Skip to content

Commit 045ca84

Browse files
Document risk of adding infinite extensions when using global marked instance (#3702)
Document risk of adding infinite extensions when using global marked instance. Resolves #3701
1 parent eb9df63 commit 045ca84

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/USING_PRO.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ All options will overwrite those previously set, except for the following option
3737

3838
* The `extensions` option is an array of objects that can contain additional custom `renderer` and `tokenizer` steps that will execute before any of the default parsing logic occurs.
3939

40+
Importantly, ensure that the extensions are only added to `marked` once (ie in the global scope of a regular JavaScript or TypeScript module). If they are added in a function that is called repeatedly, or in the JS for an HTML component in a library such as Svelte, your extensions will be added repeatedly, eventually causing a recursion error. If you cannot prevent the code from being run repeatedly, you should create a [Marked instance](/using_advanced#instance) so that your extensions are stored independently from the global instance Marked provides.
41+
4042
***
4143

4244
<h2>The Marked Pipeline</h2>

0 commit comments

Comments
 (0)