https://github.com/bem-contrib/html2bemjson
html to bemjson converter
https://github.com/bem-contrib/html2bemjson
Last synced: 6 months ago
JSON representation
html to bemjson converter
- Host: GitHub
- URL: https://github.com/bem-contrib/html2bemjson
- Owner: bem-contrib
- Created: 2014-01-07T20:02:02.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-07-15T09:30:15.000Z (almost 8 years ago)
- Last Synced: 2024-11-14T00:03:47.152Z (6 months ago)
- Language: JavaScript
- Homepage:
- Size: 28.3 KB
- Stars: 30
- Watchers: 11
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# html2bemjson
Converts HTML to [BEMJSON](https://en.bem.info/technology/bemjson/).
## Installation
```sh
npm install html2bemjson --save
```## Usage
```js
var html2bemjson = require('html2bemjson');
var html = '';html2bemjson.convert(html); // BEMJSON object
html2bemjson.stringify(html);
// {
// block: 'b1',
// content: [
// {
// block: 'b1',
// elem: 'elem1'
// }
// ]
// }
```### Options
Both methods can take options object as a second argument:
```js
require('html2bemjson').stringify('', {
preserveComments: false,
naming: { elem: '__', mod: '--' }, // refer to https://en.bem.info/tools/bem/bem-naming/ for details
indent: '\t'
});
```For more examples please refer to `test` folder.