very-small-parser
Version:
A very small Markdown, HTML, and CSS parser.
18 lines (17 loc) • 496 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.toHast = void 0;
const toHast = (node) => {
if (typeof node === 'string')
return { type: 'text', value: node };
const [tag, properties, ...children] = node;
const element = {
type: 'element',
tagName: tag + '',
children: children.map(exports.toHast),
};
if (properties)
element.properties = properties;
return element;
};
exports.toHast = toHast;
;