可以将markdown转换成[use::mdast]

使用示例

ts-node环境下

use::ts-node

async function main() {
  let { remarkParse } = await import("remark-parse");
  let { remark } = await import("remark");
  let mdast = await remark().use(remarkParse).parse("# Hello, world!");
  console.dir(mdast);
}
main();
{
  type: 'root',
  children: [
    {
      type: 'heading',
      depth: 1,
      children: [
        {
          type: 'text',
          value: 'Hello, world!',
          position: {
            start: { line: 1, column: 3, offset: 2 },
            end: { line: 1, column: 16, offset: 15 }
          }
        }
      ],
      position: {
        start: { line: 1, column: 1, offset: 0 },
        end: { line: 1, column: 16, offset: 15 }
      }
    }
  ],
  position: {
    start: { line: 1, column: 1, offset: 0 },
    end: { line: 1, column: 16, offset: 15 }
  }
}

适用范围

生态

  • 插件丰富

优势

  • 使用简单

功能

father:: 解析markdown

child:: remark_stringify