@temelj/mdx 0.14.0 → 0.15.0
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/README.md +468 -82
- package/dist/character-entities.d.mts +4 -0
- package/dist/character-entities.d.mts.map +1 -0
- package/dist/character-entities.mjs +2132 -0
- package/dist/character-entities.mjs.map +1 -0
- package/dist/character-reference.d.mts +6 -0
- package/dist/character-reference.d.mts.map +1 -0
- package/dist/character-reference.mjs +18 -0
- package/dist/character-reference.mjs.map +1 -0
- package/dist/compile-analysis.d.mts +28 -0
- package/dist/compile-analysis.d.mts.map +1 -0
- package/dist/compile-analysis.mjs +74 -0
- package/dist/compile-analysis.mjs.map +1 -0
- package/dist/compile-emit.d.mts +9 -0
- package/dist/compile-emit.d.mts.map +1 -0
- package/dist/compile-emit.mjs +187 -0
- package/dist/compile-emit.mjs.map +1 -0
- package/dist/compile-esm.d.mts +34 -0
- package/dist/compile-esm.d.mts.map +1 -0
- package/dist/compile-esm.mjs +187 -0
- package/dist/compile-esm.mjs.map +1 -0
- package/dist/compile-names.d.mts +13 -0
- package/dist/compile-names.d.mts.map +1 -0
- package/dist/compile-names.mjs +32 -0
- package/dist/compile-names.mjs.map +1 -0
- package/dist/compiler.d.mts +69 -85
- package/dist/compiler.d.mts.map +1 -1
- package/dist/compiler.mjs +185 -418
- package/dist/compiler.mjs.map +1 -1
- package/dist/diagnostics.d.mts +37 -0
- package/dist/diagnostics.d.mts.map +1 -0
- package/dist/diagnostics.mjs +57 -0
- package/dist/diagnostics.mjs.map +1 -0
- package/dist/errors.d.mts +157 -0
- package/dist/errors.d.mts.map +1 -0
- package/dist/errors.mjs +263 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/footnote-numbering.d.mts +27 -0
- package/dist/footnote-numbering.d.mts.map +1 -0
- package/dist/footnote-numbering.mjs +49 -0
- package/dist/footnote-numbering.mjs.map +1 -0
- package/dist/format-context.d.mts +46 -0
- package/dist/format-context.d.mts.map +1 -0
- package/dist/format-context.mjs +26 -0
- package/dist/format-context.mjs.map +1 -0
- package/dist/format-directive.d.mts +9 -0
- package/dist/format-directive.d.mts.map +1 -0
- package/dist/format-directive.mjs +99 -0
- package/dist/format-directive.mjs.map +1 -0
- package/dist/format-jsx.d.mts +8 -0
- package/dist/format-jsx.d.mts.map +1 -0
- package/dist/format-jsx.mjs +47 -0
- package/dist/format-jsx.mjs.map +1 -0
- package/dist/format-math.d.mts +9 -0
- package/dist/format-math.d.mts.map +1 -0
- package/dist/format-math.mjs +79 -0
- package/dist/format-math.mjs.map +1 -0
- package/dist/format-safe.d.mts +25 -0
- package/dist/format-safe.d.mts.map +1 -0
- package/dist/format-safe.mjs +366 -0
- package/dist/format-safe.mjs.map +1 -0
- package/dist/format-table.d.mts +8 -0
- package/dist/format-table.d.mts.map +1 -0
- package/dist/format-table.mjs +55 -0
- package/dist/format-table.mjs.map +1 -0
- package/dist/format-track.d.mts +18 -0
- package/dist/format-track.d.mts.map +1 -0
- package/dist/format-track.mjs +34 -0
- package/dist/format-track.mjs.map +1 -0
- package/dist/format.d.mts +7 -0
- package/dist/format.d.mts.map +1 -0
- package/dist/format.mjs +549 -0
- package/dist/format.mjs.map +1 -0
- package/dist/frontmatter.d.mts +15 -0
- package/dist/frontmatter.d.mts.map +1 -0
- package/dist/frontmatter.mjs +187 -0
- package/dist/frontmatter.mjs.map +1 -0
- package/dist/heading.d.mts +6 -0
- package/dist/heading.d.mts.map +1 -0
- package/dist/heading.mjs +19 -0
- package/dist/heading.mjs.map +1 -0
- package/dist/html-format.d.mts +32 -0
- package/dist/html-format.d.mts.map +1 -0
- package/dist/html-format.mjs +127 -0
- package/dist/html-format.mjs.map +1 -0
- package/dist/html-lower.d.mts +78 -0
- package/dist/html-lower.d.mts.map +1 -0
- package/dist/html-lower.mjs +583 -0
- package/dist/html-lower.mjs.map +1 -0
- package/dist/html-stream.d.mts +13 -0
- package/dist/html-stream.d.mts.map +1 -0
- package/dist/html-stream.mjs +32 -0
- package/dist/html-stream.mjs.map +1 -0
- package/dist/html.d.mts +120 -0
- package/dist/html.d.mts.map +1 -0
- package/dist/html.mjs +77 -0
- package/dist/html.mjs.map +1 -0
- package/dist/identifier.d.mts +4 -0
- package/dist/identifier.d.mts.map +1 -0
- package/dist/identifier.mjs +8 -0
- package/dist/identifier.mjs.map +1 -0
- package/dist/javascript-ast.d.mts +16 -0
- package/dist/javascript-ast.d.mts.map +1 -0
- package/dist/javascript-ast.mjs +39 -0
- package/dist/javascript-ast.mjs.map +1 -0
- package/dist/javascript-jsx.d.mts +24 -0
- package/dist/javascript-jsx.d.mts.map +1 -0
- package/dist/javascript-jsx.mjs +189 -0
- package/dist/javascript-jsx.mjs.map +1 -0
- package/dist/javascript.d.mts +9 -0
- package/dist/javascript.d.mts.map +1 -0
- package/dist/javascript.mjs +31 -0
- package/dist/javascript.mjs.map +1 -0
- package/dist/jsx-reference.d.mts +15 -0
- package/dist/jsx-reference.d.mts.map +1 -0
- package/dist/jsx-reference.mjs +31 -0
- package/dist/jsx-reference.mjs.map +1 -0
- package/dist/mod.d.mts +25 -9
- package/dist/mod.mjs +19 -8
- package/dist/model.d.mts +196 -0
- package/dist/model.d.mts.map +1 -0
- package/dist/model.mjs +113 -0
- package/dist/model.mjs.map +1 -0
- package/dist/parser/block-container-recognizers.d.mts +40 -0
- package/dist/parser/block-container-recognizers.d.mts.map +1 -0
- package/dist/parser/block-container-recognizers.mjs +90 -0
- package/dist/parser/block-container-recognizers.mjs.map +1 -0
- package/dist/parser/block-directive-recognizers.d.mts +22 -0
- package/dist/parser/block-directive-recognizers.d.mts.map +1 -0
- package/dist/parser/block-directive-recognizers.mjs +77 -0
- package/dist/parser/block-directive-recognizers.mjs.map +1 -0
- package/dist/parser/block-leaf-recognizers.d.mts +53 -0
- package/dist/parser/block-leaf-recognizers.d.mts.map +1 -0
- package/dist/parser/block-leaf-recognizers.mjs +386 -0
- package/dist/parser/block-leaf-recognizers.mjs.map +1 -0
- package/dist/parser/block-parser.d.mts +38 -0
- package/dist/parser/block-parser.d.mts.map +1 -0
- package/dist/parser/block-parser.mjs +895 -0
- package/dist/parser/block-parser.mjs.map +1 -0
- package/dist/parser/block-syntax.d.mts +240 -0
- package/dist/parser/block-syntax.d.mts.map +1 -0
- package/dist/parser/characters.d.mts +19 -0
- package/dist/parser/characters.d.mts.map +1 -0
- package/dist/parser/characters.mjs +52 -0
- package/dist/parser/characters.mjs.map +1 -0
- package/dist/parser/config.d.mts +16 -0
- package/dist/parser/config.d.mts.map +1 -0
- package/dist/parser/config.mjs +25 -0
- package/dist/parser/config.mjs.map +1 -0
- package/dist/parser/directive-attributes.d.mts +9 -0
- package/dist/parser/directive-attributes.d.mts.map +1 -0
- package/dist/parser/directive-attributes.mjs +24 -0
- package/dist/parser/directive-attributes.mjs.map +1 -0
- package/dist/parser/embedded-scanner.d.mts +18 -0
- package/dist/parser/embedded-scanner.d.mts.map +1 -0
- package/dist/parser/embedded-scanner.mjs +199 -0
- package/dist/parser/embedded-scanner.mjs.map +1 -0
- package/dist/parser/inline-autolink.d.mts +7 -0
- package/dist/parser/inline-autolink.d.mts.map +1 -0
- package/dist/parser/inline-autolink.mjs +42 -0
- package/dist/parser/inline-autolink.mjs.map +1 -0
- package/dist/parser/inline-character-reference.d.mts +7 -0
- package/dist/parser/inline-character-reference.d.mts.map +1 -0
- package/dist/parser/inline-character-reference.mjs +22 -0
- package/dist/parser/inline-character-reference.mjs.map +1 -0
- package/dist/parser/inline-code.d.mts +7 -0
- package/dist/parser/inline-code.d.mts.map +1 -0
- package/dist/parser/inline-code.mjs +29 -0
- package/dist/parser/inline-code.mjs.map +1 -0
- package/dist/parser/inline-directive.d.mts +9 -0
- package/dist/parser/inline-directive.d.mts.map +1 -0
- package/dist/parser/inline-directive.mjs +45 -0
- package/dist/parser/inline-directive.mjs.map +1 -0
- package/dist/parser/inline-embedded.d.mts +19 -0
- package/dist/parser/inline-embedded.d.mts.map +1 -0
- package/dist/parser/inline-embedded.mjs +92 -0
- package/dist/parser/inline-embedded.mjs.map +1 -0
- package/dist/parser/inline-emphasis.d.mts +11 -0
- package/dist/parser/inline-emphasis.d.mts.map +1 -0
- package/dist/parser/inline-emphasis.mjs +79 -0
- package/dist/parser/inline-emphasis.mjs.map +1 -0
- package/dist/parser/inline-input.d.mts +46 -0
- package/dist/parser/inline-input.d.mts.map +1 -0
- package/dist/parser/inline-input.mjs +137 -0
- package/dist/parser/inline-input.mjs.map +1 -0
- package/dist/parser/inline-link.d.mts +12 -0
- package/dist/parser/inline-link.d.mts.map +1 -0
- package/dist/parser/inline-link.mjs +187 -0
- package/dist/parser/inline-link.mjs.map +1 -0
- package/dist/parser/inline-math.d.mts +10 -0
- package/dist/parser/inline-math.d.mts.map +1 -0
- package/dist/parser/inline-math.mjs +46 -0
- package/dist/parser/inline-math.mjs.map +1 -0
- package/dist/parser/inline-output.d.mts +34 -0
- package/dist/parser/inline-output.d.mts.map +1 -0
- package/dist/parser/inline-output.mjs +62 -0
- package/dist/parser/inline-output.mjs.map +1 -0
- package/dist/parser/inline-parser.d.mts +14 -0
- package/dist/parser/inline-parser.d.mts.map +1 -0
- package/dist/parser/inline-parser.mjs +328 -0
- package/dist/parser/inline-parser.mjs.map +1 -0
- package/dist/parser/inline-pending.d.mts +23 -0
- package/dist/parser/inline-pending.d.mts.map +1 -0
- package/dist/parser/inline-pending.mjs +100 -0
- package/dist/parser/inline-pending.mjs.map +1 -0
- package/dist/parser/inline-syntax.d.mts +118 -0
- package/dist/parser/inline-syntax.d.mts.map +1 -0
- package/dist/parser/inline-syntax.mjs +1 -0
- package/dist/parser/javascript-boundary.d.mts +16 -0
- package/dist/parser/javascript-boundary.d.mts.map +1 -0
- package/dist/parser/javascript-boundary.mjs +42 -0
- package/dist/parser/javascript-boundary.mjs.map +1 -0
- package/dist/parser/javascript-scanner.d.mts +22 -0
- package/dist/parser/javascript-scanner.d.mts.map +1 -0
- package/dist/parser/javascript-scanner.mjs +122 -0
- package/dist/parser/javascript-scanner.mjs.map +1 -0
- package/dist/parser/materialize-cache.d.mts +34 -0
- package/dist/parser/materialize-cache.d.mts.map +1 -0
- package/dist/parser/materialize-cache.mjs +12 -0
- package/dist/parser/materialize-cache.mjs.map +1 -0
- package/dist/parser/materialize-jsx.d.mts +14 -0
- package/dist/parser/materialize-jsx.d.mts.map +1 -0
- package/dist/parser/materialize-jsx.mjs +76 -0
- package/dist/parser/materialize-jsx.mjs.map +1 -0
- package/dist/parser/materialize.d.mts +61 -0
- package/dist/parser/materialize.d.mts.map +1 -0
- package/dist/parser/materialize.mjs +736 -0
- package/dist/parser/materialize.mjs.map +1 -0
- package/dist/parser/recognizer.d.mts +20 -0
- package/dist/parser/recognizer.d.mts.map +1 -0
- package/dist/parser/recognizer.mjs +24 -0
- package/dist/parser/recognizer.mjs.map +1 -0
- package/dist/parser/session.d.mts +42 -0
- package/dist/parser/session.d.mts.map +1 -0
- package/dist/parser/session.mjs +89 -0
- package/dist/parser/session.mjs.map +1 -0
- package/dist/parser.d.mts +25 -0
- package/dist/parser.d.mts.map +1 -0
- package/dist/parser.mjs +37 -0
- package/dist/parser.mjs.map +1 -0
- package/dist/plugin-internal.d.mts +25 -0
- package/dist/plugin-internal.d.mts.map +1 -0
- package/dist/plugin-internal.mjs +99 -0
- package/dist/plugin-internal.mjs.map +1 -0
- package/dist/plugin.d.mts +37 -0
- package/dist/plugin.d.mts.map +1 -0
- package/dist/plugin.mjs +1 -0
- package/dist/plugins/code-block-metadata.d.mts +42 -0
- package/dist/plugins/code-block-metadata.d.mts.map +1 -0
- package/dist/plugins/code-block-metadata.mjs +133 -0
- package/dist/plugins/code-block-metadata.mjs.map +1 -0
- package/dist/plugins/heading-id.d.mts +15 -0
- package/dist/plugins/heading-id.d.mts.map +1 -0
- package/dist/plugins/heading-id.mjs +45 -0
- package/dist/plugins/heading-id.mjs.map +1 -0
- package/dist/plugins/lower-heading.d.mts +16 -0
- package/dist/plugins/lower-heading.d.mts.map +1 -0
- package/dist/plugins/lower-heading.mjs +28 -0
- package/dist/plugins/lower-heading.mjs.map +1 -0
- package/dist/plugins/math-render.d.mts +26 -0
- package/dist/plugins/math-render.d.mts.map +1 -0
- package/dist/plugins/math-render.mjs +51 -0
- package/dist/plugins/math-render.mjs.map +1 -0
- package/dist/plugins/mod.d.mts +9 -6
- package/dist/plugins/mod.mjs +8 -6
- package/dist/plugins/remove-esm.d.mts +10 -0
- package/dist/plugins/remove-esm.d.mts.map +1 -0
- package/dist/plugins/remove-esm.mjs +12 -0
- package/dist/plugins/remove-esm.mjs.map +1 -0
- package/dist/plugins/shiki.d.mts +21 -0
- package/dist/plugins/shiki.d.mts.map +1 -0
- package/dist/plugins/shiki.mjs +144 -0
- package/dist/plugins/shiki.mjs.map +1 -0
- package/dist/plugins/syntax-highlight.d.mts +38 -0
- package/dist/plugins/syntax-highlight.d.mts.map +1 -0
- package/dist/plugins/syntax-highlight.mjs +106 -0
- package/dist/plugins/syntax-highlight.mjs.map +1 -0
- package/dist/processor.d.mts +60 -0
- package/dist/processor.d.mts.map +1 -0
- package/dist/processor.mjs +106 -0
- package/dist/processor.mjs.map +1 -0
- package/dist/ranges.d.mts +10 -0
- package/dist/ranges.d.mts.map +1 -0
- package/dist/ranges.mjs +22 -0
- package/dist/ranges.mjs.map +1 -0
- package/dist/source-map.d.mts +28 -0
- package/dist/source-map.d.mts.map +1 -0
- package/dist/source-map.mjs +90 -0
- package/dist/source-map.mjs.map +1 -0
- package/dist/source-text.d.mts +35 -0
- package/dist/source-text.d.mts.map +1 -0
- package/dist/source-text.mjs +132 -0
- package/dist/source-text.mjs.map +1 -0
- package/dist/source.d.mts +86 -0
- package/dist/source.d.mts.map +1 -0
- package/dist/source.mjs +264 -0
- package/dist/source.mjs.map +1 -0
- package/dist/stream-events.d.mts +59 -0
- package/dist/stream-events.d.mts.map +1 -0
- package/dist/stream-events.mjs +115 -0
- package/dist/stream-events.mjs.map +1 -0
- package/dist/stream-session.d.mts +79 -0
- package/dist/stream-session.d.mts.map +1 -0
- package/dist/stream-session.mjs +904 -0
- package/dist/stream-session.mjs.map +1 -0
- package/dist/stream-tail.d.mts +84 -0
- package/dist/stream-tail.d.mts.map +1 -0
- package/dist/stream-tail.mjs +359 -0
- package/dist/stream-tail.mjs.map +1 -0
- package/dist/stream-types.d.mts +89 -0
- package/dist/stream-types.d.mts.map +1 -0
- package/dist/stream-types.mjs +1 -0
- package/dist/stream.d.mts +28 -0
- package/dist/stream.d.mts.map +1 -0
- package/dist/stream.mjs +68 -0
- package/dist/stream.mjs.map +1 -0
- package/dist/syntax-options.d.mts +21 -0
- package/dist/syntax-options.d.mts.map +1 -0
- package/dist/syntax-options.mjs +26 -0
- package/dist/syntax-options.mjs.map +1 -0
- package/dist/traversal.d.mts +25 -0
- package/dist/traversal.d.mts.map +1 -0
- package/dist/traversal.mjs +136 -0
- package/dist/traversal.mjs.map +1 -0
- package/dist/tree.d.mts +18 -0
- package/dist/tree.d.mts.map +1 -0
- package/dist/tree.mjs +43 -0
- package/dist/tree.mjs.map +1 -0
- package/dist/unified/adapter.d.mts +24 -0
- package/dist/unified/adapter.d.mts.map +1 -0
- package/dist/unified/adapter.mjs +44 -0
- package/dist/unified/adapter.mjs.map +1 -0
- package/dist/unified/mod.d.mts +2 -0
- package/dist/unified/mod.mjs +1 -0
- package/dist/unified/runtime.d.mts +10 -0
- package/dist/unified/runtime.d.mts.map +1 -0
- package/dist/unified/runtime.mjs +115 -0
- package/dist/unified/runtime.mjs.map +1 -0
- package/dist/unified/tree-bridge.d.mts +63 -0
- package/dist/unified/tree-bridge.d.mts.map +1 -0
- package/dist/unified/tree-bridge.mjs +876 -0
- package/dist/unified/tree-bridge.mjs.map +1 -0
- package/dist/uri.d.mts +5 -0
- package/dist/uri.d.mts.map +1 -0
- package/dist/uri.mjs +32 -0
- package/dist/uri.mjs.map +1 -0
- package/package.json +56 -30
- package/dist/plugins/heading-id/plugin.d.mts +0 -17
- package/dist/plugins/heading-id/plugin.d.mts.map +0 -1
- package/dist/plugins/heading-id/plugin.mjs +0 -23
- package/dist/plugins/heading-id/plugin.mjs.map +0 -1
- package/dist/plugins/katex/plugin.d.mts +0 -39
- package/dist/plugins/katex/plugin.d.mts.map +0 -1
- package/dist/plugins/katex/plugin.mjs +0 -107
- package/dist/plugins/katex/plugin.mjs.map +0 -1
- package/dist/plugins/remove-imports-exports.d.mts +0 -10
- package/dist/plugins/remove-imports-exports.d.mts.map +0 -1
- package/dist/plugins/remove-imports-exports.mjs +0 -15
- package/dist/plugins/remove-imports-exports.mjs.map +0 -1
- package/dist/plugins/syntax-highlight/code-meta.d.mts +0 -22
- package/dist/plugins/syntax-highlight/code-meta.d.mts.map +0 -1
- package/dist/plugins/syntax-highlight/code-meta.mjs +0 -38
- package/dist/plugins/syntax-highlight/code-meta.mjs.map +0 -1
- package/dist/plugins/syntax-highlight/plugin.d.mts +0 -57
- package/dist/plugins/syntax-highlight/plugin.d.mts.map +0 -1
- package/dist/plugins/syntax-highlight/plugin.mjs +0 -93
- package/dist/plugins/syntax-highlight/plugin.mjs.map +0 -1
- package/dist/plugins/tree-processor/plugin.d.mts +0 -19
- package/dist/plugins/tree-processor/plugin.d.mts.map +0 -1
- package/dist/plugins/tree-processor/plugin.mjs +0 -21
- package/dist/plugins/tree-processor/plugin.mjs.map +0 -1
- package/dist/types.d.mts +0 -2
- /package/dist/{types.mjs → parser/block-syntax.mjs} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-bridge.mjs","names":["exhaustive"],"sources":["../../src/unified/tree-bridge.ts"],"sourcesContent":["import { isNumber, isBoolean, isString, isPlainObject } from \"@temelj/value\";\nimport { find, html, svg, type Schema } from \"property-information\";\n\nimport type { HtmlAttributeValue, HtmlAttributes, HtmlNode, HtmlRootNode } from \"../html.ts\";\nimport type {\n ContainerDirectiveNode,\n DirectiveAttribute,\n DirectiveLabelNode,\n DocumentNode,\n FlowContent,\n JsxAttribute,\n JsxAttributeLike,\n JsxFlowElementNode,\n JsxTextElementNode,\n LeafDirectiveNode,\n ListItemNode,\n MdxNode,\n PhrasingContent,\n ReferenceKind,\n TableAlignment,\n TableCellNode,\n TableRowNode,\n TextDirectiveNode,\n} from \"../model.ts\";\nimport type { SourceRange } from \"../ranges.ts\";\nimport type { SourceFile } from \"../source.ts\";\n\nimport { isHeadingDepth, type HeadingDepth } from \"../heading.ts\";\nimport { htmlChildren, htmlFallback, htmlText } from \"../html.ts\";\nimport { normalizeIdentifier } from \"../identifier.ts\";\nimport { isFlowContent, isPhrasingContent } from \"../model.ts\";\n\ninterface UnistRecord {\n readonly type: string;\n readonly align?: unknown;\n readonly alt?: unknown;\n readonly attributes?: unknown;\n readonly checked?: unknown;\n children?: unknown;\n data?: unknown;\n readonly depth?: unknown;\n readonly identifier?: unknown;\n readonly label?: unknown;\n readonly lang?: unknown;\n readonly meta?: unknown;\n readonly name?: unknown;\n readonly ordered?: unknown;\n readonly position?: unknown;\n readonly properties?: unknown;\n readonly referenceType?: unknown;\n readonly spread?: unknown;\n readonly start?: unknown;\n readonly tagName?: unknown;\n readonly title?: unknown;\n readonly url?: unknown;\n readonly value?: unknown;\n}\n\ninterface UnistPosition {\n readonly start: ReturnType<SourceFile[\"location\"]>;\n readonly end: ReturnType<SourceFile[\"location\"]>;\n}\n\ninterface UnistOrigin {\n readonly position?: UnistPosition;\n}\n\nconst unifiedDataKeys = {\n directiveLabel: \"temeljDirectiveLabel\",\n htmlNode: \"temeljHtmlNode\",\n mathFormat: \"temeljMathFormat\",\n} as const;\n\nexport class UnifiedBoundaryError extends Error {\n public constructor(message: string) {\n super(message);\n this.name = \"UnifiedBoundaryError\";\n }\n}\n\nexport class UnifiedTreeBridge {\n private readonly file: SourceFile;\n public readonly visiting = new WeakSet<object>();\n /** Semantic HTML nodes sent to rehype. HAST data refers to them by index. */\n readonly #owned: HtmlNode[] = [];\n\n public constructor(file: SourceFile) {\n this.file = file;\n }\n\n public toMdast(document: DocumentNode): UnistRecord {\n const node = this.mdxToUnist(document);\n\n if (node.type !== \"root\") {\n throw new UnifiedBoundaryError(\"The document bridge did not produce an mdast root\");\n }\n\n return node;\n }\n\n public fromMdast(root: unknown): DocumentNode {\n const node = this.unistToMdx(root);\n\n if (node.kind !== \"document\") {\n throw new UnifiedBoundaryError(\n `Remark returned a ${node.kind} node instead of an mdast root`,\n );\n }\n\n return node;\n }\n\n public toHast(document: HtmlRootNode): UnistRecord {\n const node = this.htmlToUnist(document);\n\n if (node.type !== \"root\") {\n throw new UnifiedBoundaryError(\"The HTML bridge did not produce a HAST root\");\n }\n\n return node;\n }\n\n public fromHast(root: unknown): HtmlRootNode {\n const node = this.unistToHtml(root, false);\n\n if (node.kind !== \"root\") {\n throw new UnifiedBoundaryError(`Rehype returned a ${node.kind} node instead of a HAST root`);\n }\n\n return node;\n }\n\n public mdxToUnist(node: MdxNode): UnistRecord {\n const base = this.positionBase(node.origin);\n\n const children = (): UnistRecord[] =>\n \"children\" in node ? node.children.map((child) => this.mdxToUnist(child)) : [];\n\n switch (node.kind) {\n case \"document\":\n return { type: \"root\", children: children(), ...base };\n case \"text\":\n return { type: \"text\", value: node.value, ...base };\n case \"emphasis\":\n return { type: \"emphasis\", children: children(), ...base };\n case \"strong\":\n return { type: \"strong\", children: children(), ...base };\n case \"delete\":\n return { type: \"delete\", children: children(), ...base };\n case \"inlineCode\":\n return { type: \"inlineCode\", value: node.value, ...base };\n case \"link\":\n return {\n type: \"link\",\n url: node.url,\n title: node.title ?? null,\n children: children(),\n ...base,\n };\n case \"image\":\n return { type: \"image\", url: node.url, alt: node.alt, title: node.title ?? null, ...base };\n case \"linkReference\":\n return {\n type: \"linkReference\",\n identifier: node.identifier,\n referenceType: node.referenceKind,\n children: children(),\n ...base,\n };\n case \"imageReference\":\n return {\n type: \"imageReference\",\n identifier: node.identifier,\n referenceType: node.referenceKind,\n alt: node.alt,\n ...base,\n };\n case \"hardBreak\":\n return { type: \"break\", ...base };\n case \"rawHtmlInline\":\n case \"rawHtmlBlock\":\n return { type: \"html\", value: node.value, ...base };\n case \"footnoteReference\":\n return {\n type: \"footnoteReference\",\n identifier: node.identifier,\n label: node.label,\n ...base,\n };\n case \"definition\":\n return {\n type: \"definition\",\n identifier: node.identifier,\n url: node.url,\n title: node.title ?? null,\n ...base,\n };\n case \"footnoteDefinition\":\n return {\n type: \"footnoteDefinition\",\n identifier: node.identifier,\n label: node.label,\n children: children(),\n ...base,\n };\n case \"frontmatter\":\n return { type: node.format, value: node.value, ...base };\n case \"inlineMath\":\n return {\n type: \"inlineMath\",\n value: node.value,\n data: { [unifiedDataKeys.mathFormat]: node.format },\n ...base,\n };\n case \"displayMath\":\n return {\n type: \"math\",\n value: node.value,\n meta: node.meta ?? null,\n data: { [unifiedDataKeys.mathFormat]: node.format },\n ...base,\n };\n case \"paragraph\":\n return { type: \"paragraph\", children: children(), ...base };\n case \"heading\":\n return { type: \"heading\", depth: node.depth, children: children(), ...base };\n case \"codeBlock\":\n return {\n type: \"code\",\n value: node.value,\n lang: node.language ?? null,\n meta: node.meta ?? null,\n ...base,\n };\n case \"thematicBreak\":\n return { type: \"thematicBreak\", ...base };\n case \"blockquote\":\n return { type: \"blockquote\", children: children(), ...base };\n case \"listItem\":\n return {\n type: \"listItem\",\n checked: node.checked ?? null,\n spread: node.spread,\n children: children(),\n ...base,\n };\n case \"list\":\n return {\n type: \"list\",\n ordered: node.ordered,\n start: node.ordered ? node.start : null,\n spread: node.spread,\n children: children(),\n ...base,\n };\n case \"tableCell\":\n return { type: \"tableCell\", children: children(), ...base };\n case \"tableRow\":\n return { type: \"tableRow\", children: children(), ...base };\n case \"table\":\n return {\n type: \"table\",\n align: node.alignments.map((value) => (value === \"none\" ? null : value)),\n children: children(),\n ...base,\n };\n case \"directiveLabel\":\n return { type: \"temeljDirectiveLabel\", children: children(), ...base };\n case \"textDirective\":\n return directiveToUnist(\"textDirective\", node, base, this);\n case \"leafDirective\":\n return directiveToUnist(\"leafDirective\", node, base, this);\n case \"containerDirective\": {\n const value = directiveToUnist(\"containerDirective\", node, base, this);\n value.children = children();\n\n if (node.label !== undefined) {\n value.data = { [unifiedDataKeys.directiveLabel]: this.mdxToUnist(node.label) };\n }\n\n return value;\n }\n\n case \"inlineExpression\":\n return { type: \"mdxTextExpression\", value: node.code, ...base };\n case \"blockExpression\":\n return { type: \"mdxFlowExpression\", value: node.code, ...base };\n case \"esm\":\n return { type: \"mdxjsEsm\", value: node.code, ...base };\n case \"jsxTextElement\":\n return jsxElementToUnist(\"mdxJsxTextElement\", node, base, this);\n case \"jsxFlowElement\":\n return jsxElementToUnist(\"mdxJsxFlowElement\", node, base, this);\n default: {\n const exhaustive: never = node;\n\n return exhaustive;\n }\n }\n }\n\n public unistToMdx(value: unknown, mode: \"flow\" | \"phrasing\" = \"flow\"): MdxNode {\n const node = this.nodeRecord(value);\n const origin = this.origin(node.position);\n\n const children = (childMode: \"flow\" | \"phrasing\" = \"flow\"): MdxNode[] =>\n this.nodeChildren(node).map((child) => this.unistToMdx(child, childMode));\n\n const phrasingChildren = (): PhrasingContent[] => phrasing(children(\"phrasing\"), node.type);\n const flowChildren = (): FlowContent[] => flow(children(), node.type);\n\n let result: MdxNode;\n\n switch (node.type) {\n case \"root\":\n result = { kind: \"document\", children: flowChildren(), origin };\n break;\n case \"text\":\n result = { kind: \"text\", value: stringField(node, \"value\"), origin };\n break;\n case \"emphasis\":\n case \"strong\":\n case \"delete\":\n result = { kind: node.type, children: phrasingChildren(), origin };\n break;\n case \"inlineCode\":\n result = { kind: \"inlineCode\", value: stringField(node, \"value\"), origin };\n break;\n case \"link\":\n result = {\n kind: \"link\",\n url: stringField(node, \"url\"),\n title: nullableString(node.title),\n children: phrasingChildren(),\n origin,\n };\n break;\n case \"image\":\n result = {\n kind: \"image\",\n url: stringField(node, \"url\"),\n alt: nullableString(node.alt) ?? \"\",\n title: nullableString(node.title),\n origin,\n };\n break;\n case \"linkReference\":\n result = {\n kind: \"linkReference\",\n identifier: normalizeIdentifier(stringField(node, \"identifier\")),\n referenceKind: referenceKind(node.referenceType),\n children: phrasingChildren(),\n origin,\n };\n break;\n case \"imageReference\":\n result = {\n kind: \"imageReference\",\n identifier: normalizeIdentifier(stringField(node, \"identifier\")),\n alt: nullableString(node.alt) ?? \"\",\n referenceKind: referenceKind(node.referenceType),\n origin,\n };\n break;\n case \"break\":\n result = { kind: \"hardBreak\", origin };\n break;\n case \"html\":\n result = {\n kind: mode === \"phrasing\" ? \"rawHtmlInline\" : \"rawHtmlBlock\",\n value: stringField(node, \"value\"),\n origin,\n };\n break;\n case \"footnoteReference\": {\n const identifier = stringField(node, \"identifier\");\n result = {\n kind: \"footnoteReference\",\n identifier: normalizeIdentifier(identifier),\n label: nullableString(node.label) ?? identifier,\n origin,\n };\n break;\n }\n\n case \"definition\":\n result = {\n kind: \"definition\",\n identifier: normalizeIdentifier(stringField(node, \"identifier\")),\n url: stringField(node, \"url\"),\n title: nullableString(node.title),\n origin,\n };\n break;\n case \"footnoteDefinition\": {\n const identifier = stringField(node, \"identifier\");\n result = {\n kind: \"footnoteDefinition\",\n identifier: normalizeIdentifier(identifier),\n label: nullableString(node.label) ?? identifier,\n children: flowChildren(),\n origin,\n };\n break;\n }\n\n case \"yaml\":\n case \"toml\":\n result = {\n kind: \"frontmatter\",\n format: node.type,\n value: stringField(node, \"value\"),\n origin,\n };\n break;\n case \"inlineMath\":\n result = {\n kind: \"inlineMath\",\n value: stringField(node, \"value\"),\n format: mathFormat(node),\n origin,\n };\n break;\n case \"math\": {\n const format = mathFormat(node);\n result = {\n kind: \"displayMath\",\n value: stringField(node, \"value\"),\n format,\n meta: format === \"dollar\" ? nullableString(node.meta) : undefined,\n origin,\n };\n break;\n }\n\n case \"paragraph\":\n result = { kind: \"paragraph\", children: phrasingChildren(), origin };\n break;\n case \"heading\":\n result = {\n kind: \"heading\",\n depth: headingDepth(node.depth),\n children: phrasingChildren(),\n origin,\n };\n break;\n case \"code\":\n result = {\n kind: \"codeBlock\",\n value: stringField(node, \"value\"),\n language: nullableString(node.lang),\n meta: nullableString(node.meta),\n origin,\n };\n break;\n case \"thematicBreak\":\n result = { kind: \"thematicBreak\", origin };\n break;\n case \"blockquote\":\n result = { kind: \"blockquote\", children: flowChildren(), origin };\n break;\n case \"listItem\":\n result = {\n kind: \"listItem\",\n checked: nullableBoolean(node.checked),\n spread: booleanField(node.spread, false),\n children: flowChildren(),\n origin,\n };\n break;\n case \"list\":\n result = {\n kind: \"list\",\n ordered: booleanField(node.ordered, false),\n start: nullableNumber(node.start) ?? 1,\n spread: booleanField(node.spread, false),\n children: listItems(children(), node.type),\n origin,\n };\n break;\n case \"tableCell\":\n result = { kind: \"tableCell\", children: phrasingChildren(), origin };\n break;\n case \"tableRow\":\n result = { kind: \"tableRow\", children: tableCells(children(), node.type), origin };\n break;\n case \"table\":\n result = {\n kind: \"table\",\n alignments: tableAlignments(node.align),\n children: tableRows(children(), node.type),\n origin,\n };\n break;\n case \"temeljDirectiveLabel\":\n result = { kind: \"directiveLabel\", children: phrasingChildren(), origin };\n break;\n case \"textDirective\":\n case \"leafDirective\":\n result = {\n kind: node.type,\n name: stringField(node, \"name\"),\n attributes: directiveAttributes(node.attributes),\n label: directiveLabel(children(\"phrasing\"), node.type),\n origin,\n };\n break;\n case \"containerDirective\":\n result = {\n kind: \"containerDirective\",\n name: stringField(node, \"name\"),\n attributes: directiveAttributes(node.attributes),\n label: directiveDataLabel(node.data, this),\n children: flowChildren(),\n origin,\n };\n break;\n case \"mdxTextExpression\":\n result = { kind: \"inlineExpression\", code: stringField(node, \"value\"), origin };\n break;\n case \"mdxFlowExpression\":\n result = { kind: \"blockExpression\", code: stringField(node, \"value\"), origin };\n break;\n case \"mdxjsEsm\":\n result = { kind: \"esm\", code: stringField(node, \"value\"), origin };\n break;\n case \"mdxJsxTextElement\":\n result = {\n kind: \"jsxTextElement\",\n name: nullableString(node.name),\n attributes: jsxAttributes(node.attributes, this),\n children: phrasingChildren(),\n origin,\n };\n break;\n case \"mdxJsxFlowElement\":\n result = {\n kind: \"jsxFlowElement\",\n name: nullableString(node.name),\n attributes: jsxAttributes(node.attributes, this),\n children: flowChildren(),\n origin,\n };\n break;\n default:\n throw new UnifiedBoundaryError(`Unsupported mdast node type: ${node.type}`);\n }\n\n this.visiting.delete(node);\n\n return result;\n }\n\n private htmlToUnist(node: HtmlNode): UnistRecord {\n const base = this.positionBase(node.origin);\n\n const children = (): UnistRecord[] =>\n htmlChildren(node).map((child) => this.htmlToUnist(child));\n\n switch (node.kind) {\n case \"root\":\n return { type: \"root\", children: children(), ...base };\n case \"text\":\n return { type: \"text\", value: node.value, ...base };\n case \"raw\":\n return { type: \"raw\", value: node.value, ...base };\n case \"comment\":\n return { type: \"comment\", value: node.value, ...base };\n case \"doctype\":\n return { type: \"doctype\", ...base };\n case \"element\":\n return {\n type: \"element\",\n tagName: node.tagName,\n properties: propertiesToHast(node.attributes, node.tagName === \"svg\" ? svg : html),\n children: children(),\n ...base,\n };\n case \"jsx\":\n case \"expression\":\n case \"pending\":\n case \"unresolvedReference\":\n // Rehype sees inert source text. The original node returns when the text is unchanged.\n return {\n type: \"text\",\n value: htmlText(node),\n data: { [unifiedDataKeys.htmlNode]: this.#owned.push(node) - 1 },\n ...base,\n };\n case \"codeBlock\":\n case \"math\":\n case \"footnoteReference\":\n case \"footnoteSection\":\n return {\n ...this.htmlToUnist({ ...htmlFallback(node), origin: node.origin }),\n data: { [unifiedDataKeys.htmlNode]: this.#owned.push(node) - 1 },\n };\n default: {\n const exhaustive: never = node;\n\n return exhaustive;\n }\n }\n }\n\n private unistToHtml(value: unknown, inSvg: boolean): HtmlNode {\n const node = this.nodeRecord(value);\n const origin = this.origin(node.position);\n let result: HtmlNode;\n\n switch (node.type) {\n case \"root\":\n result = {\n kind: \"root\",\n children: this.nodeChildren(node).map((child) => this.unistToHtml(child, inSvg)),\n origin,\n };\n break;\n case \"text\":\n result = { kind: \"text\", value: stringField(node, \"value\"), origin };\n break;\n case \"raw\":\n result = { kind: \"raw\", value: stringField(node, \"value\"), origin };\n break;\n case \"comment\":\n result = { kind: \"comment\", value: stringField(node, \"value\"), origin };\n break;\n case \"doctype\":\n result = { kind: \"doctype\", origin };\n break;\n case \"element\": {\n const tagName = stringField(node, \"tagName\");\n const svgElement = inSvg || tagName === \"svg\";\n const childSvg = svgElement && tagName !== \"foreignObject\";\n result = {\n kind: \"element\",\n tagName,\n attributes: propertiesFromHast(node.properties ?? {}, svgElement ? svg : html),\n children: this.nodeChildren(node).map((child) => this.unistToHtml(child, childSvg)),\n origin,\n };\n break;\n }\n\n default:\n throw new UnifiedBoundaryError(`Unsupported HAST node type: ${node.type}`);\n }\n\n this.visiting.delete(node);\n\n return this.restoredHtmlNode(node.data, result);\n }\n\n /** Restores a semantic node whose inert fallback came back from rehype unchanged. */\n private restoredHtmlNode(data: unknown, result: HtmlNode): HtmlNode {\n const index =\n isPlainObject(data) && unifiedDataKeys.htmlNode in data\n ? data[unifiedDataKeys.htmlNode]\n : undefined;\n\n const owned = isNumber(index) ? this.#owned.at(index) : undefined;\n\n if (owned === undefined) {\n return result;\n }\n\n const unchanged =\n owned.origin?.start === result.origin?.start &&\n owned.origin?.end === result.origin?.end &&\n htmlText(stripSemantic(owned)) === htmlText(result);\n\n return unchanged ? owned : result;\n }\n\n public nodeRecord(value: unknown): UnistRecord {\n if (!isUnistNode(value)) {\n throw new UnifiedBoundaryError(\"Unified returned a malformed node without a string type\");\n }\n\n if (this.visiting.has(value)) {\n throw new UnifiedBoundaryError(`Unified returned a cyclic ${value.type} tree`);\n }\n\n this.visiting.add(value);\n\n return value;\n }\n\n private nodeChildren(node: UnistRecord): unknown[] {\n if (!Array.isArray(node.children)) {\n throw new UnifiedBoundaryError(`${node.type} must have a children array`);\n }\n\n return node.children;\n }\n\n public positionBase(origin: SourceRange | undefined): UnistOrigin {\n return origin === undefined\n ? {}\n : {\n position: {\n start: this.file.location(origin.start),\n end: this.file.location(origin.end),\n },\n };\n }\n\n public origin(position: unknown): SourceRange | undefined {\n if (position === undefined) {\n return undefined;\n }\n\n if (\n !isPlainObject(position) ||\n !(\"start\" in position) ||\n !(\"end\" in position) ||\n !isPlainObject(position.start) ||\n !isPlainObject(position.end)\n ) {\n throw new UnifiedBoundaryError(\"A returned Unist position is malformed\");\n }\n\n const start = \"offset\" in position.start ? position.start.offset : undefined;\n const end = \"offset\" in position.end ? position.end.offset : undefined;\n\n if (\n !Number.isInteger(start) ||\n !Number.isInteger(end) ||\n !isNumber(start) ||\n !isNumber(end) ||\n start < 0 ||\n end < start ||\n end > this.file.length\n ) {\n throw new UnifiedBoundaryError(\"A returned Unist position has invalid UTF-16 offsets\");\n }\n\n return { start, end };\n }\n}\n\nfunction stripSemantic(node: HtmlNode): HtmlNode {\n return node.kind === \"codeBlock\" ||\n node.kind === \"math\" ||\n node.kind === \"footnoteReference\" ||\n node.kind === \"footnoteSection\"\n ? htmlFallback(node)\n : node;\n}\n\nfunction directiveToUnist(\n type: string,\n node: TextDirectiveNode | LeafDirectiveNode | ContainerDirectiveNode,\n base: UnistOrigin,\n bridge: UnifiedTreeBridge,\n): UnistRecord {\n return {\n type,\n name: node.name,\n attributes: Object.fromEntries(node.attributes.map((entry) => [entry.name, entry.value])),\n children:\n node.label === undefined ? [] : node.label.children.map((child) => bridge.mdxToUnist(child)),\n ...base,\n };\n}\n\nfunction jsxElementToUnist(\n type: string,\n node: JsxTextElementNode | JsxFlowElementNode,\n base: UnistOrigin,\n bridge: UnifiedTreeBridge,\n): UnistRecord {\n return {\n type,\n name: node.name ?? null,\n attributes: node.attributes.map((attribute) => jsxAttributeToUnist(attribute, bridge)),\n children: node.children.map((child) => bridge.mdxToUnist(child)),\n ...base,\n };\n}\n\nfunction jsxAttributeToUnist(node: JsxAttributeLike, bridge: UnifiedTreeBridge): UnistRecord {\n const base = bridge.positionBase(node.origin);\n\n if (node.kind === \"jsxSpreadAttribute\") {\n return { type: \"mdxJsxExpressionAttribute\", value: `...${node.code}`, ...base };\n }\n\n const value = jsxAttributeValueToUnist(node);\n\n return { type: \"mdxJsxAttribute\", name: node.name, value, ...base };\n}\n\nfunction jsxAttributeValueToUnist(node: JsxAttribute): string | UnistRecord | null {\n if (node.value === undefined) {\n return null;\n }\n\n return isString(node.value)\n ? node.value\n : { type: \"mdxJsxAttributeValueExpression\", value: node.value.code };\n}\n\nfunction propertiesToHast(\n attributes: HtmlAttributes,\n schema: Schema,\n): Record<string, HtmlAttributeValue> {\n const result: Record<string, HtmlAttributeValue> = Object.create(null);\n\n for (const [name, value] of Object.entries(attributes)) {\n result[find(schema, name).property] = value;\n }\n\n return result;\n}\n\nfunction propertiesFromHast(value: unknown, schema: Schema): HtmlAttributes {\n if (!isPlainObject(value)) {\n throw new UnifiedBoundaryError(\"HAST properties must be an object\");\n }\n\n const result: Record<string, HtmlAttributeValue> = Object.create(null);\n\n for (const [name, item] of Object.entries(value)) {\n if (item === null || item === undefined) {\n continue;\n }\n\n if (isBoolean(item) || isString(item) || (isNumber(item) && Number.isFinite(item))) {\n result[find(schema, name).attribute] = item;\n continue;\n }\n\n if (\n Array.isArray(item) &&\n item.every((entry) => isString(entry) || (isNumber(entry) && Number.isFinite(entry)))\n ) {\n result[find(schema, name).attribute] = [...item];\n continue;\n }\n\n throw new UnifiedBoundaryError(`Unsupported HAST property value for ${JSON.stringify(name)}`);\n }\n\n return result;\n}\n\nfunction stringField(node: UnistRecord, name: keyof UnistRecord): string {\n const value = node[name];\n\n if (!isString(value)) {\n throw new UnifiedBoundaryError(`${node.type}.${name} must be a string`);\n }\n\n return value;\n}\n\nfunction nullableString(value: unknown): string | undefined {\n if (value === null || value === undefined) {\n return undefined;\n }\n\n if (!isString(value)) {\n throw new UnifiedBoundaryError(\"Expected a string or null\");\n }\n\n return value;\n}\n\nfunction nullableBoolean(value: unknown): boolean | undefined {\n if (value === null || value === undefined) {\n return undefined;\n }\n\n if (!isBoolean(value)) {\n throw new UnifiedBoundaryError(\"Expected a boolean or null\");\n }\n\n return value;\n}\n\nfunction booleanField(value: unknown, fallback: boolean): boolean {\n return value === undefined || value === null ? fallback : (nullableBoolean(value) ?? fallback);\n}\n\nfunction nullableNumber(value: unknown): number | undefined {\n if (value === null || value === undefined) {\n return undefined;\n }\n\n if (!isNumber(value) || !Number.isSafeInteger(value)) {\n throw new UnifiedBoundaryError(\"Expected a safe integer or null\");\n }\n\n return value;\n}\n\nfunction headingDepth(value: unknown): HeadingDepth {\n if (isHeadingDepth(value)) {\n return value;\n }\n\n throw new UnifiedBoundaryError(\"heading.depth must be between 1 and 6\");\n}\n\nfunction referenceKind(value: unknown): ReferenceKind {\n if (value === \"full\" || value === \"collapsed\" || value === \"shortcut\") {\n return value;\n }\n\n throw new UnifiedBoundaryError(\"A reference has an invalid referenceType\");\n}\n\nfunction mathFormat(node: UnistRecord): \"dollar\" | \"tex\" {\n return isPlainObject(node.data) &&\n unifiedDataKeys.mathFormat in node.data &&\n node.data[unifiedDataKeys.mathFormat] === \"tex\"\n ? \"tex\"\n : \"dollar\";\n}\n\nfunction tableAlignments(value: unknown): TableAlignment[] {\n if (!Array.isArray(value)) {\n return [];\n }\n\n return value.map((item) =>\n item === null\n ? \"none\"\n : item === \"left\" || item === \"right\" || item === \"center\"\n ? item\n : (() => {\n throw new UnifiedBoundaryError(\"table.align contains an invalid value\");\n })(),\n );\n}\n\nfunction directiveAttributes(value: unknown): DirectiveAttribute[] {\n if (value === null || value === undefined) {\n return [];\n }\n\n if (!isPlainObject(value)) {\n throw new UnifiedBoundaryError(\"Directive attributes must be an object\");\n }\n\n return Object.entries(value).map(([name, item]) => ({\n name,\n value: nullableString(item) ?? \"\",\n }));\n}\n\nfunction directiveLabel(values: MdxNode[], type: string): DirectiveLabelNode | undefined {\n return values.length === 0\n ? undefined\n : { kind: \"directiveLabel\", children: phrasing(values, type) };\n}\n\nfunction directiveDataLabel(\n value: unknown,\n bridge: UnifiedTreeBridge,\n): DirectiveLabelNode | undefined {\n if (\n !isPlainObject(value) ||\n !(unifiedDataKeys.directiveLabel in value) ||\n value[unifiedDataKeys.directiveLabel] === undefined\n ) {\n return undefined;\n }\n\n const label = bridge.unistToMdx(value[unifiedDataKeys.directiveLabel]);\n\n if (label.kind !== \"directiveLabel\") {\n throw new UnifiedBoundaryError(\"Container directive label is malformed\");\n }\n\n return label;\n}\n\nfunction jsxAttributes(value: unknown, bridge: UnifiedTreeBridge): JsxAttributeLike[] {\n if (!Array.isArray(value)) {\n throw new UnifiedBoundaryError(\"MDX JSX attributes must be an array\");\n }\n\n return value.map((item) => {\n const node = bridge.nodeRecord(item);\n const origin = bridge.origin(node.position);\n bridge.visiting.delete(node);\n\n if (node.type === \"mdxJsxExpressionAttribute\") {\n return {\n kind: \"jsxSpreadAttribute\",\n code: stringField(node, \"value\").replace(/^\\s*\\.\\.\\./u, \"\"),\n origin,\n };\n }\n\n if (node.type !== \"mdxJsxAttribute\") {\n throw new UnifiedBoundaryError(`Unsupported MDX JSX attribute type: ${node.type}`);\n }\n\n const name = stringField(node, \"name\");\n\n if (node.value === null || node.value === undefined || isString(node.value)) {\n return { kind: \"jsxAttribute\", name, value: node.value ?? undefined, origin };\n }\n\n const expression = bridge.nodeRecord(node.value);\n\n if (expression.type !== \"mdxJsxAttributeValueExpression\") {\n throw new UnifiedBoundaryError(\"Unsupported MDX JSX attribute value\");\n }\n\n bridge.visiting.delete(expression);\n\n return {\n kind: \"jsxAttribute\",\n name,\n value: {\n kind: \"jsxAttributeValueExpression\",\n code: stringField(expression, \"value\"),\n origin: bridge.origin(expression.position),\n },\n origin,\n };\n });\n}\n\nfunction phrasing(values: MdxNode[], parent: string): PhrasingContent[] {\n if (!values.every(isPhrasingContent)) {\n throw new UnifiedBoundaryError(`${parent} contains non-phrasing content`);\n }\n\n return values;\n}\n\nfunction flow(values: MdxNode[], parent: string): FlowContent[] {\n if (!values.every(isFlowContent)) {\n throw new UnifiedBoundaryError(`${parent} contains non-flow content`);\n }\n\n return values;\n}\n\nfunction listItems(values: MdxNode[], parent: string): ListItemNode[] {\n if (!values.every((node): node is ListItemNode => node.kind === \"listItem\")) {\n throw new UnifiedBoundaryError(`${parent} contains a non-list-item child`);\n }\n\n return values;\n}\n\nfunction tableCells(values: MdxNode[], parent: string): TableCellNode[] {\n if (!values.every((node): node is TableCellNode => node.kind === \"tableCell\")) {\n throw new UnifiedBoundaryError(`${parent} contains a non-table-cell child`);\n }\n\n return values;\n}\n\nfunction tableRows(values: MdxNode[], parent: string): TableRowNode[] {\n if (!values.every((node): node is TableRowNode => node.kind === \"tableRow\")) {\n throw new UnifiedBoundaryError(`${parent} contains a non-table-row child`);\n }\n\n return values;\n}\n\nfunction isUnistNode(value: unknown): value is UnistRecord {\n return isPlainObject(value) && \"type\" in value && isString(value.type);\n}\n"],"mappings":";;;;;;;AAmEA,MAAM,kBAAkB;CACtB,gBAAgB;CAChB,UAAU;CACV,YAAY;AACd;AAEA,IAAa,uBAAb,cAA0C,MAAM;CAC9C,YAAmB,SAAiB;EAClC,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;AAEA,IAAa,oBAAb,MAA+B;CAC7B;CACA,2BAA2B,IAAI,QAAgB;;CAE/C,SAA8B,CAAC;CAE/B,YAAmB,MAAkB;EACnC,KAAK,OAAO;CACd;CAEA,QAAe,UAAqC;EAClD,MAAM,OAAO,KAAK,WAAW,QAAQ;EAErC,IAAI,KAAK,SAAS,QAChB,MAAM,IAAI,qBAAqB,mDAAmD;EAGpF,OAAO;CACT;CAEA,UAAiB,MAA6B;EAC5C,MAAM,OAAO,KAAK,WAAW,IAAI;EAEjC,IAAI,KAAK,SAAS,YAChB,MAAM,IAAI,qBACR,qBAAqB,KAAK,KAAK,+BACjC;EAGF,OAAO;CACT;CAEA,OAAc,UAAqC;EACjD,MAAM,OAAO,KAAK,YAAY,QAAQ;EAEtC,IAAI,KAAK,SAAS,QAChB,MAAM,IAAI,qBAAqB,6CAA6C;EAG9E,OAAO;CACT;CAEA,SAAgB,MAA6B;EAC3C,MAAM,OAAO,KAAK,YAAY,MAAM,KAAK;EAEzC,IAAI,KAAK,SAAS,QAChB,MAAM,IAAI,qBAAqB,qB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M,IAAI;AACvE"}
|
package/dist/uri.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uri.d.mts","names":[],"sources":["../src/uri.ts"],"mappings":";wBASgB,aAAa;wBA0Bb,sBAAsB"}
|
package/dist/uri.mjs
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import "./source.mjs";
|
|
2
|
+
//#region src/uri.ts
|
|
3
|
+
const PERCENT_ENCODED_BYTE = /^[0-9A-Fa-f]{2}$/u;
|
|
4
|
+
const LONE_SURROGATE = /^[\uD800-\uDFFF]$/u;
|
|
5
|
+
const URI_CHARACTERS = "!#$&'()*+,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~";
|
|
6
|
+
function normalizeUri(value) {
|
|
7
|
+
const result = [];
|
|
8
|
+
const characters = Array.from(value);
|
|
9
|
+
for (let index = 0; index < characters.length; index++) {
|
|
10
|
+
const c = characters[index];
|
|
11
|
+
const hexadecimal = `${characters[index + 1] ?? ""}${characters[index + 2] ?? ""}`;
|
|
12
|
+
if (c === "%" && PERCENT_ENCODED_BYTE.test(hexadecimal)) {
|
|
13
|
+
result.push(c, hexadecimal);
|
|
14
|
+
index += hexadecimal.length;
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (URI_CHARACTERS.includes(c)) {
|
|
18
|
+
result.push(c);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const scalar = LONE_SURROGATE.test(c) ? "�" : c;
|
|
22
|
+
result.push(encodeURIComponent(scalar));
|
|
23
|
+
}
|
|
24
|
+
return result.join("");
|
|
25
|
+
}
|
|
26
|
+
function isUrlControlCharacter(character) {
|
|
27
|
+
return character === "\0" || character <= " " || character === "";
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { isUrlControlCharacter, normalizeUri };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=uri.mjs.map
|
package/dist/uri.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uri.mjs","names":[],"sources":["../src/uri.ts"],"sourcesContent":["import { REPLACEMENT_CHARACTER } from \"./source.ts\";\n\nconst PERCENT_ENCODED_BYTE = /^[0-9A-Fa-f]{2}$/u;\n\nconst LONE_SURROGATE = /^[\\uD800-\\uDFFF]$/u;\n\nconst URI_CHARACTERS =\n \"!#$&'()*+,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~\";\n\nexport function normalizeUri(value: string): string {\n const result: string[] = [];\n const characters = Array.from(value);\n\n for (let index = 0; index < characters.length; index++) {\n const c = characters[index];\n const hexadecimal = `${characters[index + 1] ?? \"\"}${characters[index + 2] ?? \"\"}`;\n\n if (c === \"%\" && PERCENT_ENCODED_BYTE.test(hexadecimal)) {\n result.push(c, hexadecimal);\n index += hexadecimal.length;\n continue;\n }\n\n if (URI_CHARACTERS.includes(c)) {\n result.push(c);\n continue;\n }\n\n const scalar = LONE_SURROGATE.test(c) ? REPLACEMENT_CHARACTER : c;\n result.push(encodeURIComponent(scalar));\n }\n\n return result.join(\"\");\n}\n\nexport function isUrlControlCharacter(character: string): boolean {\n return character === \"\\0\" || character <= \" \" || character === \"\\u007F\";\n}\n"],"mappings":";;AAEA,MAAM,uBAAuB;AAE7B,MAAM,iBAAiB;AAEvB,MAAM,iBACJ;AAEF,SAAgB,aAAa,OAAuB;CAClD,MAAM,SAAmB,CAAC;CAC1B,MAAM,aAAa,MAAM,KAAK,KAAK;CAEnC,KAAK,IAAI,QAAQ,GAAG,QAAQ,WAAW,QAAQ,SAAS;EACtD,MAAM,IAAI,WAAW;EACrB,MAAM,cAAc,GAAG,WAAW,QAAQ,MAAM,KAAK,WAAW,QAAQ,MAAM;EAE9E,IAAI,MAAM,OAAO,qBAAqB,KAAK,WAAW,GAAG;GACvD,OAAO,KAAK,GAAG,WAAW;GAC1B,SAAS,YAAY;GACrB;EACF;EAEA,IAAI,eAAe,SAAS,CAAC,GAAG;GAC9B,OAAO,KAAK,CAAC;GACb;EACF;EAEA,MAAM,SAAS,eAAe,KAAK,CAAC,IAAA,MAA4B;EAChE,OAAO,KAAK,mBAAmB,MAAM,CAAC;CACxC;CAEA,OAAO,OAAO,KAAK,EAAE;AACvB;AAEA,SAAgB,sBAAsB,WAA4B;CAChE,OAAO,cAAc,QAAQ,aAAa,OAAO,cAAc;AACjE"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temelj/mdx",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "MDX
|
|
3
|
+
"version": "0.15.0",
|
|
4
|
+
"description": "MDX parsing, formatting, compilation, safe rendering, and streaming.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"markdown",
|
|
7
|
+
"mdx",
|
|
8
|
+
"rendering",
|
|
9
|
+
"streaming"
|
|
10
|
+
],
|
|
5
11
|
"license": "MIT",
|
|
6
12
|
"repository": {
|
|
7
13
|
"url": "https://github.com/tinrab/temelj"
|
|
@@ -10,50 +16,70 @@
|
|
|
10
16
|
"dist"
|
|
11
17
|
],
|
|
12
18
|
"type": "module",
|
|
19
|
+
"sideEffects": false,
|
|
13
20
|
"main": "./dist/mod.mjs",
|
|
14
21
|
"types": "./dist/mod.d.mts",
|
|
15
22
|
"exports": {
|
|
16
23
|
".": {
|
|
17
24
|
"types": "./dist/mod.d.mts",
|
|
18
25
|
"import": "./dist/mod.mjs"
|
|
26
|
+
},
|
|
27
|
+
"./plugins": {
|
|
28
|
+
"types": "./dist/plugins/mod.d.mts",
|
|
29
|
+
"import": "./dist/plugins/mod.mjs"
|
|
30
|
+
},
|
|
31
|
+
"./unified": {
|
|
32
|
+
"types": "./dist/unified/mod.d.mts",
|
|
33
|
+
"import": "./dist/unified/mod.mjs"
|
|
19
34
|
}
|
|
20
35
|
},
|
|
21
36
|
"dependencies": {
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
24
|
-
"@
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"hast-util-to-string": "^3.0.1",
|
|
30
|
-
"hast-util-to-text": "^4.0.2",
|
|
31
|
-
"katex": "^0.18.1",
|
|
32
|
-
"remark-frontmatter": "^5.0.0",
|
|
33
|
-
"remark-gfm": "^4.0.1",
|
|
34
|
-
"remark-math": "^6.0.0",
|
|
35
|
-
"remark-parse": "^11.0.0",
|
|
36
|
-
"shiki": "^4.3.1",
|
|
37
|
-
"unified": "^11.0.5",
|
|
38
|
-
"unist-util-remove": "^4.0.0",
|
|
39
|
-
"unist-util-visit": "^5.1.0",
|
|
40
|
-
"unist-util-visit-parents": "^6.0.2",
|
|
41
|
-
"vfile": "^6.0.3",
|
|
42
|
-
"vfile-matter": "^5.0.1",
|
|
43
|
-
"@temelj/iterator": "0.13.0",
|
|
44
|
-
"@temelj/standard-schema": "0.1.0"
|
|
37
|
+
"@temelj/standard-schema": "0.1.0",
|
|
38
|
+
"@temelj/string": "0.15.0",
|
|
39
|
+
"@temelj/value": "0.15.0",
|
|
40
|
+
"acorn": "8.19.0",
|
|
41
|
+
"acorn-jsx": "5.3.2",
|
|
42
|
+
"smol-toml": "1.9.1",
|
|
43
|
+
"yaml": "2.9.1"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
|
-
"@
|
|
48
|
-
"@types/node": "26.
|
|
46
|
+
"@shikijs/rehype": "4.5.0",
|
|
47
|
+
"@types/node": "26.6.5",
|
|
48
|
+
"property-information": "7.2.0",
|
|
49
|
+
"rehype-slug": "6.0.0",
|
|
50
|
+
"remark-toc": "9.0.0",
|
|
51
|
+
"shiki": "4.5.0",
|
|
49
52
|
"shx": "^0.4.0",
|
|
50
|
-
"tsdown": "^0.
|
|
53
|
+
"tsdown": "^0.23.1",
|
|
54
|
+
"tsx": "^4.23.15",
|
|
51
55
|
"typescript": "^7.0.2",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
56
|
+
"unified": "11.0.5",
|
|
57
|
+
"vfile": "6.0.3",
|
|
58
|
+
"vitest": "^5.0.4"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"property-information": "7.2.0",
|
|
62
|
+
"shiki": "4.5.0",
|
|
63
|
+
"unified": "11.0.5",
|
|
64
|
+
"vfile": "6.0.3"
|
|
65
|
+
},
|
|
66
|
+
"peerDependenciesMeta": {
|
|
67
|
+
"property-information": {
|
|
68
|
+
"optional": true
|
|
69
|
+
},
|
|
70
|
+
"shiki": {
|
|
71
|
+
"optional": true
|
|
72
|
+
},
|
|
73
|
+
"unified": {
|
|
74
|
+
"optional": true
|
|
75
|
+
},
|
|
76
|
+
"vfile": {
|
|
77
|
+
"optional": true
|
|
78
|
+
}
|
|
54
79
|
},
|
|
55
80
|
"scripts": {
|
|
56
81
|
"build": "tsdown",
|
|
82
|
+
"script:generate-entities": "node --import tsx/esm ./scripts/generate-character-entities.ts",
|
|
57
83
|
"test": "vitest run",
|
|
58
84
|
"typecheck": "tsc --noEmit",
|
|
59
85
|
"clean": "shx rm -rf dist"
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { HastNode as Node } from "../../types.mjs";
|
|
2
|
-
import { Plugin } from "unified";
|
|
3
|
-
//#region src/plugins/heading-id/plugin.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Options for {@linkcode headingIdPlugin}.
|
|
6
|
-
*/
|
|
7
|
-
interface HeadingIdPluginOptions {
|
|
8
|
-
/** Prefix for title slugs. */
|
|
9
|
-
prefix?: string;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* A rehype plugin that adds IDs to heading tags.
|
|
13
|
-
*/
|
|
14
|
-
declare const headingIdPlugin: Plugin<[HeadingIdPluginOptions?], Node, Node>;
|
|
15
|
-
//#endregion
|
|
16
|
-
export { HeadingIdPluginOptions, headingIdPlugin };
|
|
17
|
-
//# sourceMappingURL=plugin.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../../src/plugins/heading-id/plugin.ts"],"mappings":";;;;;;UAWiB;;EAEf;;;;;cAMW,iBAAiB,QAAQ,0BAA0B,MAAU"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import GithubSlugger from "github-slugger";
|
|
2
|
-
import { toString } from "hast-util-to-string";
|
|
3
|
-
import { visit } from "unist-util-visit";
|
|
4
|
-
//#region src/plugins/heading-id/plugin.ts
|
|
5
|
-
/**
|
|
6
|
-
* A rehype plugin that adds IDs to heading tags.
|
|
7
|
-
*/
|
|
8
|
-
const headingIdPlugin = ({ prefix } = {}) => {
|
|
9
|
-
const slugger = new GithubSlugger();
|
|
10
|
-
return (tree) => {
|
|
11
|
-
slugger.reset();
|
|
12
|
-
visit(tree, "element", function visitor(node, index, parent) {
|
|
13
|
-
if (!parent || index === null || !node.tagName.startsWith("h")) return;
|
|
14
|
-
const id = (prefix ?? "") + slugger.slug(toString(node));
|
|
15
|
-
node.properties.id = id;
|
|
16
|
-
});
|
|
17
|
-
return tree;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
//#endregion
|
|
21
|
-
export { headingIdPlugin };
|
|
22
|
-
|
|
23
|
-
//# sourceMappingURL=plugin.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.mjs","names":["hastToString"],"sources":["../../../src/plugins/heading-id/plugin.ts"],"sourcesContent":["import type { Plugin } from \"unified\";\n\nimport GithubSlugger from \"github-slugger\";\nimport { toString as hastToString } from \"hast-util-to-string\";\nimport { visit } from \"unist-util-visit\";\n\nimport type { HastElement, HastNode } from \"../../types\";\n\n/**\n * Options for {@linkcode headingIdPlugin}.\n */\nexport interface HeadingIdPluginOptions {\n /** Prefix for title slugs. */\n prefix?: string;\n}\n\n/**\n * A rehype plugin that adds IDs to heading tags.\n */\nexport const headingIdPlugin: Plugin<[HeadingIdPluginOptions?], HastNode, HastNode> = ({\n prefix,\n} = {}) => {\n const slugger = new GithubSlugger();\n return (tree) => {\n slugger.reset();\n visit(\n tree,\n \"element\",\n function visitor(node: HastElement, index: number, parent: HastElement): void {\n if (!parent || index === null || !node.tagName.startsWith(\"h\")) return;\n const id = (prefix ?? \"\") + slugger.slug(hastToString(node));\n node.properties.id = id;\n },\n );\n return tree;\n };\n};\n"],"mappings":";;;;;;;AAmBA,MAAa,mBAA0E,EACrF,WACE,CAAC,MAAM;CACT,MAAM,UAAU,IAAI,cAAc;CAClC,QAAQ,SAAS;EACf,QAAQ,MAAM;EACd,MACE,MACA,WACA,SAAS,QAAQ,MAAmB,OAAe,QAA2B;GAC5E,IAAI,CAAC,UAAU,UAAU,QAAQ,CAAC,KAAK,QAAQ,WAAW,GAAG,GAAG;GAChE,MAAM,MAAM,UAAU,MAAM,QAAQ,KAAKA,SAAa,IAAI,CAAC;GAC3D,KAAK,WAAW,KAAK;EACvB,CACF;EACA,OAAO;CACT;AACF"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { HastNode as Node } from "../../types.mjs";
|
|
2
|
-
import { KatexOptions } from "katex";
|
|
3
|
-
import { Plugin } from "unified";
|
|
4
|
-
//#region src/plugins/katex/plugin.d.ts
|
|
5
|
-
declare const inlineMathStyleCommands: {
|
|
6
|
-
readonly display: string;
|
|
7
|
-
readonly script: string;
|
|
8
|
-
readonly scriptscript: string;
|
|
9
|
-
readonly text: string;
|
|
10
|
-
};
|
|
11
|
-
type KatexRenderOptions = Omit<KatexOptions, "displayMode" | "throwOnError">;
|
|
12
|
-
/**
|
|
13
|
-
* TeX math style applied to inline math.
|
|
14
|
-
*
|
|
15
|
-
* `"auto"` preserves the source and KaTeX's default style.
|
|
16
|
-
*/
|
|
17
|
-
type InlineMathStyle = "auto" | keyof typeof inlineMathStyleCommands;
|
|
18
|
-
/**
|
|
19
|
-
* KaTeX options controlled by callers. Rendering mode and error handling are
|
|
20
|
-
* inferred and enforced by the plugin.
|
|
21
|
-
*/
|
|
22
|
-
type KatexPluginOptions = KatexRenderOptions & {
|
|
23
|
-
/**
|
|
24
|
-
* TeX math style applied to inline-math nodes.
|
|
25
|
-
*
|
|
26
|
-
* Display and fenced math are not affected.
|
|
27
|
-
*
|
|
28
|
-
* @default "auto"
|
|
29
|
-
*/
|
|
30
|
-
inlineMathStyle?: InlineMathStyle;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Renders HAST elements marked as inline, display, or fenced-code math with
|
|
34
|
-
* KaTeX.
|
|
35
|
-
*/
|
|
36
|
-
declare const katexPlugin: Plugin<[Readonly<KatexPluginOptions>?], Node, Node>;
|
|
37
|
-
//#endregion
|
|
38
|
-
export { InlineMathStyle, KatexPluginOptions, katexPlugin };
|
|
39
|
-
//# sourceMappingURL=plugin.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../../src/plugins/katex/plugin.ts"],"mappings":";;;;cAgBM;WACJ;WACA;WACA;WACA;;KAGG,qBAAqB,KAAK;;;;;;KAOnB,wCAAwC;;;;;KAMxC,qBAAqB;;;;;;;;EAQ/B,kBAAkB;;;;;;cAOP,aAAa,QAAQ,SAAS,uBAAuB,MAAU"}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { fromHtmlIsomorphic } from "hast-util-from-html-isomorphic";
|
|
2
|
-
import { toText } from "hast-util-to-text";
|
|
3
|
-
import katex from "katex";
|
|
4
|
-
import { SKIP, visitParents } from "unist-util-visit-parents";
|
|
5
|
-
//#region src/plugins/katex/plugin.ts
|
|
6
|
-
const mathClasses = {
|
|
7
|
-
display: "math-display",
|
|
8
|
-
inline: "math-inline",
|
|
9
|
-
language: "language-math"
|
|
10
|
-
};
|
|
11
|
-
const inlineMathStyleCommands = {
|
|
12
|
-
display: String.raw`\displaystyle`,
|
|
13
|
-
script: String.raw`\scriptstyle`,
|
|
14
|
-
scriptscript: String.raw`\scriptscriptstyle`,
|
|
15
|
-
text: String.raw`\textstyle`
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Renders HAST elements marked as inline, display, or fenced-code math with
|
|
19
|
-
* KaTeX.
|
|
20
|
-
*/
|
|
21
|
-
const katexPlugin = (options = {}) => {
|
|
22
|
-
const { inlineMathStyle = "auto", ...katexOptions } = options;
|
|
23
|
-
return (tree, file) => {
|
|
24
|
-
visitParents(tree, "element", (element, ancestors) => {
|
|
25
|
-
const classes = Array.isArray(element.properties.className) ? element.properties.className : [];
|
|
26
|
-
const isLanguageMath = classes.includes(mathClasses.language);
|
|
27
|
-
const isDisplayMath = classes.includes(mathClasses.display);
|
|
28
|
-
const isInlineMath = classes.includes(mathClasses.inline);
|
|
29
|
-
if (!isLanguageMath && !isDisplayMath && !isInlineMath) return;
|
|
30
|
-
let scope = element;
|
|
31
|
-
let parent = ancestors.at(-1);
|
|
32
|
-
let displayMode = isDisplayMath;
|
|
33
|
-
if (element.tagName === "code" && isLanguageMath && parent?.type === "element" && parent.tagName === "pre") {
|
|
34
|
-
scope = parent;
|
|
35
|
-
parent = ancestors.at(-2);
|
|
36
|
-
displayMode = true;
|
|
37
|
-
}
|
|
38
|
-
if (parent === void 0 || parent.type !== "element" && parent.type !== "root") return;
|
|
39
|
-
const value = toText(scope, { whitespace: "pre" });
|
|
40
|
-
const renderedValue = isInlineMath && !displayMode ? applyInlineMathStyle(value, inlineMathStyle) : value;
|
|
41
|
-
let result;
|
|
42
|
-
try {
|
|
43
|
-
result = renderMath(renderedValue, katexOptions, displayMode);
|
|
44
|
-
} catch (error) {
|
|
45
|
-
const cause = getOriginalRenderError(value, katexOptions, displayMode, error);
|
|
46
|
-
file.message("Could not render math with KaTeX", {
|
|
47
|
-
ancestors: [...ancestors, element],
|
|
48
|
-
cause,
|
|
49
|
-
place: element.position,
|
|
50
|
-
ruleId: cause.name.toLowerCase(),
|
|
51
|
-
source: "rehype-katex"
|
|
52
|
-
});
|
|
53
|
-
try {
|
|
54
|
-
result = renderMath(value, {
|
|
55
|
-
...katexOptions,
|
|
56
|
-
strict: "ignore"
|
|
57
|
-
}, displayMode, false);
|
|
58
|
-
} catch {
|
|
59
|
-
result = [{
|
|
60
|
-
type: "element",
|
|
61
|
-
tagName: "span",
|
|
62
|
-
properties: {
|
|
63
|
-
className: ["katex-error"],
|
|
64
|
-
style: `color:${katexOptions.errorColor ?? "#cc0000"}`,
|
|
65
|
-
title: String(cause)
|
|
66
|
-
},
|
|
67
|
-
children: [{
|
|
68
|
-
type: "text",
|
|
69
|
-
value
|
|
70
|
-
}]
|
|
71
|
-
}];
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
const index = parent.children.indexOf(scope);
|
|
75
|
-
if (index !== -1) parent.children.splice(index, 1, ...result);
|
|
76
|
-
return SKIP;
|
|
77
|
-
});
|
|
78
|
-
return tree;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
function getOriginalRenderError(value, options, displayMode, styledError) {
|
|
82
|
-
try {
|
|
83
|
-
katex.renderToString(value, {
|
|
84
|
-
...options,
|
|
85
|
-
displayMode,
|
|
86
|
-
throwOnError: true
|
|
87
|
-
});
|
|
88
|
-
} catch (error) {
|
|
89
|
-
return error instanceof Error ? error : new Error(String(error));
|
|
90
|
-
}
|
|
91
|
-
return styledError instanceof Error ? styledError : new Error(String(styledError));
|
|
92
|
-
}
|
|
93
|
-
function applyInlineMathStyle(value, style) {
|
|
94
|
-
if (style === "auto") return value;
|
|
95
|
-
return `{${inlineMathStyleCommands[style]} ${value}}`;
|
|
96
|
-
}
|
|
97
|
-
function renderMath(value, options, displayMode, throwOnError = true) {
|
|
98
|
-
return fromHtmlIsomorphic(katex.renderToString(value, {
|
|
99
|
-
...options,
|
|
100
|
-
displayMode,
|
|
101
|
-
throwOnError
|
|
102
|
-
}), { fragment: true }).children;
|
|
103
|
-
}
|
|
104
|
-
//#endregion
|
|
105
|
-
export { katexPlugin };
|
|
106
|
-
|
|
107
|
-
//# sourceMappingURL=plugin.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../../src/plugins/katex/plugin.ts"],"sourcesContent":["import type { Element, ElementContent, Root } from \"hast\";\nimport type { Plugin } from \"unified\";\n\nimport { fromHtmlIsomorphic } from \"hast-util-from-html-isomorphic\";\nimport { toText } from \"hast-util-to-text\";\nimport katex, { type KatexOptions } from \"katex\";\nimport { SKIP, visitParents } from \"unist-util-visit-parents\";\n\nimport type { HastNode } from \"../../types\";\n\nconst mathClasses = {\n display: \"math-display\",\n inline: \"math-inline\",\n language: \"language-math\",\n} as const;\n\nconst inlineMathStyleCommands = {\n display: String.raw`\\displaystyle`,\n script: String.raw`\\scriptstyle`,\n scriptscript: String.raw`\\scriptscriptstyle`,\n text: String.raw`\\textstyle`,\n} as const;\n\ntype KatexRenderOptions = Omit<KatexOptions, \"displayMode\" | \"throwOnError\">;\n\n/**\n * TeX math style applied to inline math.\n *\n * `\"auto\"` preserves the source and KaTeX's default style.\n */\nexport type InlineMathStyle = \"auto\" | keyof typeof inlineMathStyleCommands;\n\n/**\n * KaTeX options controlled by callers. Rendering mode and error handling are\n * inferred and enforced by the plugin.\n */\nexport type KatexPluginOptions = KatexRenderOptions & {\n /**\n * TeX math style applied to inline-math nodes.\n *\n * Display and fenced math are not affected.\n *\n * @default \"auto\"\n */\n inlineMathStyle?: InlineMathStyle;\n};\n\n/**\n * Renders HAST elements marked as inline, display, or fenced-code math with\n * KaTeX.\n */\nexport const katexPlugin: Plugin<[Readonly<KatexPluginOptions>?], HastNode, HastNode> = (\n options = {},\n) => {\n const { inlineMathStyle = \"auto\", ...katexOptions } = options;\n\n return (tree, file) => {\n visitParents(tree as Root, \"element\", (element, ancestors) => {\n const classes = Array.isArray(element.properties.className)\n ? element.properties.className\n : [];\n const isLanguageMath = classes.includes(mathClasses.language);\n const isDisplayMath = classes.includes(mathClasses.display);\n const isInlineMath = classes.includes(mathClasses.inline);\n\n if (!isLanguageMath && !isDisplayMath && !isInlineMath) {\n return;\n }\n\n let scope: Element = element;\n let parent = ancestors.at(-1);\n let displayMode = isDisplayMath;\n\n if (\n element.tagName === \"code\" &&\n isLanguageMath &&\n parent?.type === \"element\" &&\n parent.tagName === \"pre\"\n ) {\n scope = parent;\n parent = ancestors.at(-2);\n displayMode = true;\n }\n\n if (parent === undefined || (parent.type !== \"element\" && parent.type !== \"root\")) {\n return;\n }\n\n const value = toText(scope, { whitespace: \"pre\" });\n const renderedValue =\n isInlineMath && !displayMode ? applyInlineMathStyle(value, inlineMathStyle) : value;\n let result: ElementContent[];\n\n try {\n result = renderMath(renderedValue, katexOptions, displayMode);\n } catch (error) {\n const cause = getOriginalRenderError(value, katexOptions, displayMode, error);\n\n file.message(\"Could not render math with KaTeX\", {\n ancestors: [...ancestors, element],\n cause,\n place: element.position,\n ruleId: cause.name.toLowerCase(),\n source: \"rehype-katex\",\n });\n\n try {\n result = renderMath(value, { ...katexOptions, strict: \"ignore\" }, displayMode, false);\n } catch {\n result = [\n {\n type: \"element\",\n tagName: \"span\",\n properties: {\n className: [\"katex-error\"],\n style: `color:${katexOptions.errorColor ?? \"#cc0000\"}`,\n title: String(cause),\n },\n children: [{ type: \"text\", value }],\n },\n ];\n }\n }\n\n const index = parent.children.indexOf(scope);\n if (index !== -1) {\n parent.children.splice(index, 1, ...result);\n }\n\n return SKIP;\n });\n\n return tree;\n };\n};\n\nfunction getOriginalRenderError(\n value: string,\n options: Readonly<KatexRenderOptions>,\n displayMode: boolean,\n styledError: unknown,\n): Error {\n try {\n katex.renderToString(value, {\n ...options,\n displayMode,\n throwOnError: true,\n });\n } catch (error) {\n return error instanceof Error ? error : new Error(String(error));\n }\n\n return styledError instanceof Error ? styledError : new Error(String(styledError));\n}\n\nfunction applyInlineMathStyle(value: string, style: InlineMathStyle): string {\n if (style === \"auto\") {\n return value;\n }\n\n return `{${inlineMathStyleCommands[style]} ${value}}`;\n}\n\nfunction renderMath(\n value: string,\n options: Readonly<KatexRenderOptions>,\n displayMode: boolean,\n throwOnError = true,\n): ElementContent[] {\n const html = katex.renderToString(value, {\n ...options,\n displayMode,\n throwOnError,\n });\n const root = fromHtmlIsomorphic(html, { fragment: true });\n\n // KaTeX emits an HTML fragment and therefore cannot produce doctypes.\n return root.children as ElementContent[];\n}\n"],"mappings":";;;;;AAUA,MAAM,cAAc;CAClB,SAAS;CACT,QAAQ;CACR,UAAU;AACZ;AAEA,MAAM,0BAA0B;CAC9B,SAAS,OAAO,GAAG;CACnB,QAAQ,OAAO,GAAG;CAClB,cAAc,OAAO,GAAG;CACxB,MAAM,OAAO,GAAG;AAClB;;;;;AA8BA,MAAa,eACX,UAAU,CAAC,MACR;CACH,MAAM,EAAE,kBAAkB,QAAQ,GAAG,iBAAiB;CAEtD,QAAQ,MAAM,SAAS;EACrB,aAAa,MAAc,YAAY,SAAS,cAAc;GAC5D,MAAM,UAAU,MAAM,QAAQ,QAAQ,WAAW,SAAS,IACtD,QAAQ,WAAW,YACnB,CAAC;GACL,MAAM,iBAAiB,QAAQ,SAAS,YAAY,QAAQ;GAC5D,MAAM,gBAAgB,QAAQ,SAAS,YAAY,OAAO;GAC1D,MAAM,eAAe,QAAQ,SAAS,YAAY,MAAM;GAExD,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,cACxC;GAGF,IAAI,QAAiB;GACrB,IAAI,SAAS,UAAU,GAAG,EAAE;GAC5B,IAAI,cAAc;GAElB,IACE,QAAQ,YAAY,UACpB,kBACA,QAAQ,SAAS,aACjB,OAAO,YAAY,OACnB;IACA,QAAQ;IACR,SAAS,UAAU,GAAG,EAAE;IACxB,cAAc;GAChB;GAEA,IAAI,WAAW,KAAA,KAAc,OAAO,SAAS,aAAa,OAAO,SAAS,QACxE;GAGF,MAAM,QAAQ,OAAO,OAAO,EAAE,YAAY,MAAM,CAAC;GACjD,MAAM,gBACJ,gBAAgB,CAAC,cAAc,qBAAqB,OAAO,eAAe,IAAI;GAChF,IAAI;GAEJ,IAAI;IACF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CAAC;AACd"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { HastNode as Node } from "../types.mjs";
|
|
2
|
-
import { Plugin } from "unified";
|
|
3
|
-
//#region src/plugins/remove-imports-exports.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* A remark plugin which removes all import and export statements.
|
|
6
|
-
*/
|
|
7
|
-
declare const removeImportsExportsPlugin: Plugin<[unknown], Node, Node>;
|
|
8
|
-
//#endregion
|
|
9
|
-
export { removeImportsExportsPlugin };
|
|
10
|
-
//# sourceMappingURL=remove-imports-exports.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remove-imports-exports.d.mts","names":[],"sources":["../../src/plugins/remove-imports-exports.ts"],"mappings":";;;;;;cASa,4BAA4B,kBAAkB,MAAU"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { remove } from "unist-util-remove";
|
|
2
|
-
//#region src/plugins/remove-imports-exports.ts
|
|
3
|
-
/**
|
|
4
|
-
* A remark plugin which removes all import and export statements.
|
|
5
|
-
*/
|
|
6
|
-
const removeImportsExportsPlugin = () => {
|
|
7
|
-
return (tree) => {
|
|
8
|
-
remove(tree, "mdxjsEsm");
|
|
9
|
-
return tree;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
//#endregion
|
|
13
|
-
export { removeImportsExportsPlugin };
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=remove-imports-exports.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remove-imports-exports.mjs","names":[],"sources":["../../src/plugins/remove-imports-exports.ts"],"sourcesContent":["import type { Plugin } from \"unified\";\n\nimport { remove } from \"unist-util-remove\";\n\nimport type { HastNode } from \"../types\";\n\n/**\n * A remark plugin which removes all import and export statements.\n */\nexport const removeImportsExportsPlugin: Plugin<[unknown], HastNode, HastNode> = () => {\n return (tree: HastNode) => {\n remove(tree, \"mdxjsEsm\");\n return tree;\n };\n};\n"],"mappings":";;;;;AASA,MAAa,mCAA0E;CACrF,QAAQ,SAAmB;EACzB,OAAO,MAAM,UAAU;EACvB,OAAO;CACT;AACF"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { HastElement as Element } from "../../types.mjs";
|
|
2
|
-
import { NumericRange } from "@temelj/iterator";
|
|
3
|
-
//#region src/plugins/syntax-highlight/code-meta.d.ts
|
|
4
|
-
interface MdxCodeMeta {
|
|
5
|
-
highlight?: MdxCodeMetaHighlightLine;
|
|
6
|
-
showLineNumbers?: MdxCodeMetaLineNumbers;
|
|
7
|
-
commandLine?: MdxCodeMetaCommandLine;
|
|
8
|
-
fileName?: string;
|
|
9
|
-
}
|
|
10
|
-
type MdxCodeMetaHighlightLine = {
|
|
11
|
-
lineRange: NumericRange;
|
|
12
|
-
};
|
|
13
|
-
type MdxCodeMetaLineNumbers = {
|
|
14
|
-
lineRange: NumericRange;
|
|
15
|
-
};
|
|
16
|
-
type MdxCodeMetaCommandLine = {
|
|
17
|
-
commandRange: NumericRange;
|
|
18
|
-
};
|
|
19
|
-
declare function extractCodeMeta(node: Element): MdxCodeMeta;
|
|
20
|
-
//#endregion
|
|
21
|
-
export { MdxCodeMeta, MdxCodeMetaCommandLine, MdxCodeMetaHighlightLine, MdxCodeMetaLineNumbers, extractCodeMeta };
|
|
22
|
-
//# sourceMappingURL=code-meta.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code-meta.d.mts","names":[],"sources":["../../../src/plugins/syntax-highlight/code-meta.ts"],"mappings":";;;UAKiB;EACf,YAAY;EACZ,kBAAkB;EAClB,cAAc;EACd;;KAGU;EACV,WAAW;;KAGD;EACV,WAAW;;KAGD;EACV,cAAc;;iBAGA,gBAAgB,MAAM,UAAc"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { ss, validateStandardSchemaSync } from "@temelj/standard-schema";
|
|
2
|
-
import { parseNumericRange } from "@temelj/iterator";
|
|
3
|
-
//#region src/plugins/syntax-highlight/code-meta.ts
|
|
4
|
-
function extractCodeMeta(node) {
|
|
5
|
-
return parseMetaString(node?.data?.meta ?? node?.properties?.metastring ?? "");
|
|
6
|
-
}
|
|
7
|
-
const stringOrBoolean = ss.union([ss.string("Expected string or boolean"), ss.boolean("Expected string or boolean")], "Expected string or boolean");
|
|
8
|
-
const metaSchema = ss.object({
|
|
9
|
-
highlight: ss.optional(ss.string("Expected string")),
|
|
10
|
-
showLineNumbers: ss.optional(stringOrBoolean),
|
|
11
|
-
commandLine: ss.optional(stringOrBoolean),
|
|
12
|
-
fileName: ss.optional(ss.string("Expected string"))
|
|
13
|
-
}, "Expected object");
|
|
14
|
-
function parseMetaString(meta) {
|
|
15
|
-
let raw;
|
|
16
|
-
try {
|
|
17
|
-
raw = JSON.parse(meta.trim());
|
|
18
|
-
} catch {
|
|
19
|
-
return {};
|
|
20
|
-
}
|
|
21
|
-
const parsed = validateStandardSchemaSync(metaSchema, raw, "Code metadata validation failed");
|
|
22
|
-
const options = {};
|
|
23
|
-
if (parsed.highlight !== void 0) options.highlight = { lineRange: parseNumericRange(parsed.highlight) };
|
|
24
|
-
if (parsed.showLineNumbers !== void 0) {
|
|
25
|
-
if (typeof parsed.showLineNumbers === "string") options.showLineNumbers = { lineRange: parseNumericRange(parsed.showLineNumbers) };
|
|
26
|
-
else if (parsed.showLineNumbers) options.showLineNumbers = { lineRange: [] };
|
|
27
|
-
}
|
|
28
|
-
if (parsed.commandLine !== void 0) {
|
|
29
|
-
if (typeof parsed.commandLine === "string") options.commandLine = { commandRange: parseNumericRange(parsed.commandLine) };
|
|
30
|
-
else if (parsed.commandLine) options.commandLine = { commandRange: [] };
|
|
31
|
-
}
|
|
32
|
-
if (parsed.fileName !== void 0) options.fileName = parsed.fileName.trim();
|
|
33
|
-
return options;
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
export { extractCodeMeta };
|
|
37
|
-
|
|
38
|
-
//# sourceMappingURL=code-meta.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code-meta.mjs","names":[],"sources":["../../../src/plugins/syntax-highlight/code-meta.ts"],"sourcesContent":["import { type NumericRange, parseNumericRange } from \"@temelj/iterator\";\nimport { ss, validateStandardSchemaSync } from \"@temelj/standard-schema\";\n\nimport type { HastElement } from \"../../types\";\n\nexport interface MdxCodeMeta {\n highlight?: MdxCodeMetaHighlightLine;\n showLineNumbers?: MdxCodeMetaLineNumbers;\n commandLine?: MdxCodeMetaCommandLine;\n fileName?: string;\n}\n\nexport type MdxCodeMetaHighlightLine = {\n lineRange: NumericRange;\n};\n\nexport type MdxCodeMetaLineNumbers = {\n lineRange: NumericRange;\n};\n\nexport type MdxCodeMetaCommandLine = {\n commandRange: NumericRange;\n};\n\nexport function extractCodeMeta(node: HastElement): MdxCodeMeta {\n const meta = node?.data?.meta ?? node?.properties?.metastring ?? \"\";\n return parseMetaString(meta as string);\n}\n\nconst stringOrBoolean = ss.union(\n [ss.string(\"Expected string or boolean\"), ss.boolean(\"Expected string or boolean\")],\n \"Expected string or boolean\",\n);\n\nconst metaSchema = ss.object(\n {\n highlight: ss.optional(ss.string(\"Expected string\")),\n showLineNumbers: ss.optional(stringOrBoolean),\n commandLine: ss.optional(stringOrBoolean),\n fileName: ss.optional(ss.string(\"Expected string\")),\n },\n \"Expected object\",\n);\n\nfunction parseMetaString(meta: string): MdxCodeMeta {\n let raw: unknown;\n try {\n raw = JSON.parse(meta.trim());\n } catch {\n return {};\n }\n const parsed = validateStandardSchemaSync(metaSchema, raw, \"Code metadata validation failed\");\n const options: MdxCodeMeta = {};\n\n if (parsed.highlight !== undefined) {\n options.highlight = { lineRange: parseNumericRange(parsed.highlight) };\n }\n\n if (parsed.showLineNumbers !== undefined) {\n if (typeof parsed.showLineNumbers === \"string\") {\n options.showLineNumbers = {\n lineRange: parseNumericRange(parsed.showLineNumbers),\n };\n } else if (parsed.showLineNumbers) {\n options.showLineNumbers = { lineRange: [] };\n }\n }\n\n if (parsed.commandLine !== undefined) {\n if (typeof parsed.commandLine === \"string\") {\n options.commandLine = {\n commandRange: parseNumericRange(parsed.commandLine),\n };\n } else if (parsed.commandLine) {\n options.commandLine = { commandRange: [] };\n }\n }\n\n if (parsed.fileName !== undefined) {\n options.fileName = parsed.fileName.trim();\n }\n\n return options;\n}\n"],"mappings":";;;AAwBA,SAAgB,gBAAgB,MAAgC;CAE9D,OAAO,gBADM,MAAM,MAAM,QAAQ,MAAM,YAAY,cAAc,EAC5B;AACvC;AAEA,MAAM,kBAAkB,GAAG,MACzB,CAAC,GAAG,OAAO,4BAA4B,GAAG,GAAG,QAAQ,4BAA4B,CAAC,GAClF,4BACF;AAEA,MAAM,aAAa,GAAG,OACpB;CACE,WAAW,GAAG,SAAS,GAAG,OAAO,iBAAiB,CAAC;CACnD,iBAAiB,GAAG,SAAS,eAAe;CAC5C,aAAa,GAAG,SAAS,eAAe;CACxC,UAAU,GAAG,SAAS,GAAG,OAAO,iBAAiB,CAAC;AACpD,GACA,iBACF;AAEA,SAAS,gBAAgB,MAA2B;CAClD,IAAI;CACJ,IAAI;EACF,MAAM,KAAK,MAAM,KAAK,KAAK,CAAC;CAC9B,QAAQ;EACN,OAAO,CAAC;CACV;CACA,MAAM,SAAS,2BAA2B,YAAY,KAAK,iCAAiC;CAC5F,MAAM,UAAuB,CAAC;CAE9B,IAAI,OAAO,cAAc,KAAA,GACvB,QAAQ,YAAY,EAAE,WAAW,kBAAkB,OAAO,SAAS,EAAE;CAGvE,IAAI,OAAO,oBAAoB,KAAA,GACzB;MAAA,OAAO,OAAO,oBAAoB,UACpC,QAAQ,kBAAkB,EACxB,WAAW,kBAAkB,OAAO,eAAe,EACrD;OACK,IAAI,OAAO,iBAChB,QAAQ,kBAAkB,EAAE,WAAW,CAAC,EAAE;CAAA;CAI9C,IAAI,OAAO,gBAAgB,KAAA,GACrB;MAAA,OAAO,OAAO,gBAAgB,UAChC,QAAQ,cAAc,EACpB,cAAc,kBAAkB,OAAO,WAAW,E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