or [rules](https://github.com/markdown-it/markdown-it/tree/master/lib),
doing something similar. It can me more simple to modify existing code,
@ -39,6 +40,7 @@ To simplify search:
## FAQ
#### I need async rule, how to do it?
Sorry. You can't do it directly. All complex parsers are sync by nature. But you
@ -47,4 +49,18 @@ can use workarounds:
1. On parse phase, replace content by random number and store it in `env`.
2. Do async processing over collected data.
3. Render content and replace those random numbers with text
(or replace first, then render)
(or replace first, then render).
Or you can render html, then parse is to DOM (or
[cheerio](https://github.com/cheeriojs/cheerio) AST) and apply transformations
in more convenient way.
#### How to replace part of text token with link?
Righ sequence is to split text to several tokens and add link tokens between.
Result will be: `text` + `link_open` + `text` + `link_close` + `text`.
See implementations of [linkify](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/linkify.js) & [emoji](https://github.com/markdown-it/markdown-it-emoji/blob/master/lib/replace.js) - those do similar things.
__Note.__ Don't try to replace text with html markup! That's not secure.