Html2bemjson
html to bemjson converter
Install / Use
/learn @bem-contrib/Html2bemjsonREADME
html2bemjson
Converts HTML to BEMJSON.
Installation
npm install html2bemjson --save
Usage
var html2bemjson = require('html2bemjson');
var html = '<div class="b1"><div class="b1__elem1"></div></div>';
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:
require('html2bemjson').stringify('<div class="b1 b1--mod">', {
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.
Related Skills
node-connect
347.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
