An open API service indexing awesome lists of open source software.

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

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.