marked icon indicating copy to clipboard operation
marked copied to clipboard

Clarify ambiguity around "extensions"

Open webketje opened this issue 1 year ago • 3 comments

What pain point are you perceiving?. There are 2 types of extensions with marked:

  • TokenizerAndRendererExtensions
  • MarkedExtensions

There are 3 (and more) signatures:

  • new Marked(extension, extension, extension)
  • marked.use(extension)
  • marked.use({ extensions: [TokenizerAndRendererExtensions] })

I was really confused by this and left me wondering whether the extension types had something in common (they don't). Then I realized TokenizerAndRendererExtensions are actually extensions options for MarkedExtensions.

Describe the solution you'd like So I think something it would be better if the MarkedExtensions were renamed to MarkedPlugins or the option property extensions is renamed to tokenizerAndRendererExtensions. I mean, I don't really have a preference for a solution, but at least maybe prefix the word "extensions" in the doc with the type, so it is very clear which type of extention it is about. For example the docs have 2 sections "Known extensions" vs "Custom Extensions", but both talk about different types of extensions.

Context I maintain @metalsmith/markdown which relies on marked and I'm working on upgrading to the latest version. In that context I need to remap a single options object and pass some of them to marked. That means I need 2 config keys (eg 'markedExtensions', and 'tokenizerAndRendererExtensions') in an object to .use the plugins from a dictionary

webketje avatar Jan 30 '24 02:01 webketje

Naming things is one of the hardest problems.

If you want to create a PR to update the docs, that would be great 😃 👍

UziTech avatar Jan 30 '24 02:01 UziTech