goldmark 是用 Go 语言编写的 markdown 解析器。易于扩展,符合标准(CommonMark),结构合理。
特性:
goldmark 对 Markdown 文本的处理流程如下:
<Markdown in []byte, parser.Context> | V +-------- parser.Parser --------------------------- | 1. Parse block elements into AST | 1. If a parsed block is a paragraph, apply | ast.ParagraphTransformer | 2. Traverse AST and parse blocks. | 1. Process delimiters(emphasis) at the end of | block parsing | 3. Apply parser.ASTTransformers to AST | V <ast.Node> | V +------- renderer.Renderer ------------------------ | 1. Traverse AST and apply renderer.NodeRenderer | corespond to the node type | V <Output>