Skip to content
This repository has been archived by the owner. It is now read-only.
transforms mdast tree to bemjson tree
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc
lib
test
.editorconfig
.eslintrc.js
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
index.js
package.json

README.md

mdast-util-to-bemjson

Transforms MDAST tree to bemjson regarding to rules.

NPM Status Travis Status Coverage Status Dependency Status Greenkeeper badge

Requirements

Install

$ npm install mdast-util-to-bemjson

Usage

const unified = require('unified');
const markdown = require('remark-parse');
const toBemjson = require('mdast-util-to-bemjson');

const mdast = unified().use(markdown).parse('# Hello im _heading_');
const bjson = toBemjson(mdast);

console.log(JSON.stringify(bjson, null, 4));

Yields:

{
    "block": "md-root",
    "content": {
        "block": "heading",
        "mods": {
            "level": 1
        },
        "level": 1,
        "content": [
            "Hello im ",
            {
                "block": "emphasis",
                "content": "heading"
            }
        ]
    }
}

API

toBemjson(mdastTree[, options])

options

  • Function augment — callback called on every node.

augment(bemNode):bemNode. Important: Must return bemNode.

bemNode - representation of bem entity (block, elem, mod, props)

License

Code and documentation copyright 2017 YANDEX LLC. Code released under the Mozilla Public License 2.0.

You can’t perform that action at this time.