@awesome-fe/translate
Version:
Translation utils
21 lines • 714 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Rehype = void 0;
const unified = require("unified");
const rehypeStringify = require("rehype-stringify");
const rehypeParse = require("rehype-parse");
class Rehype {
static stringify(node) {
return unified().use(rehypeStringify, { closeSelfClosing: true }).stringify(node);
}
static parse(html) {
return unified().use(rehypeParse).parse(html);
}
static parseFragment(html) {
const htmlElement = this.parse(html).children[0];
const bodyElement = htmlElement.children[1];
return bodyElement.children[0];
}
}
exports.Rehype = Rehype;
//# sourceMappingURL=rehype.js.map