Markdown parser for Go that satisfies the following requirements:
- Standards-compliant.Markdown has many dialects.
- GitHub-Flavored Markdown is widely used and is based upon CommonMark, effectively mooting the question of whether or not CommonMark is an ideal specification.CommonMark is complicated and hard to implement
- Easy to extend.
- Markdown is poor in document expressions compared to other light markup languages such as reStructuredText.
- We have extensions to the Markdown syntax, e.g. PHP Markdown Extra, GitHub Flavored Markdown.
- Well-structured.
- AST-based; preserves source position of nodes
- Written in pure Golang
Easy to extend, well-structured, standards-compliant
golang-commonmark may be a good choice, but it seems to be a copy of markdown-it.
blackfriday.v2 is a fast and widely-used implementation but is not CommonMark-compliant and cannot be extended from outside of the package, since its AST uses structs instead of interfaces.
Furthermore, its behavior differs from other implementations in some cases, especially regarding lists: Deeply nested lists don’t output correctly #329, List block cannot have a second line #244, etc.
This behavior sometimes causes problems. If you migrate your Markdown text from GitHub to blackfriday-based wikis, many lists will immediately be broken.
As mentioned above, CommonMark is complicated and hard to implement, so Markdown parsers based on CommonMark are few and far between.
Features
- Standards-compliant. goldmark is fully compliant with the latest CommonMark specification.
- Extensible. Do you want to add a
@username
mention syntax to Markdown? You can easily do so in goldmark. You can add your AST nodes, parsers for block-level elements, parsers for inline-level elements, transformers for paragraphs, transformers for the whole AST structure, and renderers. - Performance. goldmark’s performance is on par with that of cmark, the CommonMark reference implementation written in C.
- Robust. goldmark is tested with go-fuzz, a fuzz testing tool.
- Built-in extensions. goldmark ships with common extensions like tables, strikethrough, task lists, and definition lists.
- Depends only on standard libraries.
There is no ads to display, Please add some