{"id":15048786,"url":"https://github.com/birhoff/md-to-bemjson","last_synced_at":"2025-10-04T10:30:50.466Z","repository":{"id":57293199,"uuid":"83795486","full_name":"birhoff/md-to-bemjson","owner":"birhoff","description":"DEPRECATED: https://github.com/bem-contrib/md-to-bemjson","archived":true,"fork":false,"pushed_at":"2017-11-10T22:54:47.000Z","size":94,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-17T13:47:14.128Z","etag":null,"topics":["bemjson","converter","markdown"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/birhoff.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-03T12:22:32.000Z","updated_at":"2023-01-28T21:30:47.000Z","dependencies_parsed_at":"2022-09-01T08:40:35.147Z","dependency_job_id":null,"html_url":"https://github.com/birhoff/md-to-bemjson","commit_stats":null,"previous_names":["birhoff/md-2-bemjson"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/birhoff%2Fmd-to-bemjson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/birhoff%2Fmd-to-bemjson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/birhoff%2Fmd-to-bemjson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/birhoff%2Fmd-to-bemjson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/birhoff","download_url":"https://codeload.github.com/birhoff/md-to-bemjson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235238058,"owners_count":18958041,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bemjson","converter","markdown"],"created_at":"2024-09-24T21:16:14.701Z","updated_at":"2025-10-04T10:30:50.110Z","avatar_url":"https://github.com/birhoff.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# md-to-bemjson\nConverts [markdown][markdown] to [bemjson][bemjson].\n\n[![NPM Status][npm-img]][npm]\n[![Travis Status][test-img]][travis]\n[![Coverage Status][coverage-img]][coveralls]\n[![Dependency Status][dependency-img]][david]\n[![Greenkeeper badge][greenkeeper-img]][greenkeeper]\n\n[npm]:            https://www.npmjs.org/package/md-to-bemjson\n[npm-img]:        https://img.shields.io/npm/v/md-to-bemjson.svg\n\n[travis]:         https://travis-ci.org/birhoff/md-to-bemjson\n[test-img]:       https://img.shields.io/travis/birhoff/md-to-bemjson.svg?label=tests\n\n[coveralls]:      https://coveralls.io/r/birhoff/md-to-bemjson\n[coverage-img]:   https://img.shields.io/coveralls/birhoff/md-to-bemjson.svg\n\n[david]:          https://david-dm.org/birhoff/md-to-bemjson\n[dependency-img]: http://img.shields.io/david/birhoff/md-to-bemjson.svg\n\n[greenkeeper]:    https://greenkeeper.io/\n[greenkeeper-img]:https://badges.greenkeeper.io/birhoff/md-to-bemjson.svg\n\n## Requirements\n\n* [Node.js 4+](https://nodejs.org/en/)\n\n## Install\n\n```sh\n$ npm install md-to-bemjson\n```\n\n## Usage\n\n```js\nconst toBemjson = require('md-to-bemjson').convertSync;\nconst bjson = toBemjson('# Hello world');\n\nconsole.log(JSON.stringify(bjson, null, 4));\n```\nYields:\n```json\n{\n    \"block\": \"md-root\",\n    \"content\": {\n        \"block\": \"heading\",\n        \"content\": \"Hello world\",\n        \"level\": 1,\n        \"mods\": {\n            \"level\": 1\n        }\n    }\n}\n```\n\n[Markdown][markdown] converter to [bemjson][bemjson]\n----------------------------------------------------\n\nModule use [remark][remark] with several plugins and custom compiler to convert [markdown][markdown] to [bemjson][bemjson].\nPlugins divided into two groups: [necessary](#necessary-plugins)(you can't disable this plugins) and [optional](#optional-plugins).\n\n### Necessary plugins:\n* [remark-inline-links](https://github.com/wooorm/remark-inline-links) - [bemjson][bemjson] don't support references.\n\n### Optional plugins:\n* [remark-github](https://github.com/wooorm/remark-github) - [Github](github.com) integrations (issues, commits, mentions)\n\n### Compiler\n* [remark-bemjson][remark-bemjson] - custom [bemjson][bemjson] compiler\n\n\nAPI\n---\n\n* [constructor(\\[options\\])](#constructoroptions)\n* [convert(markdown)](#convertmarkdown--promise)\n* [convertSync(markdown)](#convertsyncmarkdown--bemjson)\n* [stringify(markdown)](#stringifymarkdown--promise)\n* [stringifySync(markdown)](#stringifysyncmarkdown--string)\n* [_static_ convert(markdown\\[, options\\])](#static-convertmarkdown--options--promise)\n* [_static_ convertSync(markdown\\[, options\\])](#static-convertsyncmarkdown--options--bemjson)\n* [_static_ stringify(markdown\\[, options\\])](#static-stringifymarkdown--options--promise)\n* [_static_ stringifySync(markdown\\[, options\\])](#static-stringifysyncmarkdown--options--string)\n\n### constructor(\\[options\\])\n\n#### Options\nParameter    | Type                 | Description\n-------------|----------------------|------------------------------\n`github`     | _Object_, _boolean_            | Enables [github][github] support with [remark][remark] plugin [remark-github](https://github.com/wooorm/remark-github). Default `false`.\n`exportType` | _enum\u003cstring\u003e_       | [remark-bemjson][remark-bemjson] option. Exports to certain type with `.stringify`. Supported [exports](https://github.com/birhoff/remark-bemjson#string-exporttype---determinate-how-to-export-bemjson-default-commonjs).\n`exportName` | _string_             | [remark-bemjson][remark-bemjson] option. Used with `exportType=(modules, umd, YModules)` stringify [bemjson][bemjson] with exported given name.\n`augment`    | _Function_, _Object_ | Options for augmentation resulting [bemjson][bemjson] by every node. As function accepts bemNode and must return it.\n`plugins`    | _Array\u003cObject\u003e_      | Options for additional [plugins][remark-plugins] to be included. Plugin format: `{ plugin: Function, options: Object }`\n\n#### Options.augment\nParameter    | Type     | Description\n-------------|----------|------------------------------\n`prefix`     | _string_ | Add prefix to all blocks. __Important:__ for root replace original prefix.\n`scope`      | _string_ | Replace root block with scope. And replace all blocks with elems.\n`map`        | _Object_ | Replace block names with provided in map. [Available blocks](https://github.com/birhoff/mdast-util-to-bemjson/blob/master/doc/rules.md).\n`html`       | _Object_ | Options for converting html to bemjson with [html2bemjson](https://github.com/bem-contrib/html2bemjson).\n\n__Important:__ Augmentation flow is serial. Order: _map_, _prefix_, _scope_.\n__Important:__ Other augmentations does not affect html.\n\n\n### convert(markdown) =\u003e Promise\u003cBemjson\u003e\n\nParameter | Type      | Description\n----------|-----------|------------------------------\n`markdown`| _string_  | Markdown text\n\nAsynchronously converts [markdown][markdown] to [bemjson][bemjson].\n\n```js\nconst Converter = require('md-to-bemjson');\nconst md2Bemjson = new Converter();\n\nmd2Bemjson.convert('# Hello world').then(bjson =\u003e console.log(JSON.stringify(bjson, null, 4)))\n```\nYields:\n```json\n{\n    \"block\": \"md-root\",\n    \"content\": {\n        \"block\": \"heading\",\n        \"content\": \"Hello world\",\n        \"level\": 1,\n        \"mods\": {\n            \"level\": 1\n        }\n    }\n}\n```\n\n### convertSync(markdown) =\u003e Bemjson\n\nParameter | Type      | Description\n----------|-----------|------------------------------\n`markdown`| _string_  | Markdown text\n\nSynchronously converts [markdown][markdown] to [bemjson][bemjson].\n\n```js\nconst Converter = require('md-to-bemjson');\nconst md2Bemjson = new Converter();\n\nconsole.log(JSON.stringify(md2Bemjson.convertSync('# Hello world'), null, 4));\n```\nYields:\n```json\n{\n    \"block\": \"md-root\",\n    \"content\": {\n        \"block\": \"heading\",\n        \"content\": \"Hello world\",\n        \"level\": 1,\n        \"mods\": {\n            \"level\": 1\n        }\n    }\n}\n```\n\n### stringify(markdown \\[, options\\]) =\u003e Promise\u003cString\u003e\n\nParameter | Type      | Description\n----------|-----------|------------------------------\n`markdown`| _string_  | Markdown text\n`options` | _Object_  | Options prefixed with [`export*`](#options). __Important:__ Creates new processor. For better performance set options via constructor.\n\nAsynchronously converts and stringify [markdown][markdown] to [bemjson][bemjson] module with exports.\n\n```js\nconst Converter = require('md-to-bemjson');\nconst md2Bemjson = new Converter();\n\nmd2Bemjson.stringify('# Hello world').then(content =\u003e console.log(content))\n```\nYields:\n```js\nmodule.exports = {\n    block: 'md-root',\n    content: {\n        block: 'heading',\n        content: 'Hello world',\n        \"level\": 1,\n        mods: {\n            'level': 1\n        }\n    }\n};\n```\n\n### stringifySync(markdown \\[, options\\]) =\u003e String\n\nParameter | Type      | Description\n----------|-----------|------------------------------\n`markdown`| _string_  | Markdown text\n`options` | _Object_  | Options prefixed with [`export*`](#options). __Important:__ Creates new processor. For better performance set options via constructor.\n\nSynchronously converts and stringify [markdown][markdown] to [bemjson][bemjson] module with exports.\n\n```js\nconst Converter = require('md-to-bemjson');\nconst md2Bemjson = new Converter();\n\nconsole.log(md2Bemjson.stringifySync('# Hello world'));\n ```\nYields:\n```js\nmodule.exports = {\n    block: 'md-root',\n    content: {\n        block: 'heading',\n        content: 'Hello world',\n        level: 1,\n        mods: {\n            'level': 1\n        }\n    }\n};\n```\n\n### _static_ convert(markdown \\[, options\\]) =\u003e Promise\u003cBemjson\u003e\n\nParameter | Type      | Description\n----------|-----------|------------------------------\n`markdown`| _string_  | Markdown text\n`options` | _Object_  | [plugin options](#options)\n\nAsynchronously converts [markdown][markdown] to [bemjson][bemjson].\n\n```js\nconst toBemjson = require('md-to-bemjson').convert;\n\ntoBemjson('# Hello world').then(bjson =\u003e console.log(JSON.stringify(bjson, null, 4)))\n```\nYields:\n ```json\n{\n    \"block\": \"md-root\",\n    \"content\": {\n        \"block\": \"heading\",\n        \"content\": \"Hello world\",\n        \"level\": 1,\n        \"mods\": {\n            \"level\": 1\n        }\n    }\n}\n```\n\n### _static_ convertSync(markdown \\[, options\\]) =\u003e Bemjson\n\nParameter | Type      | Description\n----------|-----------|------------------------------\n`markdown`| _string_  | Markdown text\n`options` | _Object_  | [plugin options](#options)\n\nSynchronously converts [markdown][markdown] to [bemjson][bemjson].\n\n```js\nconst toBemjson = require('md-to-bemjson').convertSync;\n\nconsole.log(JSON.stringify(toBemjson('# Hello world'), null, 4));\n```\nYields:\n```json\n{\n    \"block\": \"md-root\",\n    \"content\": {\n        \"block\": \"heading\",\n        \"content\": \"Hello world\",\n        \"level\": 1,\n        \"mods\": {\n            \"level\": 1\n        }\n    }\n}\n```\n\n### _static_ stringify(markdown \\[, options\\]) =\u003e Promise\u003cString\u003e\n\nParameter | Type      | Description\n----------|-----------|------------------------------\n`markdown`| _string_  | Markdown text\n`options` | _Object_  | [plugin options](#options)\n\nAsynchronously converts and stringify [markdown][markdown] to [bemjson][bemjson] module with exports.\n\n```js\nconst toBemjsonString = require('md-to-bemjson').stringify;\n\ntoBemjsonString('# Hello world').then(bjson =\u003e console.log(JSON.stringify(bjson, null, 4)));\n```\nYields:\n```js\nmodule.exports = {\n    block: 'md-root',\n    content: {\n        block: 'heading',\n        content: 'Hello world',\n        level: 1,\n        mods: {\n            level: 1\n        }\n    }\n};\n```\n\n### _static_ stringifySync(markdown \\[, options\\]) =\u003e String\n\nParameter | Type      | Description\n----------|-----------|------------------------------\n`markdown`| _string_  | Markdown text\n`options` | _Object_  | [plugin options](#options)\n\nSynchronously converts and stringify [markdown][markdown] to [bemjson][bemjson] module with exports.\n\n```js\nconst toBemjsonString = require('md-to-bemjson').stringifySync;\n\nconsole.log(toBemjsonString('# Hello world'));\n```\nYields:\n```js\nmodule.exports = {\n    block: 'md-root',\n    content: {\n        block: 'heading',\n        content: 'Hello world',\n        level: 1,\n        mods: {\n            'level': 1\n        }\n    }\n};\n```\n\nLicense\n-------\n\nCode and documentation copyright 2017 YANDEX LLC. Code released under the [Mozilla Public License 2.0](LICENSE.txt).\n\n\n[bemjson]: https://en.bem.info/platform/bemjson/\n[remark-bemjson]: https://github.com/birhoff/remark-bemjson\n[markdown]: https://wikipedia.org/wiki/Markdown\n[github]: https://github.com/\n[remark]: https://github.com/wooorm/remark\n[remark-plugins]: https://github.com/wooorm/remark/blob/master/doc/plugins.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbirhoff%2Fmd-to-bemjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbirhoff%2Fmd-to-bemjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbirhoff%2Fmd-to-bemjson/lists"}