Skip to main content

unifiedjs

  • unifiedjs/unified
    • interface for parsing, inspecting, transforming, and serializing content through syntax trees
  • learn
  • 主要处理模块
  • vfile
    • Virtual file format for text processing
  • mdast-util-to-hast
  • AST - 语法树结构
    • unist
      • Universal Syntax Tree
      • 基础 AST - 其他 AST 扩展于该 AST
      • Node
        • type
        • data
        • position: Position
          • start: Point
            • line, column, offset
          • end, indent
      • Parent extends Node
        • children: Node[]
      • Literal extends Node
        • value: any
    • mdast
      • Markdown Abstract Syntax Tree
    • hast
      • HTML, SVG, MathML
      • Hypertext Abstract Syntax Tree
    • nlcst - for natural language
    • xast - for XML
  • micromark
    • state machine
    • 替代 remark-parse
    • SyntaxExtension
    • HtmlExtension
import { micromark } from 'micromark';
import { gfm, gfmHtml } from 'micromark-extension-gfm';

const value = '* [x] done';

const result = micromark(value, {
extensions: [gfm()],
htmlExtensions: [gfmHtml()],
});

// 输出 HTML
console.log(result);