myst-cli
Version:
Command line tools for MyST
27 lines (26 loc) • 837 B
JavaScript
import { parseMyst } from '../process/myst.js';
/**
* Parse frontmatter parts and prepend them as blocks to mdast children
*
* @deprecated frontmatter parts are now processed separately by MyST
*/
export function frontmatterPartsTransform(session, file, mdast, frontmatter) {
if (!frontmatter.parts)
return;
const blocks = Object.entries(frontmatter.parts)
.map(([part, contents]) => {
const data = { part };
return contents.map((content) => {
const root = parseMyst(session, content, file);
return {
type: 'block',
data,
visibility: 'remove',
children: root.children,
};
});
})
.flat();
mdast.children = [...blocks, ...mdast.children];
delete frontmatter.parts;
}