Testing Markdown parser to format md files (Roam Research to Obsidian)
- Best working example is using VS code plugin - Tidy Markdown to format md files from Roam Research
- But it still has some issues in formatting fenced code blocks - it adds additional fences (```) when it encounters curly braces ({})
- Another example - Markdown-Formatter - for understanding the logic
- VS-Code extension - Markdown spec Formatter
- How it works:
- It uses remark to parse the markdown and generate an AST.
- Then remark-stringify to re-generate the string from the AST and apply the formatting rules to it.
- Additionally, mdast-util-toc is used to generate a ToC.