docs/development.md
Before continuing, make sure you've read:
target="_blank" for the links.markdown-it package as dependency in package.json.
If you need access to internals, those are available via a parser instance,
passed on plugin load. See properties of main class and nested objects.To simplify search:
package.json keywords markdown-it and markdown-it-plugin for plugins.markdown-it for any other related packages.Sorry. You can't do it directly. All complex parsers are sync by nature. But you can use workarounds:
env.Alternatively, you can render HTML, then parse it to DOM, or cheerio AST, and apply transformations in a more convenient way.
The right sequence is to split text to several tokens and add link tokens in between.
The result will be: text + link_open + text + link_close + text.
See implementations of linkify and emoji - those do text token splits.
Note. Don't try to replace text with HTML markup! That's not secure.
The inline parser skips pieces of texts to optimize speed. It stops only on a small set of chars, which can be tokens. We did not made this list extensible for performance reasons too.
If you are absolutely sure that something important is missing there - create a ticket and we will consider adding it as a new charcode.
We do a markdown parser. It should keep the "markdown spirit". Other things should be kept separate, in plugins, for example. We have no clear criteria, sorry. Probably, you will find CommonMark forum a useful read to understand us better.
Of course, if you find the architecture of this parser interesting for another type of markup, you are welcome to reuse it in another project.