@docubook/core 2.0.3 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -217,7 +217,7 @@ function B() {
217
217
  p,
218
218
  C,
219
219
  D,
220
- u,
220
+ [u, { ignoreMissing: !0 }],
221
221
  D,
222
222
  f,
223
223
  d,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/plugins/handleCodeTitles.ts","../src/plugins/handleCodeExpandable.ts","../src/plugins/rehypeMermaid.ts","../src/plugins/remarkDirectiveToMdx.ts","../src/mdx-compiler/index.ts","../src/compile.ts","../src/plugins/rehypeCollectTocs.ts","../src/extract.ts"],"sourcesContent":["import type { Node, Parent } from \"unist\";\nimport { visit } from \"unist-util-visit\";\nimport type { ElementNode } from \"../utils\";\n\ninterface TextNode extends Node {\n type: \"text\";\n value: string;\n}\n\nexport const handleCodeTitles = () => (tree: Node) => {\n const toRemove: { parent: Parent; index: number }[] = [];\n\n visit(tree, \"element\", (node: ElementNode, index: number | null, parent: Parent | null) => {\n if (!parent || index === null || node.tagName !== \"div\") {\n return;\n }\n\n const isTitleDiv = node.properties?.className?.includes(\"rehype-code-title\");\n if (!isTitleDiv) {\n return;\n }\n\n let nextElement: ElementNode | null = null;\n for (let i = index + 1; i < parent.children.length; i++) {\n const sibling = parent.children[i];\n if (sibling.type === \"element\") {\n nextElement = sibling as ElementNode;\n break;\n }\n }\n\n if (nextElement?.tagName === \"pre\") {\n const titleNode = node.children?.[0] as TextNode;\n if (titleNode?.type === \"text\") {\n if (!nextElement.properties) {\n nextElement.properties = {};\n }\n nextElement.properties[\"data-title\"] = titleNode.value;\n nextElement.codeTitle = titleNode.value;\n toRemove.push({ parent, index });\n }\n }\n });\n\n // Remove title divs in reverse order to preserve indices\n for (let i = toRemove.length - 1; i >= 0; i--) {\n const { parent, index } = toRemove[i];\n parent.children.splice(index, 1);\n }\n};\n","import type { Node } from \"unist\";\nimport { visit } from \"unist-util-visit\";\nimport type { ElementNode } from \"../utils\";\n\n/**\n * Escape metadata values that are interpolated into MDX-compiled JavaScript.\n *\n * References:\n * - HTML spec (script data state): escape `</` as `\\u003C/` to prevent premature\n * `</script>` closing when the compiled JS is embedded as JSON in a <script> tag.\n * - Bun.escapeHTML(): escapes `< > \" ' &` for HTML context; for JS/JSON context\n * we use `\\uXXXX` JSON Unicode escapes instead so the value survives round-trip\n * through JSON.parse on the client side.\n * - React: JSX auto-escapes attribute values via `{expression}`, so values set\n * as HAST properties (data-language, data-title) are HTML-safe at render time.\n */\nfunction escapeMeta(s: string): string {\n let out = \"\";\n for (let i = 0; i < s.length; i++) {\n const ch = s[i];\n\n // HTML spec: prevent </script> in script/JSON context\n if (ch === \"<\" && s[i + 1] === \"/\") {\n out += \"\\\\u003C/\";\n i++;\n continue;\n }\n\n // JS string: escape template literal & string special chars\n if (ch === \"`\" || ch === \"$\" || ch === \"{\" || ch === \"}\" || ch === '\"' || ch === \"\\\\\") {\n out += `\\\\${ch}`;\n continue;\n }\n\n out += ch;\n }\n return out;\n}\n\ninterface CodeNode extends Node {\n type: \"code\";\n lang?: string;\n meta?: string;\n value: string;\n data?: {\n meta?: string;\n hProperties?: Record<string, unknown>;\n };\n}\n\nfunction countCodeLines(raw: string): number {\n let normalized = raw.replace(/\\r\\n/g, \"\\n\");\n if (normalized.startsWith(\"\\n\")) normalized = normalized.slice(1);\n if (normalized.endsWith(\"\\n\")) normalized = normalized.slice(0, -1);\n\n if (normalized.length === 0) return 0;\n return normalized.split(\"\\n\").length;\n}\n\nexport const handleCodeExpandableRemark = () => (tree: Node) => {\n visit(tree, \"code\", (node: CodeNode) => {\n if (!node.meta) return;\n\n const isExpandable = node.meta.includes(\"Expandable\");\n const [languagePart, titlePart] = (node.lang ?? \"\").split(\":\");\n const normalizedLanguage = languagePart?.trim();\n const normalizedTitle = titlePart?.trim();\n\n if (!isExpandable) return;\n\n const lineCount = countCodeLines(node.value);\n\n if (!node.data) {\n node.data = {};\n }\n if (!node.data.hProperties) {\n node.data.hProperties = {};\n }\n\n node.data.hProperties[\"data-expandable\"] = \"true\";\n node.data.hProperties[\"data-expandable-lines\"] = lineCount.toString();\n\n if (normalizedLanguage) {\n node.data.hProperties[\"data-language\"] = normalizedLanguage;\n }\n if (normalizedTitle) {\n node.data.hProperties[\"data-title\"] = normalizedTitle;\n }\n\n const currentClassName = node.data.hProperties.className;\n const classList = Array.isArray(currentClassName)\n ? currentClassName\n : typeof currentClassName === \"string\"\n ? currentClassName.split(\" \").filter(Boolean)\n : [];\n\n if (!classList.includes(\"mdx-expandable-meta\")) {\n classList.push(\"mdx-expandable-meta\");\n }\n\n node.data.hProperties.className = classList;\n\n if (normalizedLanguage && !node.meta.includes(\"dbLang(\")) {\n node.meta = `${node.meta} dbLang(${escapeMeta(normalizedLanguage)})`.trim();\n }\n if (normalizedTitle && !node.meta.includes(\"dbTitle(\")) {\n node.meta = `${node.meta} dbTitle(${escapeMeta(normalizedTitle)})`.trim();\n }\n });\n};\n\nexport const handleCodeExpandable = () => (tree: Node) => {\n visit(tree, \"element\", (node: ElementNode) => {\n if (node.tagName !== \"pre\") return;\n\n const codeElement = node.children?.find((child) => {\n const element = child as ElementNode;\n return element.type === \"element\" && element.tagName === \"code\";\n }) as ElementNode | undefined;\n\n const codeClassName = codeElement?.properties?.className;\n const codeClassList = Array.isArray(codeClassName)\n ? codeClassName\n : typeof codeClassName === \"string\"\n ? codeClassName.split(\" \").filter(Boolean)\n : [];\n\n const codeMeta =\n codeElement?.data &&\n typeof codeElement.data === \"object\" &&\n typeof codeElement.data[\"meta\"] === \"string\"\n ? (codeElement.data[\"meta\"] as string)\n : undefined;\n\n const languageFromMeta = codeMeta?.match(/dbLang\\(([^)]+)\\)/)?.[1];\n const titleFromMeta = codeMeta?.match(/dbTitle\\(([^)]+)\\)/)?.[1];\n\n const languageFromProps =\n typeof codeElement?.properties?.[\"data-language\"] === \"string\"\n ? (codeElement.properties[\"data-language\"] as string)\n : undefined;\n const titleFromProps =\n typeof codeElement?.properties?.[\"data-title\"] === \"string\"\n ? (codeElement.properties[\"data-title\"] as string)\n : undefined;\n\n const languageFromCodeClass = codeClassList\n .find((item) => item.startsWith(\"language-\"))\n ?.replace(\"language-\", \"\");\n\n const existingPreLanguage =\n typeof node.properties?.[\"data-language\"] === \"string\"\n ? (node.properties[\"data-language\"] as string)\n : undefined;\n const existingPreTitle =\n typeof node.properties?.[\"data-title\"] === \"string\"\n ? (node.properties[\"data-title\"] as string)\n : undefined;\n\n const isExpandable =\n codeElement?.properties?.[\"data-expandable\"] === \"true\" ||\n codeClassList.includes(\"mdx-expandable-meta\") ||\n codeMeta?.includes(\"Expandable\") === true;\n\n const expandableLines = codeElement?.properties?.[\"data-expandable-lines\"];\n if (!isExpandable) return;\n\n if (!node.properties) {\n node.properties = {};\n }\n\n node.properties[\"data-expandable\"] = \"true\";\n if (typeof expandableLines === \"string\" || typeof expandableLines === \"number\") {\n node.properties[\"data-expandable-lines\"] = expandableLines.toString();\n } else if (node.raw) {\n node.properties[\"data-expandable-lines\"] = countCodeLines(node.raw).toString();\n }\n\n const resolvedLanguage =\n languageFromProps ||\n languageFromMeta ||\n languageFromCodeClass ||\n existingPreLanguage ||\n node.language;\n const resolvedTitle = titleFromProps || titleFromMeta || existingPreTitle || node.codeTitle;\n\n if (resolvedLanguage) {\n node.properties[\"data-language\"] = resolvedLanguage;\n }\n if (resolvedTitle) {\n node.properties[\"data-title\"] = resolvedTitle;\n }\n\n const className = node.properties.className;\n if (!className) {\n node.properties.className = [];\n }\n\n if (Array.isArray(node.properties.className)) {\n if (!node.properties.className.includes(\"mdx-expandable-code\")) {\n node.properties.className.push(\"mdx-expandable-code\");\n }\n } else if (typeof className === \"string\") {\n const hasMarker = className.split(\" \").includes(\"mdx-expandable-code\");\n if (!hasMarker) {\n node.properties.className = `${className} mdx-expandable-code`.trim().split(\" \");\n }\n } else {\n node.properties.className = [\"mdx-expandable-code\"];\n }\n\n if (codeElement?.properties) {\n const cleanedCodeClassList = codeClassList.filter((item) => item !== \"mdx-expandable-meta\");\n codeElement.properties.className = cleanedCodeClassList;\n }\n });\n};\n","import type { Node, Parent } from \"unist\";\nimport { visit } from \"unist-util-visit\";\nimport type { ElementNode } from \"../utils\";\n\ninterface TextNode extends Node {\n type: \"text\";\n value: string;\n}\n\n/**\n * Rehype plugin that transforms `<pre><code class=\"language-mermaid\">` fenced\n * blocks into `<Mermaid chart=\"...\">` elements.\n *\n * This allows Mermaid diagram definitions to be authored via standard fenced\n * code blocks (````mermaid) which avoids JSX parsing collisions with\n * Mermaid's `{...}` (decision nodes) and `[...]` (label nodes) syntax.\n */\nexport const rehypeMermaid = () => (tree: Node) => {\n visit(tree, \"element\", (node: ElementNode, index: number | null, parent: Parent | null) => {\n if (!parent || index === null || node.tagName !== \"pre\") return;\n\n const codeEl = node.children?.find(\n (child) =>\n (child as ElementNode).type === \"element\" && (child as ElementNode).tagName === \"code\"\n ) as ElementNode | undefined;\n\n if (!codeEl) return;\n\n const classList = Array.isArray(codeEl.properties?.className)\n ? (codeEl.properties.className as string[])\n : typeof codeEl.properties?.className === \"string\"\n ? (codeEl.properties.className as string).split(\" \").filter(Boolean)\n : [];\n\n if (!classList.includes(\"language-mermaid\")) return;\n\n const textNode = codeEl.children?.find((child) => (child as TextNode).type === \"text\") as\n TextNode | undefined;\n\n const chart = textNode?.value ?? \"\";\n\n parent.children[index] = {\n type: \"element\",\n tagName: \"Mermaid\",\n properties: { chart },\n children: [],\n } as unknown as ElementNode;\n });\n};\n","import type { Node } from \"unist\";\nimport type { VFile } from \"vfile\";\n\n/**\n * Remark plugin: convert markdown directives into MDX component elements.\n *\n * Contract (docubook):\n * - `:::name{attrs} … :::` — container: EVERY component that holds content\n * (tabs, tab, accordions, accordion, steps, step, cards, card, files,\n * folder, note + variants). Children are the block between the opening\n * `:::` and closing `:::` — bounded by micromark's container grammar, so\n * a component can never trap siblings that follow it.\n * - `::name{attrs}` — self-closing leaf (no children): file, youtube,\n * mermaid.\n * - `:tooltip[label]{tip=\"…\"}` — the ONE inline (single-colon) directive.\n * Every other text directive is rebuilt as literal text\n * (`localhost:3000` stays intact). `::tooltip` (block leaf) is removed\n * in v2 — tooltips are inline only.\n *\n * Names are PascalCased to match the components map (`file-tree` → `FileTree`).\n * Bare attributes (`{horizontal}`) become boolean props (JSX bare attribute).\n * Callout variants (`:::tip`, `:::info`, …) map to their own registry entries\n * (`Tip`/`Info`/…) which wrap the `Callout` component with the type set.\n */\nexport function remarkDirectiveToMdx() {\n return (tree: Node, file: VFile) => {\n const source = String(file);\n const root = tree as unknown as { children: Node[] };\n root.children = root.children.map((node) => transform(node, source));\n return tree;\n };\n}\n\n/** Leaves that never hold children (self-closing). */\nconst PURE_LEAVES = new Set([\"youtube\"]);\n\ntype DirectiveNode = Node & {\n type: \"containerDirective\" | \"leafDirective\" | \"textDirective\";\n name: string;\n attributes?: Record<string, string>;\n children?: Node[];\n};\n\nfunction isDirective(node: Node): node is DirectiveNode {\n return (\n node.type === \"containerDirective\" ||\n node.type === \"leafDirective\" ||\n node.type === \"textDirective\"\n );\n}\n\nfunction transform(node: Node, source: string): Node {\n if (!isDirective(node)) {\n const children = (node as unknown as { children?: Node[] }).children;\n if (Array.isArray(children)) {\n (node as unknown as { children: Node[] }).children = children.map((child) =>\n transform(child, source)\n );\n }\n return node;\n }\n if (node.type === \"textDirective\") {\n // `:tooltip[label]{tip=\"…\"}` is the one inline component — it stays\n // inside the paragraph. Every other single-colon text directive is\n // rebuilt as literal text (`localhost:3000` stays intact).\n if (node.name === \"tooltip\") {\n return inlineTooltip(node);\n }\n return literalDirective(node, source);\n }\n // Block-form tooltips are gone in v2 — degrade to literal text so the\n // author sees the directive instead of a broken component.\n if (node.type === \"leafDirective\" && node.name === \"tooltip\") {\n return literalDirective(node, source);\n }\n // containerDirective → component with children; leafDirective → self-closing.\n const children =\n node.type === \"containerDirective\" && !PURE_LEAVES.has(node.name)\n ? (node.children ?? []).map((child) => transform(child, source))\n : [];\n return directiveToElement(node, children);\n}\n\nfunction directiveToElement(directive: DirectiveNode, children: Node[]): Node {\n const name = pascalCase(directive.name);\n const attributes = Object.entries(directive.attributes ?? {}).map(([attrName, value]) => ({\n type: \"mdxJsxAttribute\",\n name: attrName,\n value: value === \"\" ? null : value,\n }));\n return {\n type: \"mdxJsxFlowElement\",\n name,\n attributes,\n children,\n } as Node;\n}\n\n/** Preserve authored syntax: parsed children and attributes lose formatting. */\nfunction literalDirective(directive: DirectiveNode, source: string): Node {\n const start = directive.position?.start.offset;\n const end = directive.position?.end.offset;\n // Synthetic nodes without source offsets cannot be restored losslessly.\n if (start === undefined || end === undefined) return directive;\n return { type: \"text\", value: source.slice(start, end) } as Node;\n}\n\n/**\n * Inline tooltip from a text directive: `:tooltip[label]{tip=\"…\"}`.\n * The label is the visible trigger (dotted underline); `tip` is the hover\n * bubble and defaults to the label, so `:tooltip[text]` alone already shows\n * a bubble. Emits an inline element so it stays inside the paragraph. The\n * bubble auto-positions (no `side` prop).\n */\nfunction inlineTooltip(directive: DirectiveNode): Node {\n const label = (directive.children ?? [])\n .map((child) => (child as { value?: string }).value ?? \"\")\n .join(\"\");\n const attrs = directive.attributes ?? {};\n const attributes = [\n { type: \"mdxJsxAttribute\", name: \"text\", value: attrs.text || label || \"?\" },\n { type: \"mdxJsxAttribute\", name: \"tip\", value: attrs.tip || label || \"\" },\n ];\n return { type: \"mdxJsxTextElement\", name: \"Tooltip\", attributes, children: [] } as Node;\n}\n\nfunction pascalCase(name: string): string {\n return name\n .split(\"-\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\"\");\n}\n","// MPL-2.0 — derived from next-mdx-remote (IBM). See LICENSE-MPL-2.0.\nimport React, { useEffect, useState, useMemo } from \"react\";\nimport * as jsxRuntime from \"react/jsx-runtime\";\nimport * as jsxDevRuntime from \"react/jsx-dev-runtime\";\nimport * as mdx from \"@mdx-js/react\";\nimport type { MDXRemoteSerializeResult } from \"./types.js\";\n\n/** Props for the client-side `<MDXRemote>` (accepts pre-serialized result). */\nexport type MDXRemoteProps = MDXRemoteSerializeResult & {\n components?: Record<string, React.ComponentType<any>>;\n /** Defer hydration to an idle callback */\n lazy?: boolean;\n};\n\n/**\n * Client-side MDX renderer.\n *\n * Accepts a pre-compiled result from `serialize()` and renders it via\n * `MDXProvider` for custom component injection.\n */\nexport function MDXRemote({\n compiledSource,\n frontmatter,\n scope = {},\n components = {},\n lazy,\n}: MDXRemoteProps): React.ReactElement {\n const [ready, setReady] = useState(!lazy || typeof window === \"undefined\");\n\n useEffect(() => {\n if (!lazy) return;\n const id = window.requestIdleCallback\n ? window.requestIdleCallback(() => setReady(true), { timeout: 500 })\n : setTimeout(() => setReady(true), 1);\n return () => {\n if (window.cancelIdleCallback) window.cancelIdleCallback(id as number);\n else clearTimeout(id as number);\n };\n }, [lazy]);\n\n const Content = useMemo(() => {\n // Non-RSC mode: compiled MDX expects `useMDXComponents` (\n // from @mdx-js/react) AND the JSX runtime.\n // In React 19, jsx/jsxs and jsxDEV live in separate modules,\n // so merge both to handle compiled output from any mode.\n const fullScope = {\n opts: { ...mdx, ...jsxRuntime, ...jsxDevRuntime },\n frontmatter,\n ...scope,\n };\n const keys = Object.keys(fullScope);\n const values = Object.values(fullScope);\n const fn = Reflect.construct(Function, keys.concat(`${compiledSource}`));\n return fn.apply(fn, values).default;\n }, [compiledSource, scope, frontmatter]);\n\n if (!ready) {\n return React.createElement(\"div\", {\n dangerouslySetInnerHTML: { __html: \"\" },\n suppressHydrationWarning: true,\n });\n }\n\n const content = React.createElement(\n mdx.MDXProvider,\n { components },\n React.createElement(Content, null)\n );\n\n return lazy ? React.createElement(\"div\", null, content) : content;\n}\n","import { serialize } from \"./mdx-compiler/serialize.js\";\nimport type { Node } from \"unist\";\nimport { visit } from \"unist-util-visit\";\nimport remarkGfm from \"remark-gfm\";\nimport rehypePrism from \"rehype-prism-plus\";\nimport rehypeAutolinkHeadings from \"rehype-autolink-headings\";\nimport rehypeSlug from \"rehype-slug\";\nimport rehypeCodeTitles from \"rehype-code-titles\";\nimport { handleCodeTitles } from \"./plugins/handleCodeTitles\";\nimport { handleCodeExpandableRemark, handleCodeExpandable } from \"./plugins/handleCodeExpandable\";\nimport { rehypeMermaid } from \"./plugins/rehypeMermaid\";\nimport { remarkDirectiveToMdx } from \"./plugins/remarkDirectiveToMdx\";\nimport remarkDirective from \"remark-directive\";\nimport type { ElementNode } from \"./utils\";\nimport type { Pluggable } from \"unified\";\n\n// Re-export serialize for non-RSC usage\nexport { serialize };\n\n// Re-export MDXRemote for client-side hydration\nexport { MDXRemote } from \"./mdx-compiler/index.js\";\n\ninterface TextNode extends Node {\n type: \"text\";\n value: string;\n}\n\nexport const preProcess = () => (tree: Node) => {\n visit(tree, (node: Node) => {\n const element = node as ElementNode;\n if (element?.type === \"element\" && element?.tagName === \"pre\" && element.children) {\n const [codeEl] = element.children as ElementNode[];\n if (codeEl.tagName !== \"code\" || !codeEl.children?.[0]) return;\n\n const className = codeEl.properties?.className;\n const classList = Array.isArray(className)\n ? className\n : typeof className === \"string\"\n ? className.split(\" \").filter(Boolean)\n : [];\n const languageClass = classList.find((item: string) => item.startsWith(\"language-\"));\n if (languageClass) {\n element.language = languageClass.replace(\"language-\", \"\").split(\":\")[0];\n }\n\n const textNode = codeEl.children[0] as TextNode;\n if (textNode.type === \"text\" && textNode.value) {\n element.raw = textNode.value;\n }\n }\n });\n\n return tree;\n};\n\nexport const postProcess = () => (tree: Node) => {\n visit(tree, \"element\", (node: Node) => {\n const element = node as ElementNode;\n if (element?.type === \"element\" && element?.tagName === \"pre\") {\n if (element.properties && element.raw) {\n element.properties.raw = element.raw;\n }\n if (element.properties && element.language && !element.properties[\"data-language\"]) {\n element.properties[\"data-language\"] = element.language;\n }\n if (element.properties && element.codeTitle && !element.properties[\"data-title\"]) {\n element.properties[\"data-title\"] = element.codeTitle;\n }\n }\n });\n\n return tree;\n};\n\nexport function createDefaultRehypePlugins(): Pluggable[] {\n return [\n preProcess,\n rehypeMermaid, // Transform ```mermaid before code transforms\n rehypeCodeTitles,\n handleCodeTitles,\n handleCodeExpandable, // Copy expandable metadata from <code> to <pre> before prism transforms nodes.\n rehypePrism,\n handleCodeExpandable, // Re-apply expandable attrs after prism tokenization.\n rehypeSlug,\n rehypeAutolinkHeadings,\n postProcess,\n ];\n}\n\nexport function createDefaultRemarkPlugins(): Pluggable[] {\n return [remarkGfm, handleCodeExpandableRemark, remarkDirective, remarkDirectiveToMdx];\n}\n","import type { Node } from \"unist\";\nimport { visit } from \"unist-util-visit\";\nimport type { TocItem } from \"../types\";\nimport type { ElementNode } from \"../utils\";\n\nfunction headingText(node: Node): string {\n const element = node as ElementNode;\n if (element.properties?.ariaHidden === true || element.properties?.ariaHidden === \"true\") {\n return \"\";\n }\n if (node.type === \"text\") return (node as Node & { value: string }).value;\n return element.children?.map(headingText).join(\"\") ?? \"\";\n}\n\n/** Collect final heading IDs, after slugging and user rehype transforms. */\nexport function rehypeCollectTocs(tocs: TocItem[]) {\n return (tree: Node) => {\n tocs.length = 0;\n visit(tree, \"element\", (node: ElementNode) => {\n if (!/^h[2-4]$/.test(node.tagName ?? \"\") || typeof node.properties?.id !== \"string\") return;\n tocs.push({\n level: Number(node.tagName!.slice(1)),\n text: headingText(node),\n href: `#${node.properties.id}`,\n });\n });\n };\n}\n","import matter from \"@11ty/gray-matter\";\nimport type { ZodType } from \"zod\";\nimport type { TocItem } from \"./types\";\nimport { compileSync } from \"@mdx-js/mdx\";\nimport { createDefaultRemarkPlugins } from \"./compile\";\nimport rehypeSlug from \"rehype-slug\";\nimport { rehypeCollectTocs } from \"./plugins/rehypeCollectTocs\";\n\nexport function sluggify(text: string): string {\n const normalized = text.normalize(\"NFD\").replace(/[\\u0300-\\u036f]/g, \"\"); // Remove accents\n const slug = normalized.toLowerCase().replace(/\\s+/g, \"-\");\n return slug.replace(/[^a-z0-9-]/g, \"\");\n}\n\nexport function extractTocsFromRawMdx(rawMdx: string): TocItem[] {\n const tocs: TocItem[] = [];\n compileSync(matter(rawMdx).content, {\n format: \"md\",\n remarkPlugins: createDefaultRemarkPlugins(),\n rehypePlugins: [rehypeSlug, [rehypeCollectTocs, tocs]],\n });\n return tocs;\n}\n\nexport function extractFrontmatter<Frontmatter>(content: string): Frontmatter {\n try {\n return matter(content).data as Frontmatter;\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n throw new Error(`Failed to extract frontmatter: ${reason}`, { cause: error });\n }\n}\n\n/**\n * Extract frontmatter and return both the parsed data and the content\n * with the frontmatter block stripped. Avoids a second parse during\n * compilation.\n *\n * Optionally validates the parsed frontmatter with a Zod schema.\n * YAML coerces unquoted values (e.g. `date: 2026-06-10` → Date, `3.5` → number),\n * so use `z.coerce.*` for fields that must remain strings.\n */\nexport function extractFrontmatterWithContent<Frontmatter>(content: string): {\n frontmatter: Frontmatter;\n strippedContent: string;\n};\nexport function extractFrontmatterWithContent<Frontmatter>(\n content: string,\n schema: ZodType<Frontmatter>\n): { frontmatter: Frontmatter; strippedContent: string };\nexport function extractFrontmatterWithContent<Frontmatter>(\n content: string,\n schema?: ZodType<Frontmatter>\n): { frontmatter: Frontmatter; strippedContent: string } {\n try {\n const { data, content: strippedContent } = matter(content);\n return {\n frontmatter: schema ? schema.parse(data) : (data as Frontmatter),\n strippedContent,\n };\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n throw new Error(`Failed to extract frontmatter: ${reason}`, { cause: error });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AASA,IAAa,WAA0B,MAAe;CACpD,IAAM,IAAgD,CAAC;CAEvD,EAAM,GAAM,YAAY,GAAmB,GAAsB,MAA0B;EAMzF,IALI,CAAC,KAAU,MAAU,QAAQ,EAAK,YAAY,SAK9C,CADe,EAAK,YAAY,WAAW,SAAS,mBAAmB,GAEzE;EAGF,IAAI,IAAkC;EACtC,KAAK,IAAI,IAAI,IAAQ,GAAG,IAAI,EAAO,SAAS,QAAQ,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,GACA,GACuD;CACvD,IAAI;EACF,IAAM,EAAE,SAAM,SAAS,MAAoB,EAAO,CAAO;EACzD,OAAO;GACL,aAAa,IAAS,EAAO,MAAM,CAAI,IAAK;GAC5C;EACF;CACF,SAAS,GAAO;EACd,IAAM,IAAS,aAAiB,QAAQ,EAAM,UAAU,OAAO,CAAK;EACpE,MAAU,MAAM,kCAAkC,KAAU,EAAE,OAAO,EAAM,CAAC;CAC9E;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/plugins/handleCodeTitles.ts","../src/plugins/handleCodeExpandable.ts","../src/plugins/rehypeMermaid.ts","../src/plugins/remarkDirectiveToMdx.ts","../src/mdx-compiler/index.ts","../src/compile.ts","../src/plugins/rehypeCollectTocs.ts","../src/extract.ts"],"sourcesContent":["import type { Node, Parent } from \"unist\";\nimport { visit } from \"unist-util-visit\";\nimport type { ElementNode } from \"../utils\";\n\ninterface TextNode extends Node {\n type: \"text\";\n value: string;\n}\n\nexport const handleCodeTitles = () => (tree: Node) => {\n const toRemove: { parent: Parent; index: number }[] = [];\n\n visit(tree, \"element\", (node: ElementNode, index: number | null, parent: Parent | null) => {\n if (!parent || index === null || node.tagName !== \"div\") {\n return;\n }\n\n const isTitleDiv = node.properties?.className?.includes(\"rehype-code-title\");\n if (!isTitleDiv) {\n return;\n }\n\n let nextElement: ElementNode | null = null;\n for (let i = index + 1; i < parent.children.length; i++) {\n const sibling = parent.children[i];\n if (sibling.type === \"element\") {\n nextElement = sibling as ElementNode;\n break;\n }\n }\n\n if (nextElement?.tagName === \"pre\") {\n const titleNode = node.children?.[0] as TextNode;\n if (titleNode?.type === \"text\") {\n if (!nextElement.properties) {\n nextElement.properties = {};\n }\n nextElement.properties[\"data-title\"] = titleNode.value;\n nextElement.codeTitle = titleNode.value;\n toRemove.push({ parent, index });\n }\n }\n });\n\n // Remove title divs in reverse order to preserve indices\n for (let i = toRemove.length - 1; i >= 0; i--) {\n const { parent, index } = toRemove[i];\n parent.children.splice(index, 1);\n }\n};\n","import type { Node } from \"unist\";\nimport { visit } from \"unist-util-visit\";\nimport type { ElementNode } from \"../utils\";\n\n/**\n * Escape metadata values that are interpolated into MDX-compiled JavaScript.\n *\n * References:\n * - HTML spec (script data state): escape `</` as `\\u003C/` to prevent premature\n * `</script>` closing when the compiled JS is embedded as JSON in a <script> tag.\n * - Bun.escapeHTML(): escapes `< > \" ' &` for HTML context; for JS/JSON context\n * we use `\\uXXXX` JSON Unicode escapes instead so the value survives round-trip\n * through JSON.parse on the client side.\n * - React: JSX auto-escapes attribute values via `{expression}`, so values set\n * as HAST properties (data-language, data-title) are HTML-safe at render time.\n */\nfunction escapeMeta(s: string): string {\n let out = \"\";\n for (let i = 0; i < s.length; i++) {\n const ch = s[i];\n\n // HTML spec: prevent </script> in script/JSON context\n if (ch === \"<\" && s[i + 1] === \"/\") {\n out += \"\\\\u003C/\";\n i++;\n continue;\n }\n\n // JS string: escape template literal & string special chars\n if (ch === \"`\" || ch === \"$\" || ch === \"{\" || ch === \"}\" || ch === '\"' || ch === \"\\\\\") {\n out += `\\\\${ch}`;\n continue;\n }\n\n out += ch;\n }\n return out;\n}\n\ninterface CodeNode extends Node {\n type: \"code\";\n lang?: string;\n meta?: string;\n value: string;\n data?: {\n meta?: string;\n hProperties?: Record<string, unknown>;\n };\n}\n\nfunction countCodeLines(raw: string): number {\n let normalized = raw.replace(/\\r\\n/g, \"\\n\");\n if (normalized.startsWith(\"\\n\")) normalized = normalized.slice(1);\n if (normalized.endsWith(\"\\n\")) normalized = normalized.slice(0, -1);\n\n if (normalized.length === 0) return 0;\n return normalized.split(\"\\n\").length;\n}\n\nexport const handleCodeExpandableRemark = () => (tree: Node) => {\n visit(tree, \"code\", (node: CodeNode) => {\n if (!node.meta) return;\n\n const isExpandable = node.meta.includes(\"Expandable\");\n const [languagePart, titlePart] = (node.lang ?? \"\").split(\":\");\n const normalizedLanguage = languagePart?.trim();\n const normalizedTitle = titlePart?.trim();\n\n if (!isExpandable) return;\n\n const lineCount = countCodeLines(node.value);\n\n if (!node.data) {\n node.data = {};\n }\n if (!node.data.hProperties) {\n node.data.hProperties = {};\n }\n\n node.data.hProperties[\"data-expandable\"] = \"true\";\n node.data.hProperties[\"data-expandable-lines\"] = lineCount.toString();\n\n if (normalizedLanguage) {\n node.data.hProperties[\"data-language\"] = normalizedLanguage;\n }\n if (normalizedTitle) {\n node.data.hProperties[\"data-title\"] = normalizedTitle;\n }\n\n const currentClassName = node.data.hProperties.className;\n const classList = Array.isArray(currentClassName)\n ? currentClassName\n : typeof currentClassName === \"string\"\n ? currentClassName.split(\" \").filter(Boolean)\n : [];\n\n if (!classList.includes(\"mdx-expandable-meta\")) {\n classList.push(\"mdx-expandable-meta\");\n }\n\n node.data.hProperties.className = classList;\n\n if (normalizedLanguage && !node.meta.includes(\"dbLang(\")) {\n node.meta = `${node.meta} dbLang(${escapeMeta(normalizedLanguage)})`.trim();\n }\n if (normalizedTitle && !node.meta.includes(\"dbTitle(\")) {\n node.meta = `${node.meta} dbTitle(${escapeMeta(normalizedTitle)})`.trim();\n }\n });\n};\n\nexport const handleCodeExpandable = () => (tree: Node) => {\n visit(tree, \"element\", (node: ElementNode) => {\n if (node.tagName !== \"pre\") return;\n\n const codeElement = node.children?.find((child) => {\n const element = child as ElementNode;\n return element.type === \"element\" && element.tagName === \"code\";\n }) as ElementNode | undefined;\n\n const codeClassName = codeElement?.properties?.className;\n const codeClassList = Array.isArray(codeClassName)\n ? codeClassName\n : typeof codeClassName === \"string\"\n ? codeClassName.split(\" \").filter(Boolean)\n : [];\n\n const codeMeta =\n codeElement?.data &&\n typeof codeElement.data === \"object\" &&\n typeof codeElement.data[\"meta\"] === \"string\"\n ? (codeElement.data[\"meta\"] as string)\n : undefined;\n\n const languageFromMeta = codeMeta?.match(/dbLang\\(([^)]+)\\)/)?.[1];\n const titleFromMeta = codeMeta?.match(/dbTitle\\(([^)]+)\\)/)?.[1];\n\n const languageFromProps =\n typeof codeElement?.properties?.[\"data-language\"] === \"string\"\n ? (codeElement.properties[\"data-language\"] as string)\n : undefined;\n const titleFromProps =\n typeof codeElement?.properties?.[\"data-title\"] === \"string\"\n ? (codeElement.properties[\"data-title\"] as string)\n : undefined;\n\n const languageFromCodeClass = codeClassList\n .find((item) => item.startsWith(\"language-\"))\n ?.replace(\"language-\", \"\");\n\n const existingPreLanguage =\n typeof node.properties?.[\"data-language\"] === \"string\"\n ? (node.properties[\"data-language\"] as string)\n : undefined;\n const existingPreTitle =\n typeof node.properties?.[\"data-title\"] === \"string\"\n ? (node.properties[\"data-title\"] as string)\n : undefined;\n\n const isExpandable =\n codeElement?.properties?.[\"data-expandable\"] === \"true\" ||\n codeClassList.includes(\"mdx-expandable-meta\") ||\n codeMeta?.includes(\"Expandable\") === true;\n\n const expandableLines = codeElement?.properties?.[\"data-expandable-lines\"];\n if (!isExpandable) return;\n\n if (!node.properties) {\n node.properties = {};\n }\n\n node.properties[\"data-expandable\"] = \"true\";\n if (typeof expandableLines === \"string\" || typeof expandableLines === \"number\") {\n node.properties[\"data-expandable-lines\"] = expandableLines.toString();\n } else if (node.raw) {\n node.properties[\"data-expandable-lines\"] = countCodeLines(node.raw).toString();\n }\n\n const resolvedLanguage =\n languageFromProps ||\n languageFromMeta ||\n languageFromCodeClass ||\n existingPreLanguage ||\n node.language;\n const resolvedTitle = titleFromProps || titleFromMeta || existingPreTitle || node.codeTitle;\n\n if (resolvedLanguage) {\n node.properties[\"data-language\"] = resolvedLanguage;\n }\n if (resolvedTitle) {\n node.properties[\"data-title\"] = resolvedTitle;\n }\n\n const className = node.properties.className;\n if (!className) {\n node.properties.className = [];\n }\n\n if (Array.isArray(node.properties.className)) {\n if (!node.properties.className.includes(\"mdx-expandable-code\")) {\n node.properties.className.push(\"mdx-expandable-code\");\n }\n } else if (typeof className === \"string\") {\n const hasMarker = className.split(\" \").includes(\"mdx-expandable-code\");\n if (!hasMarker) {\n node.properties.className = `${className} mdx-expandable-code`.trim().split(\" \");\n }\n } else {\n node.properties.className = [\"mdx-expandable-code\"];\n }\n\n if (codeElement?.properties) {\n const cleanedCodeClassList = codeClassList.filter((item) => item !== \"mdx-expandable-meta\");\n codeElement.properties.className = cleanedCodeClassList;\n }\n });\n};\n","import type { Node, Parent } from \"unist\";\nimport { visit } from \"unist-util-visit\";\nimport type { ElementNode } from \"../utils\";\n\ninterface TextNode extends Node {\n type: \"text\";\n value: string;\n}\n\n/**\n * Rehype plugin that transforms `<pre><code class=\"language-mermaid\">` fenced\n * blocks into `<Mermaid chart=\"...\">` elements.\n *\n * This allows Mermaid diagram definitions to be authored via standard fenced\n * code blocks (````mermaid) which avoids JSX parsing collisions with\n * Mermaid's `{...}` (decision nodes) and `[...]` (label nodes) syntax.\n */\nexport const rehypeMermaid = () => (tree: Node) => {\n visit(tree, \"element\", (node: ElementNode, index: number | null, parent: Parent | null) => {\n if (!parent || index === null || node.tagName !== \"pre\") return;\n\n const codeEl = node.children?.find(\n (child) =>\n (child as ElementNode).type === \"element\" && (child as ElementNode).tagName === \"code\"\n ) as ElementNode | undefined;\n\n if (!codeEl) return;\n\n const classList = Array.isArray(codeEl.properties?.className)\n ? (codeEl.properties.className as string[])\n : typeof codeEl.properties?.className === \"string\"\n ? (codeEl.properties.className as string).split(\" \").filter(Boolean)\n : [];\n\n if (!classList.includes(\"language-mermaid\")) return;\n\n const textNode = codeEl.children?.find((child) => (child as TextNode).type === \"text\") as\n TextNode | undefined;\n\n const chart = textNode?.value ?? \"\";\n\n parent.children[index] = {\n type: \"element\",\n tagName: \"Mermaid\",\n properties: { chart },\n children: [],\n } as unknown as ElementNode;\n });\n};\n","import type { Node } from \"unist\";\nimport type { VFile } from \"vfile\";\n\n/**\n * Remark plugin: convert markdown directives into MDX component elements.\n *\n * Contract (docubook):\n * - `:::name{attrs} … :::` — container: EVERY component that holds content\n * (tabs, tab, accordions, accordion, steps, step, cards, card, files,\n * folder, note + variants). Children are the block between the opening\n * `:::` and closing `:::` — bounded by micromark's container grammar, so\n * a component can never trap siblings that follow it.\n * - `::name{attrs}` — self-closing leaf (no children): file, youtube,\n * mermaid.\n * - `:tooltip[label]{tip=\"…\"}` — the ONE inline (single-colon) directive.\n * Every other text directive is rebuilt as literal text\n * (`localhost:3000` stays intact). `::tooltip` (block leaf) is removed\n * in v2 — tooltips are inline only.\n *\n * Names are PascalCased to match the components map (`file-tree` → `FileTree`).\n * Bare attributes (`{horizontal}`) become boolean props (JSX bare attribute).\n * Callout variants (`:::tip`, `:::info`, …) map to their own registry entries\n * (`Tip`/`Info`/…) which wrap the `Callout` component with the type set.\n */\nexport function remarkDirectiveToMdx() {\n return (tree: Node, file: VFile) => {\n const source = String(file);\n const root = tree as unknown as { children: Node[] };\n root.children = root.children.map((node) => transform(node, source));\n return tree;\n };\n}\n\n/** Leaves that never hold children (self-closing). */\nconst PURE_LEAVES = new Set([\"youtube\"]);\n\ntype DirectiveNode = Node & {\n type: \"containerDirective\" | \"leafDirective\" | \"textDirective\";\n name: string;\n attributes?: Record<string, string>;\n children?: Node[];\n};\n\nfunction isDirective(node: Node): node is DirectiveNode {\n return (\n node.type === \"containerDirective\" ||\n node.type === \"leafDirective\" ||\n node.type === \"textDirective\"\n );\n}\n\nfunction transform(node: Node, source: string): Node {\n if (!isDirective(node)) {\n const children = (node as unknown as { children?: Node[] }).children;\n if (Array.isArray(children)) {\n (node as unknown as { children: Node[] }).children = children.map((child) =>\n transform(child, source)\n );\n }\n return node;\n }\n if (node.type === \"textDirective\") {\n // `:tooltip[label]{tip=\"…\"}` is the one inline component — it stays\n // inside the paragraph. Every other single-colon text directive is\n // rebuilt as literal text (`localhost:3000` stays intact).\n if (node.name === \"tooltip\") {\n return inlineTooltip(node);\n }\n return literalDirective(node, source);\n }\n // Block-form tooltips are gone in v2 — degrade to literal text so the\n // author sees the directive instead of a broken component.\n if (node.type === \"leafDirective\" && node.name === \"tooltip\") {\n return literalDirective(node, source);\n }\n // containerDirective → component with children; leafDirective → self-closing.\n const children =\n node.type === \"containerDirective\" && !PURE_LEAVES.has(node.name)\n ? (node.children ?? []).map((child) => transform(child, source))\n : [];\n return directiveToElement(node, children);\n}\n\nfunction directiveToElement(directive: DirectiveNode, children: Node[]): Node {\n const name = pascalCase(directive.name);\n const attributes = Object.entries(directive.attributes ?? {}).map(([attrName, value]) => ({\n type: \"mdxJsxAttribute\",\n name: attrName,\n value: value === \"\" ? null : value,\n }));\n return {\n type: \"mdxJsxFlowElement\",\n name,\n attributes,\n children,\n } as Node;\n}\n\n/** Preserve authored syntax: parsed children and attributes lose formatting. */\nfunction literalDirective(directive: DirectiveNode, source: string): Node {\n const start = directive.position?.start.offset;\n const end = directive.position?.end.offset;\n // Synthetic nodes without source offsets cannot be restored losslessly.\n if (start === undefined || end === undefined) return directive;\n return { type: \"text\", value: source.slice(start, end) } as Node;\n}\n\n/**\n * Inline tooltip from a text directive: `:tooltip[label]{tip=\"…\"}`.\n * The label is the visible trigger (dotted underline); `tip` is the hover\n * bubble and defaults to the label, so `:tooltip[text]` alone already shows\n * a bubble. Emits an inline element so it stays inside the paragraph. The\n * bubble auto-positions (no `side` prop).\n */\nfunction inlineTooltip(directive: DirectiveNode): Node {\n const label = (directive.children ?? [])\n .map((child) => (child as { value?: string }).value ?? \"\")\n .join(\"\");\n const attrs = directive.attributes ?? {};\n const attributes = [\n { type: \"mdxJsxAttribute\", name: \"text\", value: attrs.text || label || \"?\" },\n { type: \"mdxJsxAttribute\", name: \"tip\", value: attrs.tip || label || \"\" },\n ];\n return { type: \"mdxJsxTextElement\", name: \"Tooltip\", attributes, children: [] } as Node;\n}\n\nfunction pascalCase(name: string): string {\n return name\n .split(\"-\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\"\");\n}\n","// MPL-2.0 — derived from next-mdx-remote (IBM). See LICENSE-MPL-2.0.\nimport React, { useEffect, useState, useMemo } from \"react\";\nimport * as jsxRuntime from \"react/jsx-runtime\";\nimport * as jsxDevRuntime from \"react/jsx-dev-runtime\";\nimport * as mdx from \"@mdx-js/react\";\nimport type { MDXRemoteSerializeResult } from \"./types.js\";\n\n/** Props for the client-side `<MDXRemote>` (accepts pre-serialized result). */\nexport type MDXRemoteProps = MDXRemoteSerializeResult & {\n components?: Record<string, React.ComponentType<any>>;\n /** Defer hydration to an idle callback */\n lazy?: boolean;\n};\n\n/**\n * Client-side MDX renderer.\n *\n * Accepts a pre-compiled result from `serialize()` and renders it via\n * `MDXProvider` for custom component injection.\n */\nexport function MDXRemote({\n compiledSource,\n frontmatter,\n scope = {},\n components = {},\n lazy,\n}: MDXRemoteProps): React.ReactElement {\n const [ready, setReady] = useState(!lazy || typeof window === \"undefined\");\n\n useEffect(() => {\n if (!lazy) return;\n const id = window.requestIdleCallback\n ? window.requestIdleCallback(() => setReady(true), { timeout: 500 })\n : setTimeout(() => setReady(true), 1);\n return () => {\n if (window.cancelIdleCallback) window.cancelIdleCallback(id as number);\n else clearTimeout(id as number);\n };\n }, [lazy]);\n\n const Content = useMemo(() => {\n // Non-RSC mode: compiled MDX expects `useMDXComponents` (\n // from @mdx-js/react) AND the JSX runtime.\n // In React 19, jsx/jsxs and jsxDEV live in separate modules,\n // so merge both to handle compiled output from any mode.\n const fullScope = {\n opts: { ...mdx, ...jsxRuntime, ...jsxDevRuntime },\n frontmatter,\n ...scope,\n };\n const keys = Object.keys(fullScope);\n const values = Object.values(fullScope);\n const fn = Reflect.construct(Function, keys.concat(`${compiledSource}`));\n return fn.apply(fn, values).default;\n }, [compiledSource, scope, frontmatter]);\n\n if (!ready) {\n return React.createElement(\"div\", {\n dangerouslySetInnerHTML: { __html: \"\" },\n suppressHydrationWarning: true,\n });\n }\n\n const content = React.createElement(\n mdx.MDXProvider,\n { components },\n React.createElement(Content, null)\n );\n\n return lazy ? React.createElement(\"div\", null, content) : content;\n}\n","import { serialize } from \"./mdx-compiler/serialize.js\";\nimport type { Node } from \"unist\";\nimport { visit } from \"unist-util-visit\";\nimport remarkGfm from \"remark-gfm\";\nimport rehypePrism from \"rehype-prism-plus\";\nimport rehypeAutolinkHeadings from \"rehype-autolink-headings\";\nimport rehypeSlug from \"rehype-slug\";\nimport rehypeCodeTitles from \"rehype-code-titles\";\nimport { handleCodeTitles } from \"./plugins/handleCodeTitles\";\nimport { handleCodeExpandableRemark, handleCodeExpandable } from \"./plugins/handleCodeExpandable\";\nimport { rehypeMermaid } from \"./plugins/rehypeMermaid\";\nimport { remarkDirectiveToMdx } from \"./plugins/remarkDirectiveToMdx\";\nimport remarkDirective from \"remark-directive\";\nimport type { ElementNode } from \"./utils\";\nimport type { Pluggable } from \"unified\";\n\n// Re-export serialize for non-RSC usage\nexport { serialize };\n\n// Re-export MDXRemote for client-side hydration\nexport { MDXRemote } from \"./mdx-compiler/index.js\";\n\ninterface TextNode extends Node {\n type: \"text\";\n value: string;\n}\n\nexport const preProcess = () => (tree: Node) => {\n visit(tree, (node: Node) => {\n const element = node as ElementNode;\n if (element?.type === \"element\" && element?.tagName === \"pre\" && element.children) {\n const [codeEl] = element.children as ElementNode[];\n if (codeEl.tagName !== \"code\" || !codeEl.children?.[0]) return;\n\n const className = codeEl.properties?.className;\n const classList = Array.isArray(className)\n ? className\n : typeof className === \"string\"\n ? className.split(\" \").filter(Boolean)\n : [];\n const languageClass = classList.find((item: string) => item.startsWith(\"language-\"));\n if (languageClass) {\n element.language = languageClass.replace(\"language-\", \"\").split(\":\")[0];\n }\n\n const textNode = codeEl.children[0] as TextNode;\n if (textNode.type === \"text\" && textNode.value) {\n element.raw = textNode.value;\n }\n }\n });\n\n return tree;\n};\n\nexport const postProcess = () => (tree: Node) => {\n visit(tree, \"element\", (node: Node) => {\n const element = node as ElementNode;\n if (element?.type === \"element\" && element?.tagName === \"pre\") {\n if (element.properties && element.raw) {\n element.properties.raw = element.raw;\n }\n if (element.properties && element.language && !element.properties[\"data-language\"]) {\n element.properties[\"data-language\"] = element.language;\n }\n if (element.properties && element.codeTitle && !element.properties[\"data-title\"]) {\n element.properties[\"data-title\"] = element.codeTitle;\n }\n }\n });\n\n return tree;\n};\n\nexport function createDefaultRehypePlugins(): Pluggable[] {\n return [\n preProcess,\n rehypeMermaid, // Transform ```mermaid before code transforms\n rehypeCodeTitles,\n handleCodeTitles,\n handleCodeExpandable, // Copy expandable metadata from <code> to <pre> before prism transforms nodes.\n // ignoreMissing: a fence language refractor does not know (e.g. `env`, `mdx`)\n // must render as plain code, not abort the whole build.\n [rehypePrism, { ignoreMissing: true }],\n handleCodeExpandable, // Re-apply expandable attrs after prism tokenization.\n rehypeSlug,\n rehypeAutolinkHeadings,\n postProcess,\n ];\n}\n\nexport function createDefaultRemarkPlugins(): Pluggable[] {\n return [remarkGfm, handleCodeExpandableRemark, remarkDirective, remarkDirectiveToMdx];\n}\n","import type { Node } from \"unist\";\nimport { visit } from \"unist-util-visit\";\nimport type { TocItem } from \"../types\";\nimport type { ElementNode } from \"../utils\";\n\nfunction headingText(node: Node): string {\n const element = node as ElementNode;\n if (element.properties?.ariaHidden === true || element.properties?.ariaHidden === \"true\") {\n return \"\";\n }\n if (node.type === \"text\") return (node as Node & { value: string }).value;\n return element.children?.map(headingText).join(\"\") ?? \"\";\n}\n\n/** Collect final heading IDs, after slugging and user rehype transforms. */\nexport function rehypeCollectTocs(tocs: TocItem[]) {\n return (tree: Node) => {\n tocs.length = 0;\n visit(tree, \"element\", (node: ElementNode) => {\n if (!/^h[2-4]$/.test(node.tagName ?? \"\") || typeof node.properties?.id !== \"string\") return;\n tocs.push({\n level: Number(node.tagName!.slice(1)),\n text: headingText(node),\n href: `#${node.properties.id}`,\n });\n });\n };\n}\n","import matter from \"@11ty/gray-matter\";\nimport type { ZodType } from \"zod\";\nimport type { TocItem } from \"./types\";\nimport { compileSync } from \"@mdx-js/mdx\";\nimport { createDefaultRemarkPlugins } from \"./compile\";\nimport rehypeSlug from \"rehype-slug\";\nimport { rehypeCollectTocs } from \"./plugins/rehypeCollectTocs\";\n\nexport function sluggify(text: string): string {\n const normalized = text.normalize(\"NFD\").replace(/[\\u0300-\\u036f]/g, \"\"); // Remove accents\n const slug = normalized.toLowerCase().replace(/\\s+/g, \"-\");\n return slug.replace(/[^a-z0-9-]/g, \"\");\n}\n\nexport function extractTocsFromRawMdx(rawMdx: string): TocItem[] {\n const tocs: TocItem[] = [];\n compileSync(matter(rawMdx).content, {\n format: \"md\",\n remarkPlugins: createDefaultRemarkPlugins(),\n rehypePlugins: [rehypeSlug, [rehypeCollectTocs, tocs]],\n });\n return tocs;\n}\n\nexport function extractFrontmatter<Frontmatter>(content: string): Frontmatter {\n try {\n return matter(content).data as Frontmatter;\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n throw new Error(`Failed to extract frontmatter: ${reason}`, { cause: error });\n }\n}\n\n/**\n * Extract frontmatter and return both the parsed data and the content\n * with the frontmatter block stripped. Avoids a second parse during\n * compilation.\n *\n * Optionally validates the parsed frontmatter with a Zod schema.\n * YAML coerces unquoted values (e.g. `date: 2026-06-10` → Date, `3.5` → number),\n * so use `z.coerce.*` for fields that must remain strings.\n */\nexport function extractFrontmatterWithContent<Frontmatter>(content: string): {\n frontmatter: Frontmatter;\n strippedContent: string;\n};\nexport function extractFrontmatterWithContent<Frontmatter>(\n content: string,\n schema: ZodType<Frontmatter>\n): { frontmatter: Frontmatter; strippedContent: string };\nexport function extractFrontmatterWithContent<Frontmatter>(\n content: string,\n schema?: ZodType<Frontmatter>\n): { frontmatter: Frontmatter; strippedContent: string } {\n try {\n const { data, content: strippedContent } = matter(content);\n return {\n frontmatter: schema ? schema.parse(data) : (data as Frontmatter),\n strippedContent,\n };\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n throw new Error(`Failed to extract frontmatter: ${reason}`, { cause: error });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AASA,IAAa,WAA0B,MAAe;CACpD,IAAM,IAAgD,CAAC;CAEvD,EAAM,GAAM,YAAY,GAAmB,GAAsB,MAA0B;EAMzF,IALI,CAAC,KAAU,MAAU,QAAQ,EAAK,YAAY,SAK9C,CADe,EAAK,YAAY,WAAW,SAAS,mBAAmB,GA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aAAiB,QAAQ,EAAM,UAAU,OAAO,CAAK;EACpE,MAAU,MAAM,kCAAkC,KAAU,EAAE,OAAO,EAAM,CAAC;CAC9E;AACF;AAmBA,SAAgB,EACd,GACA,GACuD;CACvD,IAAI;EACF,IAAM,EAAE,SAAM,SAAS,MAAoB,EAAO,CAAO;EACzD,OAAO;GACL,aAAa,IAAS,EAAO,MAAM,CAAI,IAAK;GAC5C;EACF;CACF,SAAS,GAAO;EACd,IAAM,IAAS,aAAiB,QAAQ,EAAM,UAAU,OAAO,CAAK;EACpE,MAAU,MAAM,kCAAkC,KAAU,EAAE,OAAO,EAAM,CAAC;CAC9E;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docubook/core",
3
- "version": "2.0.3",
3
+ "version": "2.1.2",
4
4
  "description": "Shared MDX compile pipeline and markdown utilities for DocuBook",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",