This package has been deprecated

Author message:

Deprecated: use something like remark instead?

markdown-tree

0.0.0 • Public • Published

markdown-tree Flattr this!experimental

Convert a markdown document into a JSON tree structure, using marked under the hood.

Should be helpful for cases where you might want to analyse the structure of the document, e.g. auto-generating sites from GitHub wikis.

Usage

markdown-tree

require('markdown-tree')(src[, options])

src should be the Markdown document you want to parse, as a string.

options is passed on to marked.lexer.

Each Node in the resulting tree represents either the document root or a heading, and should be formatted similarly to this:

{
    type: "Heading" // or, "Document"
  , text: "The Heading Contents"
  , children: []
  , depth: 2 // e.g. "### hello" would be 3
  , tokens: [
    {
        type: 'paragraph'
      , text: 'The tokens from each paragraph...'
    },
    {
        type: 'paragraph'
      , text: '...before the next heading go here!'
    },
    {
        type: 'paragraph'
      , text: 'This data comes directly from marked.'
    }
  ]
}

There's also a parent property, but that's hidden to make logging the tree a little cleaner.

Note also that the tokens array is actually retrieved from the marked module untouched, so you can run it through marked.parse with little trouble to compile that section to standalone HTML.

License

MIT. See LICENSE.md for details.

Readme

Keywords

none

Package Sidebar

Install

npm i markdown-tree

Weekly Downloads

13

Version

0.0.0

License

MIT

Last publish

Collaborators

  • hughsk