markedjs / marked

A markdown parser and compiler. Built for speed.
https://marked.js.org
Other
33.17k stars 3.39k forks source link

Confusing/contradicting documentation regarding extensions #3488

Open ronny-rentner opened 4 weeks ago

ronny-rentner commented 4 weeks ago

On https://marked.js.org/using_pro#use it's being said I can use marked.use(myExtension, extension2, extension3); to load my custom extension but this doesn't work.

On https://marked.js.org/using_pro#extensions you learn that you actually have to use marked.use({ extensions: [description] }); with the key extensions.

The first version does not work but there's also no error message. Just nothing happens which is bad because you start guessing around why nothing happens and why your extension is not being used.

UziTech commented 4 weeks ago

There is a difference between "Marked Extension" and "Custom Extension" see #3182 and The two hardest things in computer science

ronny-rentner commented 4 weeks ago

And this difference is necessary? What's the idea behind it? Why not treat any kind of extension the same and simplify things?

UziTech commented 4 weeks ago

A marked extension can have multiple custom extensions, tokenizer extensions, and renderer extensions. Yes this is necessary mostly for legacy reasons. It would be great to clean it up but there will be many extensions that would break.