Support for Extension Token

DougR noreply@talk.commonmark.org writes:

It could really improve the Markdown ecosystem if the
parsers/renderers implemented hooks for plugin extensions.

Some of them do. gfm’s extensions to cmark were implemented through a
plugin system designed by Mathieu Duponchelle.

The javascript parser markdown-it has a plugin system.

The Haskell parser I’m
working

on has an extension system.

Probably others too, these are just the ones I’m aware of

It would be fairly simple to have the parser detect the marker/token in
markdown and pass the information up to an extension hook.

Here you’re underestimating the complexity. As these examples show,
it’s fairly complex to design a plugin system that works with commonmark.

Note that it’s also possible to customize by re-using the existing
constructs. E.g. one could construe a link with an empty target as
a wikilink, or overload HTML comments in the way described. For this
kind of thing, you don’t need to modify the parser at all; you just
need a way to manipulate the AST after parsing. My
lcmark gives a way to do this
with cmark.

1 Like