main
 1import type { RehypePlugin } from "@astrojs/markdown-remark";
 2import { visit } from "unist-util-visit";
 3
 4// Typst HTML export produces a full document; feed content only needs its body.
 5export const rehypeExtractBody: RehypePlugin = () => (tree) => {
 6  const root = tree as unknown as {
 7    type?: string;
 8    children: unknown[];
 9    tagName?: string;
10    properties?: Record<string, unknown>;
11  };
12  visit(tree, "element", (node) => {
13    if (node.tagName !== "body") {
14      return;
15    }
16    root.children = node.children;
17    root.type = "root";
18    delete root.tagName;
19    delete root.properties;
20    return false;
21  });
22};