# marked-token-tree

> Build a token tree from marked tokens

Latest version **0.2.0** (published 2016-11-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install marked-token-tree
pnpm add marked-token-tree
yarn add marked-token-tree
bun add marked-token-tree
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2016-11-25 |
| First published | 2016-11-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Viorel Cojocaru |
| Maintainers | vio |
| Keywords | markdown |

## Links

- npm: https://www.npmjs.com/package/marked-token-tree
- Repository: https://github.com/vio/marked-token-tree
- Homepage: https://github.com/vio/marked-token-tree#readme
- Issues: https://github.com/vio/marked-token-tree/issues
- npm.io page: https://npm.io/package/marked-token-tree

## Dependencies (1)

- [marked](https://npm.io/package/marked.md) ^0.3.6

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 0.2.0 (latest) — 2016-11-25
- 0.1.0 — 2016-11-25
- 0.0.1 — 2016-11-24

## README

# marked-token-tree

Build a tocken tree from [marked](https://www.npmjs.com/package/marked) tokens.

---

1. [Installation](#installation)
2. [Usage](#usage)
  1. [Get the tree object](#get-the-tree-object)
  2. [Walk the token tree](#walk-the-token-tree)


## Instalation

```sh
npm install --dev marked-token-tree
```

## Usage

### Get the tree object

```js
const tree = require('marked-token-tre')

const source = `
    # Main heading
    Main block text

    ## Section 1
    Second level block text

    ### Section 1.1
    Third level block text

    ### Section 1.2
    Third level block text

    \```stylus
    .element
    color: black
    \```

    \```css
    .element {
    color: #000;
    }
    \```

    ## Section 2

    Second level block text
  `;
  
  const output = tree(source);
  
  console.log(output);
```

will output:

```json
{  
  "heading":"Main heading",
    "depth":1,
    "content":[ {  
      "type":"paragraph",
      "text":"Main block text"
    }],
    "children":[{  
      "heading":"Section 1",
      "depth":2,
      "content":[{  
        "type":"paragraph",
        "text":"Second level block text"
      }],
      "children":[{  
        "heading":"Section 1.1",
        "depth":3,
        "content":[{  
            "type":"paragraph",
            "text":"Third level block text"
          }]
      }, {  
        "heading":"Section 1.2",
        "depth":3,
        "content": [{  
            "type":"paragraph",
            "text":"Third level block text"
          }, {  
            "type":"code",
            "text":".element\n    color: black",
            "lang":"stylus"
          }, {  
            "type":"code",
            "text":".element {\n    color: #000;\n}",
            "lang":"css"
          }]
      }]
    }, {  
      "heading":"Section 2",
      "depth":2,
      "content":[{  
          "type":"paragraph",
          "text":"Second level block text"
        }]
    }]
}
```

### Walk the token tree

```js
const fs = require('fs')
const tree = require('marked-token-tree')
const source = fs.readFileSync('./source.md')

source.walk((token, block) => {
  // process token and coresponding block
})

---
_Source: https://npm.io/package/marked-token-tree · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
