UNPKG

@brendonovich/kobalte__solidbase

Version:

Fully featured, fully customisable static site generation for SolidStart

26 lines (21 loc) 646 B
import { visit } from "unist-util-visit"; export function remarkGithubAlertsToDirectives() { return (tree: any) => { visit(tree, (node) => { if (node.type !== "blockquote") return; const text: string | undefined = node.children?.[0]?.children?.[0]?.value; if (!text) return; const matches = text.match(/^\[!(\w+)]/); if (!matches) return; const key = matches[1]; if (!key) return; const directive = key.toLowerCase(); node.children[0].children[0].value = text.slice(matches[0].length); Object.assign(node, { type: "containerDirective", name: directive, children: node.children, }); }); }; }