How to add new node type to the AST for [[_TOC_]]
and [[_TOSP_]]
?
#1258
-
I'd like to implement a plugin that support custom syntax offered by Wiki page TOC of the Azure DevOps Services. The syntax will be like this: [[_TOC_]]
[[_TOSP_]] Here is the code I wrote currently: let parsed = unified()
.use(remarkParse)
.use(remarkGfm)
.use(remarkFrontmatter, ['yaml', 'toml'])
.use(remarkStringify, {
emphasis: '_',
rule: '-',
})
.processSync(txt).toString(); After running my code, the Markdown will become this: \[\[_TOC_]]
\[\[_TOSP_]] But I want the result is: [[_TOC_]]
[[_TOSP_]] Is that possible? I need some help on how to implement this. Is there any docs or reference for me? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Welcome @doggy8088! 👋
It is possible, though generally not recommended to create yet another markdown flavor (https://github.com/micromark/micromark#extending-markdown) An alternative would be nudging Azure/Microsoft toward using standard markdown directives https://github.com/remarkjs/remark-directive#readme, instead of creating another markdown flavor. |
Beta Was this translation helpful? Give feedback.
Welcome @doggy8088! 👋
It is possible, though generally not recommended to create yet another markdown flavor (https://github.com/micromark/micromark#extending-markdown)
If you do want to add token type/AST node, see https://github.com/micromark/micromark#creating-a-micromark-extension
And draw some inspiration from https://github.com/landakram/remark-wiki-link
An alternative would be nudging Azure/Microsoft toward using standard markdown directives https://github.com/remarkjs/remark-directive#readme, instead of creating another markdown flavor.