ITADN

extensions array in options does not work

#3956Opentrumpetinc 创建于 2026-04-24
need more info
T
trumpetinccommented
**Marked version:** 6.0.0 **Describe the bug** The documentation ( https://marked.js.org/using_pro ) indicates that passing an extensions value to the Marked options should set the extensions. However, passing an option named 'extensions' (containing an array of extensions) does not work. My testing has all been done with creating a new Marked instance. **To Reproduce** const ext1 = { name: 'Handle #test:', level: 'inline', renderer: { text(text) { if(!text.startsWith('#test:')) return false; let id = text.slice('#test:'.length); if(id.length == 0) return false; return `<a href="#${id}">${text}</a>`; } } }; const ext2 = { name: 'Handle #rest:', level: 'inline', renderer: { text(text) { if(!text.startsWith('#rest:')) return false; let id = text.slice('#rest:'.length); if(id.length == 0) return false; return `<a href="#${id}">${text}</a>`; } } }; this.marked = new Marked( {mangle: false, extensions: [ext1, ext2] } ); // this does not work this.marked = new Marked({mangle: false}, ext1, ext2); // this does work **Expected behavior** I expect passing the extensions array to the options being equivalent to passing each extensions separately. If this is not possible, then I expect the documentation to be updated.
2 条评论