myst-to-html
Version:
Export from MyST mdast to HTML
18 lines (17 loc) • 745 B
JavaScript
import { unified } from 'unified';
import rehypeStringify from 'rehype-stringify';
import { formatHtml } from './format.js';
import { mystToHast } from './schema.js';
import { State } from './state.js';
import { transform } from './transforms.js';
export function mystToHtml(tree, opts) {
const state = new State();
const pipe = unified()
.use(transform, state)
.use(mystToHast, opts === null || opts === void 0 ? void 0 : opts.hast)
.use(formatHtml, opts === null || opts === void 0 ? void 0 : opts.formatHtml)
.use(rehypeStringify, opts === null || opts === void 0 ? void 0 : opts.stringifyHtml);
const result = pipe.runSync(tree);
const html = pipe.stringify(result);
return html.trim();
}