marked-ast

Parses Markdown into an abstract syntax tree. Based on github.com/chjj/marked.

MIT 5 个版本
安装
npm install marked-ast
yarn add marked-ast
pnpm add marked-ast
bun add marked-ast
README

marked-ast

A modified version of marked that can produce an abstract syntax tree for Markdown.

Usage

var marked = require('marked-ast');
var ast = marked.parse('_This is **Markdown**_, he said.');
var html = marked.render(ast);

The package is just a wrapper for marked, so the produced HTML should be identical (if it isn't it's a bug). The AST produced in the example would look like this:

[
  {
    "type": "paragraph",
    "text": [
      {
        "type": "em",
        "text": [
          "This is ",
          {
            "type": "strong",
            "text": [ "Markdown" ]
          }
        ]
      },
      ", he said."
    ]
  }
]

Development

Basic setup:

git clone https://github.com/pdubroy/marked-ast.git
cd marked-ast
npm install
git submodule update --init

Running Tests

Use npm test to run the tests. Before checking code in, run npm run prepublish.

Updating Marked

To update to a new version of marked:

cd third_party/marked
git checkout <REF>  # E.g., `git checkout v0.3.3`
cd ../..
npm run rewrite && npm test
版本列表
0.3.0 2016-02-01
0.2.2 2015-05-18
0.2.1 2015-05-18
0.2.0 2015-01-03
0.1.0 2014-08-05