Spaces:
Running
Running
File size: 680 Bytes
4f3bb9d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
// Transform `:::outputs ... :::` into a <section class="code-outputs"> wrapper
// Requires remark-directive to be applied before this plugin
export default function remarkOutputsContainer() {
return (tree) => {
const visit = (node) => {
if (!node || typeof node !== 'object') return;
if (node.type === 'containerDirective' && node.name === 'outputs') {
node.data = node.data || {};
node.data.hName = 'section';
node.data.hProperties = { className: ['code-outputs'] };
}
const children = Array.isArray(node.children) ? node.children : [];
for (const child of children) visit(child);
};
visit(tree);
};
}
|