Accepted
We need a markdown parser that:
- Supports GitHub Flavored Markdown (GFM)
- Has good performance for real-time preview
- Allows custom renderers
- Supports extensions (math, syntax highlighting)
- Has a small footprint
- Is actively maintained
We will use Marked.js as our markdown parser.
- Performance: One of the fastest markdown parsers
- GFM support: Full GitHub Flavored Markdown support
- Extensibility: Custom renderer support for our needs
- Bundle size: Relatively small (~30KB gzipped)
- Active development: Well-maintained with regular updates
- Security: Built-in XSS protection options
- Synchronous API: Better for our real-time preview
- Limited plugin ecosystem: Compared to remark/rehype
- Less flexible: AST manipulation is limited
- Math support: Requires additional library (KaTeX)
- Simple API suits our straightforward needs
- Good balance between features and performance
marked.setOptions({
gfm: true,
breaks: true,
renderer: customRenderer
})
const html = marked(markdown)- markdown-it: More plugins but slightly slower
- remark/rehype: More powerful but complex and larger
- Showdown: Older, less performant
- Commonmark.js: Too basic, lacks GFM features