@coderminer/vue-markdown 0.0.0-stage → 1.0.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/CHANGELOG.md +110 -0
- package/LICENSE +21 -0
- package/README.md +579 -3
- package/README.zh-CN.md +547 -0
- package/dist/chunks/MarkdownBlockquote-DVXziX2t.js +18 -0
- package/dist/chunks/MarkdownBlockquote-DVXziX2t.js.map +1 -0
- package/dist/chunks/MarkdownBreak-BwCi2Itt.js +18 -0
- package/dist/chunks/MarkdownBreak-BwCi2Itt.js.map +1 -0
- package/dist/chunks/MarkdownCode-B1k9tmW5.js +65 -0
- package/dist/chunks/MarkdownCode-B1k9tmW5.js.map +1 -0
- package/dist/chunks/MarkdownConfigProvider-5N3ylrIu.js +51 -0
- package/dist/chunks/MarkdownConfigProvider-5N3ylrIu.js.map +1 -0
- package/dist/chunks/MarkdownContent-BAK6dqo7.js +15 -0
- package/dist/chunks/MarkdownContent-BAK6dqo7.js.map +1 -0
- package/dist/chunks/MarkdownCustomTag-BBdn3-WO.js +42 -0
- package/dist/chunks/MarkdownCustomTag-BBdn3-WO.js.map +1 -0
- package/dist/chunks/MarkdownEmphasis-CppivOEu.js +18 -0
- package/dist/chunks/MarkdownEmphasis-CppivOEu.js.map +1 -0
- package/dist/chunks/MarkdownEmpty-Av5k6bqa.js +16 -0
- package/dist/chunks/MarkdownEmpty-Av5k6bqa.js.map +1 -0
- package/dist/chunks/MarkdownError-C0sPs5W0.js +19 -0
- package/dist/chunks/MarkdownError-C0sPs5W0.js.map +1 -0
- package/dist/chunks/MarkdownFootnoteReference-Dy3Khwyj.js +24 -0
- package/dist/chunks/MarkdownFootnoteReference-Dy3Khwyj.js.map +1 -0
- package/dist/chunks/MarkdownFootnotes-BRPzkbXv.js +23 -0
- package/dist/chunks/MarkdownFootnotes-BRPzkbXv.js.map +1 -0
- package/dist/chunks/MarkdownHeading-DaNcP0_6.js +31 -0
- package/dist/chunks/MarkdownHeading-DaNcP0_6.js.map +1 -0
- package/dist/chunks/MarkdownHorizontalRule-QNe_cuUI.js +18 -0
- package/dist/chunks/MarkdownHorizontalRule-QNe_cuUI.js.map +1 -0
- package/dist/chunks/MarkdownHtml-66lYkvwM.js +15 -0
- package/dist/chunks/MarkdownHtml-66lYkvwM.js.map +1 -0
- package/dist/chunks/MarkdownImage-BRy76svs.js +53 -0
- package/dist/chunks/MarkdownImage-BRy76svs.js.map +1 -0
- package/dist/chunks/MarkdownInlineCode-MXZYFwex.js +18 -0
- package/dist/chunks/MarkdownInlineCode-MXZYFwex.js.map +1 -0
- package/dist/chunks/MarkdownLink-Dbx3NwgV.js +47 -0
- package/dist/chunks/MarkdownLink-Dbx3NwgV.js.map +1 -0
- package/dist/chunks/MarkdownList-BJ-_C71k.js +22 -0
- package/dist/chunks/MarkdownList-BJ-_C71k.js.map +1 -0
- package/dist/chunks/MarkdownListItem-Z1EHIY26.js +18 -0
- package/dist/chunks/MarkdownListItem-Z1EHIY26.js.map +1 -0
- package/dist/chunks/MarkdownLoading-D-RYtXxf.js +17 -0
- package/dist/chunks/MarkdownLoading-D-RYtXxf.js.map +1 -0
- package/dist/chunks/MarkdownParagraph-BxLSmSaG.js +18 -0
- package/dist/chunks/MarkdownParagraph-BxLSmSaG.js.map +1 -0
- package/dist/chunks/MarkdownRenderer-DLRRfsdI.js +416 -0
- package/dist/chunks/MarkdownRenderer-DLRRfsdI.js.map +1 -0
- package/dist/chunks/MarkdownRoot-DEE6iVfh.js +25 -0
- package/dist/chunks/MarkdownRoot-DEE6iVfh.js.map +1 -0
- package/dist/chunks/MarkdownStrikethrough-CblvbqDk.js +18 -0
- package/dist/chunks/MarkdownStrikethrough-CblvbqDk.js.map +1 -0
- package/dist/chunks/MarkdownStrong-uU5MzAoJ.js +18 -0
- package/dist/chunks/MarkdownStrong-uU5MzAoJ.js.map +1 -0
- package/dist/chunks/MarkdownTable-DmBTg_CR.js +18 -0
- package/dist/chunks/MarkdownTable-DmBTg_CR.js.map +1 -0
- package/dist/chunks/MarkdownTableCell-eiCJe847.js +33 -0
- package/dist/chunks/MarkdownTableCell-eiCJe847.js.map +1 -0
- package/dist/chunks/MarkdownTableRow-DuJaPntg.js +18 -0
- package/dist/chunks/MarkdownTableRow-DuJaPntg.js.map +1 -0
- package/dist/chunks/MarkdownTableSection-PFHz-R33.js +26 -0
- package/dist/chunks/MarkdownTableSection-PFHz-R33.js.map +1 -0
- package/dist/chunks/MarkdownTaskItem-BcmKo1lk.js +40 -0
- package/dist/chunks/MarkdownTaskItem-BcmKo1lk.js.map +1 -0
- package/dist/chunks/MarkdownToc-BdOHF-Yo.js +51 -0
- package/dist/chunks/MarkdownToc-BdOHF-Yo.js.map +1 -0
- package/dist/chunks/MarkdownTocItem-DT9mR3vL.js +27 -0
- package/dist/chunks/MarkdownTocItem-DT9mR3vL.js.map +1 -0
- package/dist/chunks/MermaidLiveEditor-W-qf3G-5.js +416 -0
- package/dist/chunks/MermaidLiveEditor-W-qf3G-5.js.map +1 -0
- package/dist/chunks/VueSyntaxHighlighter-DyLsYMwy.js +262 -0
- package/dist/chunks/VueSyntaxHighlighter-DyLsYMwy.js.map +1 -0
- package/dist/chunks/adapters-CMwX_NEI.js +28 -0
- package/dist/chunks/adapters-CMwX_NEI.js.map +1 -0
- package/dist/chunks/asyncToGenerator-ChigusFD.js +26 -0
- package/dist/chunks/blank-line-Cb-JBP_5.js +90 -0
- package/dist/chunks/blank-line-Cb-JBP_5.js.map +1 -0
- package/dist/chunks/codemirror-DyphMAEg.js +84 -0
- package/dist/chunks/codemirror-DyphMAEg.js.map +1 -0
- package/dist/chunks/config-aRYo2R8_.js +12 -0
- package/dist/chunks/config-aRYo2R8_.js.map +1 -0
- package/dist/chunks/context-8NfW6fxI.js +32 -0
- package/dist/chunks/context-8NfW6fxI.js.map +1 -0
- package/dist/chunks/default-DWVS-I_8.js +23 -0
- package/dist/chunks/default-DWVS-I_8.js.map +1 -0
- package/dist/chunks/diagnostics-CtHoJyiX.js +25 -0
- package/dist/chunks/diagnostics-CtHoJyiX.js.map +1 -0
- package/dist/chunks/export-DZQ3cUry.js +1575 -0
- package/dist/chunks/export-DZQ3cUry.js.map +1 -0
- package/dist/chunks/hast-nodes-C0bX3M5Z.js +35 -0
- package/dist/chunks/hast-nodes-C0bX3M5Z.js.map +1 -0
- package/dist/chunks/highlightjs-BEh-YwEG.js +6041 -0
- package/dist/chunks/highlightjs-BEh-YwEG.js.map +1 -0
- package/dist/chunks/identity-jZEhX2d5.js +6244 -0
- package/dist/chunks/identity-jZEhX2d5.js.map +1 -0
- package/dist/chunks/labels-BtHiUTQI.js +49 -0
- package/dist/chunks/labels-BtHiUTQI.js.map +1 -0
- package/dist/chunks/lib-BQiWGWpu.js +5087 -0
- package/dist/chunks/lib-BQiWGWpu.js.map +1 -0
- package/dist/chunks/lib-LwqA_W3J.js +127 -0
- package/dist/chunks/lib-LwqA_W3J.js.map +1 -0
- package/dist/chunks/longest-streak-DZE_EqsU.js +10 -0
- package/dist/chunks/longest-streak-DZE_EqsU.js.map +1 -0
- package/dist/chunks/micromark-factory-space-Db040TnW.js +139 -0
- package/dist/chunks/micromark-factory-space-Db040TnW.js.map +1 -0
- package/dist/chunks/normalize-CRYv3Wqt.js +220 -0
- package/dist/chunks/normalize-CRYv3Wqt.js.map +1 -0
- package/dist/chunks/objectSpread2-CtBNx0TF.js +57 -0
- package/dist/chunks/plugin-DqkFHyny.js +28 -0
- package/dist/chunks/plugin-DqkFHyny.js.map +1 -0
- package/dist/chunks/preset-BjaOuJUL.js +46 -0
- package/dist/chunks/preset-BjaOuJUL.js.map +1 -0
- package/dist/chunks/registry-DLjr93-V.js +6144 -0
- package/dist/chunks/registry-DLjr93-V.js.map +1 -0
- package/dist/chunks/render-Cs8iKrgz.js +1724 -0
- package/dist/chunks/render-Cs8iKrgz.js.map +1 -0
- package/dist/chunks/runtime-DJMnzjah.js +546 -0
- package/dist/chunks/runtime-DJMnzjah.js.map +1 -0
- package/dist/chunks/security-y4EwUyAs.js +214 -0
- package/dist/chunks/security-y4EwUyAs.js.map +1 -0
- package/dist/chunks/shared-DNAvZ-UY.js +76 -0
- package/dist/chunks/shared-DNAvZ-UY.js.map +1 -0
- package/dist/chunks/space-separated-tokens-CmBjEPdR.js +1099 -0
- package/dist/chunks/space-separated-tokens-CmBjEPdR.js.map +1 -0
- package/dist/chunks/url-D2BoivaE.js +26 -0
- package/dist/chunks/url-D2BoivaE.js.map +1 -0
- package/dist/chunks/useActiveHeading-BaGVMJnB.js +316 -0
- package/dist/chunks/useActiveHeading-BaGVMJnB.js.map +1 -0
- package/dist/components/CodeBlock.d.ts +73 -0
- package/dist/components/CodeBlock.js +1 -0
- package/dist/components/Icon.d.ts +6 -0
- package/dist/components/MarkdownBlockquote.d.ts +18 -0
- package/dist/components/MarkdownBlockquote.js +1 -0
- package/dist/components/MarkdownBreak.d.ts +8 -0
- package/dist/components/MarkdownBreak.js +1 -0
- package/dist/components/MarkdownChildren.d.ts +17 -0
- package/dist/components/MarkdownCode.d.ts +29 -0
- package/dist/components/MarkdownCode.js +1 -0
- package/dist/components/MarkdownConfigProvider.d.ts +33 -0
- package/dist/components/MarkdownConfigProvider.js +1 -0
- package/dist/components/MarkdownContent.d.ts +16 -0
- package/dist/components/MarkdownContent.js +1 -0
- package/dist/components/MarkdownCustomTag.d.ts +20 -0
- package/dist/components/MarkdownCustomTag.js +1 -0
- package/dist/components/MarkdownEmphasis.d.ts +18 -0
- package/dist/components/MarkdownEmphasis.js +1 -0
- package/dist/components/MarkdownEmpty.d.ts +8 -0
- package/dist/components/MarkdownEmpty.js +1 -0
- package/dist/components/MarkdownError.d.ts +11 -0
- package/dist/components/MarkdownError.js +1 -0
- package/dist/components/MarkdownFootnoteReference.d.ts +19 -0
- package/dist/components/MarkdownFootnoteReference.js +1 -0
- package/dist/components/MarkdownFootnotes.d.ts +17 -0
- package/dist/components/MarkdownFootnotes.js +1 -0
- package/dist/components/MarkdownHeading.d.ts +18 -0
- package/dist/components/MarkdownHeading.js +1 -0
- package/dist/components/MarkdownHorizontalRule.d.ts +8 -0
- package/dist/components/MarkdownHorizontalRule.js +1 -0
- package/dist/components/MarkdownHtml.d.ts +8 -0
- package/dist/components/MarkdownHtml.js +1 -0
- package/dist/components/MarkdownImage.d.ts +15 -0
- package/dist/components/MarkdownImage.js +1 -0
- package/dist/components/MarkdownInlineCode.d.ts +18 -0
- package/dist/components/MarkdownInlineCode.js +1 -0
- package/dist/components/MarkdownLink.d.ts +22 -0
- package/dist/components/MarkdownLink.js +1 -0
- package/dist/components/MarkdownList.d.ts +18 -0
- package/dist/components/MarkdownList.js +1 -0
- package/dist/components/MarkdownListItem.d.ts +18 -0
- package/dist/components/MarkdownListItem.js +1 -0
- package/dist/components/MarkdownLoading.d.ts +8 -0
- package/dist/components/MarkdownLoading.js +1 -0
- package/dist/components/MarkdownMath.d.ts +12 -0
- package/dist/components/MarkdownMath.js +1 -0
- package/dist/components/MarkdownMermaid.d.ts +78 -0
- package/dist/components/MarkdownMermaid.js +1 -0
- package/dist/components/MarkdownParagraph.d.ts +18 -0
- package/dist/components/MarkdownParagraph.js +1 -0
- package/dist/components/MarkdownRenderer.d.ts +170 -0
- package/dist/components/MarkdownRenderer.js +1 -0
- package/dist/components/MarkdownRoot.d.ts +24 -0
- package/dist/components/MarkdownRoot.js +1 -0
- package/dist/components/MarkdownStrikethrough.d.ts +18 -0
- package/dist/components/MarkdownStrikethrough.js +1 -0
- package/dist/components/MarkdownStrong.d.ts +18 -0
- package/dist/components/MarkdownStrong.js +1 -0
- package/dist/components/MarkdownTable.d.ts +18 -0
- package/dist/components/MarkdownTable.js +1 -0
- package/dist/components/MarkdownTableCell.d.ts +20 -0
- package/dist/components/MarkdownTableCell.js +1 -0
- package/dist/components/MarkdownTableRow.d.ts +18 -0
- package/dist/components/MarkdownTableRow.js +1 -0
- package/dist/components/MarkdownTableSection.d.ts +18 -0
- package/dist/components/MarkdownTableSection.js +1 -0
- package/dist/components/MarkdownTaskItem.d.ts +20 -0
- package/dist/components/MarkdownTaskItem.js +1 -0
- package/dist/components/MarkdownToc.d.ts +36 -0
- package/dist/components/MarkdownToc.js +1 -0
- package/dist/components/MarkdownTocItem.d.ts +14 -0
- package/dist/components/MarkdownTocItem.js +1 -0
- package/dist/components/MermaidBlock.d.ts +50 -0
- package/dist/components/MermaidBlock.js +1 -0
- package/dist/components/MermaidLiveEditor.d.ts +44 -0
- package/dist/components/MermaidLiveEditor.js +1 -0
- package/dist/components/VueSyntaxHighlighter.d.ts +39 -0
- package/dist/components/VueSyntaxHighlighter.js +1 -0
- package/dist/components/codeRegion.d.ts +14 -0
- package/dist/components/config.d.ts +7 -0
- package/dist/components/context.d.ts +45 -0
- package/dist/components/index.d.ts +42 -0
- package/dist/components/index.js +38 -0
- package/dist/components/render.d.ts +9 -0
- package/dist/components/scroll-lock.d.ts +7 -0
- package/dist/components/types.d.ts +29 -0
- package/dist/composables/useActiveHeading.d.ts +12 -0
- package/dist/composables/useCodeHighlighter.d.ts +30 -0
- package/dist/composables/useLineWindow.d.ts +38 -0
- package/dist/composables/useMarkdownDocument.d.ts +23 -0
- package/dist/core/adapters.d.ts +7 -0
- package/dist/core/config.d.ts +5 -0
- package/dist/core/diagnostics.d.ts +9 -0
- package/dist/core/finalize.d.ts +18 -0
- package/dist/core/hast-nodes.d.ts +6 -0
- package/dist/core/highlight-lines.d.ts +8 -0
- package/dist/core/identity.d.ts +4 -0
- package/dist/core/labels.d.ts +4 -0
- package/dist/core/manifest.d.ts +38 -0
- package/dist/core/memo.d.ts +5 -0
- package/dist/core/model-hast.d.ts +8 -0
- package/dist/core/model.d.ts +10 -0
- package/dist/core/normalize.d.ts +27 -0
- package/dist/core/parts.d.ts +135 -0
- package/dist/core/preset.d.ts +10 -0
- package/dist/core/run.d.ts +16 -0
- package/dist/core/search.d.ts +5 -0
- package/dist/core/security.d.ts +21 -0
- package/dist/core/slugger.d.ts +6 -0
- package/dist/core/types.d.ts +390 -0
- package/dist/core/url.d.ts +10 -0
- package/dist/editor/codemirror.d.ts +14 -0
- package/dist/editor/index.d.ts +2 -0
- package/dist/editor/index.js +1 -0
- package/dist/export/index.d.ts +6 -0
- package/dist/headless.d.ts +21 -0
- package/dist/headless.js +12 -0
- package/dist/highlight/highlightjs.d.ts +7 -0
- package/dist/highlight/index.d.ts +3 -0
- package/dist/highlight/index.js +3 -0
- package/dist/highlight/shared.d.ts +16 -0
- package/dist/highlight/shiki.d.ts +7 -0
- package/dist/highlight/shiki.js +76 -0
- package/dist/highlight/shiki.js.map +1 -0
- package/dist/html/index.d.ts +17 -0
- package/dist/html/index.js +13 -0
- package/dist/html/index.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/dist/math/index.d.ts +4 -0
- package/dist/math/index.js +583 -0
- package/dist/math/index.js.map +1 -0
- package/dist/math/katex.d.ts +4 -0
- package/dist/math/plugin.d.ts +20 -0
- package/dist/mermaid/index.d.ts +5 -0
- package/dist/mermaid/index.js +3 -0
- package/dist/mermaid/plugin.d.ts +14 -0
- package/dist/mermaid/runtime.d.ts +12 -0
- package/dist/mermaid/sanitize.d.ts +12 -0
- package/dist/node-components.d.ts +1 -0
- package/dist/node-components.js +39 -0
- package/dist/pipeline/custom.d.ts +8 -0
- package/dist/pipeline/identity.d.ts +12 -0
- package/dist/pipeline/index.d.ts +5 -0
- package/dist/pipeline/official.d.ts +6 -0
- package/dist/pipeline.d.ts +1 -0
- package/dist/pipeline.js +1 -0
- package/dist/plugins/builtin.d.ts +15 -0
- package/dist/plugins/define.d.ts +7 -0
- package/dist/plugins/registry.d.ts +16 -0
- package/dist/plugins/source.d.ts +7 -0
- package/dist/plugins.d.ts +3 -0
- package/dist/plugins.js +1 -0
- package/dist/presets.d.ts +3 -0
- package/dist/presets.js +1 -0
- package/dist/style.css +2 -0
- package/dist/styles/components.css +712 -0
- package/dist/styles/index.d.ts +1 -0
- package/dist/styles/math-full.css +3 -0
- package/dist/styles/math.css +18 -0
- package/dist/styles/tokens.css +96 -0
- package/package.json +211 -6
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Properties } from 'hast';
|
|
2
|
+
/** Tags that may appear in the normalized model. */
|
|
3
|
+
export declare const ALLOWED_TAGS: Set<string>;
|
|
4
|
+
/** Tags whose content must never reach the model. */
|
|
5
|
+
export declare const DANGEROUS_TAGS: Set<string>;
|
|
6
|
+
declare const URL_ATTRIBUTES: Set<string>;
|
|
7
|
+
export { URL_ATTRIBUTES };
|
|
8
|
+
export declare function toAttributeName(key: string): string;
|
|
9
|
+
export declare function isAllowedAttribute(tag: string, name: string): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Validate one URL-bearing attribute value. `srcset` holds a comma-separated
|
|
12
|
+
* candidate list, so each candidate is checked individually.
|
|
13
|
+
*/
|
|
14
|
+
export declare function sanitizeUrlValue(value: string, key: string): string | undefined;
|
|
15
|
+
export declare function sanitizeStyleValue(value: string): string | undefined;
|
|
16
|
+
export interface PropertiesToAttrsOptions {
|
|
17
|
+
/** Allow a constrained inline-style subset for trusted engine output. */
|
|
18
|
+
allowStyle?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** Convert hast properties into safe, normalized attributes. */
|
|
21
|
+
export declare function propertiesToAttrs(tag: string, properties: Properties | undefined, options?: PropertiesToAttrsOptions): Record<string, string>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MarkdownSlugger } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Ensure a host slugger still produces unique heading IDs. The wrapper keeps
|
|
4
|
+
* the host's formatting and appends a numeric suffix for duplicates.
|
|
5
|
+
*/
|
|
6
|
+
export declare function withUniqueSlugs(slugger: MarkdownSlugger): MarkdownSlugger;
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import { Root } from 'hast';
|
|
2
|
+
import { PluggableList } from 'unified';
|
|
3
|
+
/** A position inside the original Markdown source. */
|
|
4
|
+
export interface SourcePosition {
|
|
5
|
+
line: number;
|
|
6
|
+
column: number;
|
|
7
|
+
offset?: number;
|
|
8
|
+
}
|
|
9
|
+
/** A half-open range inside the original Markdown source. */
|
|
10
|
+
export interface SourceRange {
|
|
11
|
+
start: SourcePosition;
|
|
12
|
+
end: SourcePosition;
|
|
13
|
+
}
|
|
14
|
+
/** A piece of a text node, optionally marked as a search match. */
|
|
15
|
+
export interface MarkdownTextSegment {
|
|
16
|
+
value: string;
|
|
17
|
+
match?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface MarkdownTextNode {
|
|
20
|
+
kind: 'text';
|
|
21
|
+
key: string;
|
|
22
|
+
value: string;
|
|
23
|
+
segments?: MarkdownTextSegment[];
|
|
24
|
+
source?: SourceRange;
|
|
25
|
+
}
|
|
26
|
+
export interface MarkdownElementNode {
|
|
27
|
+
kind: 'element';
|
|
28
|
+
key: string;
|
|
29
|
+
tag: string;
|
|
30
|
+
attrs: Record<string, string>;
|
|
31
|
+
children: MarkdownNode[];
|
|
32
|
+
source?: SourceRange;
|
|
33
|
+
}
|
|
34
|
+
export interface MarkdownCodeNode {
|
|
35
|
+
kind: 'code';
|
|
36
|
+
key: string;
|
|
37
|
+
code: string;
|
|
38
|
+
language: string;
|
|
39
|
+
highlighted?: MarkdownNode[];
|
|
40
|
+
source?: SourceRange;
|
|
41
|
+
}
|
|
42
|
+
export interface MarkdownMathNode {
|
|
43
|
+
kind: 'math';
|
|
44
|
+
key: string;
|
|
45
|
+
tex: string;
|
|
46
|
+
displayMode: boolean;
|
|
47
|
+
rendered?: MarkdownNode[];
|
|
48
|
+
source?: SourceRange;
|
|
49
|
+
}
|
|
50
|
+
export interface MarkdownMermaidNode {
|
|
51
|
+
kind: 'mermaid';
|
|
52
|
+
key: string;
|
|
53
|
+
code: string;
|
|
54
|
+
complete: boolean;
|
|
55
|
+
index: number;
|
|
56
|
+
source?: SourceRange;
|
|
57
|
+
}
|
|
58
|
+
export interface MarkdownCustomTagNode {
|
|
59
|
+
kind: 'custom';
|
|
60
|
+
key: string;
|
|
61
|
+
tag: string;
|
|
62
|
+
props: Record<string, unknown>;
|
|
63
|
+
attrs: Record<string, string>;
|
|
64
|
+
children: MarkdownNode[];
|
|
65
|
+
source?: SourceRange;
|
|
66
|
+
}
|
|
67
|
+
export interface MarkdownPluginNode {
|
|
68
|
+
kind: 'plugin';
|
|
69
|
+
key: string;
|
|
70
|
+
type: string;
|
|
71
|
+
payload: unknown;
|
|
72
|
+
children?: MarkdownNode[];
|
|
73
|
+
source?: SourceRange;
|
|
74
|
+
}
|
|
75
|
+
/** The immutable, serializable document model. */
|
|
76
|
+
export type MarkdownNode = MarkdownTextNode | MarkdownElementNode | MarkdownCodeNode | MarkdownMathNode | MarkdownMermaidNode | MarkdownCustomTagNode | MarkdownPluginNode;
|
|
77
|
+
export interface TocItem {
|
|
78
|
+
id: string;
|
|
79
|
+
text: string;
|
|
80
|
+
level: number;
|
|
81
|
+
}
|
|
82
|
+
/** Renderer-level search state emitted with `search-change`. */
|
|
83
|
+
export interface SearchChangePayload {
|
|
84
|
+
query: string;
|
|
85
|
+
caseSensitive: boolean;
|
|
86
|
+
matches: number;
|
|
87
|
+
}
|
|
88
|
+
/** Options for segmenting text nodes into search matches. */
|
|
89
|
+
export interface SearchOptions {
|
|
90
|
+
query?: string;
|
|
91
|
+
caseSensitive?: boolean;
|
|
92
|
+
}
|
|
93
|
+
export interface CustomTagInstance {
|
|
94
|
+
key: string;
|
|
95
|
+
tag: string;
|
|
96
|
+
props: Record<string, unknown>;
|
|
97
|
+
attrs: Record<string, string>;
|
|
98
|
+
}
|
|
99
|
+
export interface MarkdownDocument {
|
|
100
|
+
nodes: MarkdownNode[];
|
|
101
|
+
toc: TocItem[];
|
|
102
|
+
customTags: CustomTagInstance[];
|
|
103
|
+
frontmatter?: Record<string, unknown>;
|
|
104
|
+
plugins: string[];
|
|
105
|
+
pipeline: string;
|
|
106
|
+
}
|
|
107
|
+
export type DiagnosticSeverity = 'error' | 'warning';
|
|
108
|
+
export type DiagnosticPhase = 'setup' | 'source' | 'remark' | 'rehype' | 'normalize' | 'document' | 'search' | 'render' | 'pipeline';
|
|
109
|
+
export interface MarkdownDiagnostic {
|
|
110
|
+
code: string;
|
|
111
|
+
message: string;
|
|
112
|
+
severity: DiagnosticSeverity;
|
|
113
|
+
phase?: DiagnosticPhase;
|
|
114
|
+
plugin?: string;
|
|
115
|
+
source?: SourceRange;
|
|
116
|
+
/** Optional raw parser/engine detail shown only by opt-in UI. */
|
|
117
|
+
details?: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* A component reference accepted by the core types.
|
|
121
|
+
*
|
|
122
|
+
* The core stays free of Vue types; the Vue-facing aliases in
|
|
123
|
+
* `components/types.ts` narrow this to Vue's `Component`.
|
|
124
|
+
*/
|
|
125
|
+
export type MarkdownComponentValue = string | object | ((...args: never[]) => unknown) | undefined;
|
|
126
|
+
export type MarkdownTagComponents = Record<string, MarkdownComponentValue>;
|
|
127
|
+
export type MarkdownNodeComponents = Record<string, MarkdownComponentValue>;
|
|
128
|
+
export interface MarkdownRegionComponents {
|
|
129
|
+
root?: MarkdownComponentValue;
|
|
130
|
+
content?: MarkdownComponentValue;
|
|
131
|
+
toc?: MarkdownComponentValue;
|
|
132
|
+
tocItem?: MarkdownComponentValue;
|
|
133
|
+
codeBlock?: MarkdownComponentValue;
|
|
134
|
+
mermaidBlock?: MarkdownComponentValue;
|
|
135
|
+
error?: MarkdownComponentValue;
|
|
136
|
+
empty?: MarkdownComponentValue;
|
|
137
|
+
loading?: MarkdownComponentValue;
|
|
138
|
+
}
|
|
139
|
+
export type MarkdownLabelContext = Record<string, unknown>;
|
|
140
|
+
export type MarkdownLabelValue = string | ((context: MarkdownLabelContext) => string);
|
|
141
|
+
export interface MarkdownLabels {
|
|
142
|
+
toc: MarkdownLabelValue;
|
|
143
|
+
error: MarkdownLabelValue;
|
|
144
|
+
empty: MarkdownLabelValue;
|
|
145
|
+
loading: MarkdownLabelValue;
|
|
146
|
+
headingAnchor: MarkdownLabelValue;
|
|
147
|
+
externalLink: MarkdownLabelValue;
|
|
148
|
+
copy: MarkdownLabelValue;
|
|
149
|
+
copied: MarkdownLabelValue;
|
|
150
|
+
copyFailed: MarkdownLabelValue;
|
|
151
|
+
download: MarkdownLabelValue;
|
|
152
|
+
footnoteReference: MarkdownLabelValue;
|
|
153
|
+
footnotes: MarkdownLabelValue;
|
|
154
|
+
math: MarkdownLabelValue;
|
|
155
|
+
mermaid: MarkdownLabelValue;
|
|
156
|
+
mermaidFallback: MarkdownLabelValue;
|
|
157
|
+
preview: MarkdownLabelValue;
|
|
158
|
+
source: MarkdownLabelValue;
|
|
159
|
+
retry: MarkdownLabelValue;
|
|
160
|
+
showAll: MarkdownLabelValue;
|
|
161
|
+
showLess: MarkdownLabelValue;
|
|
162
|
+
exportPng: MarkdownLabelValue;
|
|
163
|
+
fullscreen: MarkdownLabelValue;
|
|
164
|
+
exitFullscreen: MarkdownLabelValue;
|
|
165
|
+
zoomIn: MarkdownLabelValue;
|
|
166
|
+
zoomOut: MarkdownLabelValue;
|
|
167
|
+
reset: MarkdownLabelValue;
|
|
168
|
+
editor: MarkdownLabelValue;
|
|
169
|
+
editorEmpty: MarkdownLabelValue;
|
|
170
|
+
editorLine: MarkdownLabelValue;
|
|
171
|
+
editorSplitter: MarkdownLabelValue;
|
|
172
|
+
editorDiagnostics: MarkdownLabelValue;
|
|
173
|
+
editorReset: MarkdownLabelValue;
|
|
174
|
+
editorSyntaxError: MarkdownLabelValue;
|
|
175
|
+
editorParseError: MarkdownLabelValue;
|
|
176
|
+
}
|
|
177
|
+
export type MarkdownTheme = 'light' | 'dark' | 'auto' | 'custom';
|
|
178
|
+
export interface HighlightOptions {
|
|
179
|
+
theme?: string;
|
|
180
|
+
colorScheme?: 'light' | 'dark';
|
|
181
|
+
[option: string]: unknown;
|
|
182
|
+
}
|
|
183
|
+
export interface HighlightResult {
|
|
184
|
+
language: string;
|
|
185
|
+
nodes: MarkdownNode[];
|
|
186
|
+
mode?: 'content' | 'block';
|
|
187
|
+
className?: string;
|
|
188
|
+
}
|
|
189
|
+
/** A 1-based line number or an inclusive `start-end` range string. */
|
|
190
|
+
export type HighlightLine = number | string;
|
|
191
|
+
export interface CodeBlockAction {
|
|
192
|
+
key: string;
|
|
193
|
+
label: MarkdownLabelValue;
|
|
194
|
+
run(context: {
|
|
195
|
+
code: string;
|
|
196
|
+
language: string;
|
|
197
|
+
copy(): Promise<void>;
|
|
198
|
+
download(): Promise<void>;
|
|
199
|
+
}): void | Promise<void>;
|
|
200
|
+
}
|
|
201
|
+
export interface MermaidAction {
|
|
202
|
+
key: string;
|
|
203
|
+
label: MarkdownLabelValue;
|
|
204
|
+
run(context: {
|
|
205
|
+
source: string;
|
|
206
|
+
copy(): Promise<void>;
|
|
207
|
+
exportPng(): Promise<void>;
|
|
208
|
+
downloadSvg(): void;
|
|
209
|
+
fullscreen(): Promise<void> | void;
|
|
210
|
+
retry(): Promise<void>;
|
|
211
|
+
zoomIn(): void;
|
|
212
|
+
zoomOut(): void;
|
|
213
|
+
resetZoom(): void;
|
|
214
|
+
}): void | Promise<void>;
|
|
215
|
+
}
|
|
216
|
+
export interface MarkdownHighlighter {
|
|
217
|
+
id: string;
|
|
218
|
+
load?(): Promise<void>;
|
|
219
|
+
languages?: string[];
|
|
220
|
+
loadLanguage?(language: string): Promise<void>;
|
|
221
|
+
highlight(code: string, language: string, options: HighlightOptions): HighlightResult;
|
|
222
|
+
}
|
|
223
|
+
export interface MathRenderOptions {
|
|
224
|
+
displayMode?: boolean;
|
|
225
|
+
[option: string]: unknown;
|
|
226
|
+
}
|
|
227
|
+
export interface MathRenderResult {
|
|
228
|
+
nodes: MarkdownNode[];
|
|
229
|
+
error?: string;
|
|
230
|
+
}
|
|
231
|
+
export interface MathEngine {
|
|
232
|
+
id: string;
|
|
233
|
+
load?(): Promise<void>;
|
|
234
|
+
render(tex: string, options: MathRenderOptions): MathRenderResult;
|
|
235
|
+
}
|
|
236
|
+
export interface MermaidRenderOptions {
|
|
237
|
+
theme?: MarkdownTheme;
|
|
238
|
+
id?: string;
|
|
239
|
+
[option: string]: unknown;
|
|
240
|
+
}
|
|
241
|
+
export interface MermaidRenderResult {
|
|
242
|
+
nodes: MarkdownNode[];
|
|
243
|
+
svg?: string;
|
|
244
|
+
error?: string;
|
|
245
|
+
}
|
|
246
|
+
export interface MermaidRenderer {
|
|
247
|
+
id: string;
|
|
248
|
+
render(source: string, options: MermaidRenderOptions): MermaidRenderResult | Promise<MermaidRenderResult>;
|
|
249
|
+
}
|
|
250
|
+
export interface DiagnosticFormatter {
|
|
251
|
+
id?: string;
|
|
252
|
+
format(error: unknown, source: string): MarkdownDiagnostic;
|
|
253
|
+
}
|
|
254
|
+
/** Parsed configuration shared by the provider, presets, and the renderer. */
|
|
255
|
+
export interface MarkdownConfig {
|
|
256
|
+
theme?: MarkdownTheme;
|
|
257
|
+
tokens?: Record<string, string>;
|
|
258
|
+
labels?: Partial<MarkdownLabels>;
|
|
259
|
+
components?: MarkdownTagComponents;
|
|
260
|
+
regions?: MarkdownRegionComponents;
|
|
261
|
+
nodeComponents?: MarkdownNodeComponents;
|
|
262
|
+
plugins?: PluginInput[];
|
|
263
|
+
pipeline?: MarkdownPipeline;
|
|
264
|
+
highlighter?: MarkdownHighlighter;
|
|
265
|
+
mathEngine?: MathEngine;
|
|
266
|
+
mermaidRenderer?: MermaidRenderer;
|
|
267
|
+
diagnosticsFormatter?: DiagnosticFormatter;
|
|
268
|
+
slugger?: MarkdownSlugger;
|
|
269
|
+
urlTransform?: MarkdownUrlTransform;
|
|
270
|
+
}
|
|
271
|
+
/** A named, declarative bundle of configuration. Not JSON-serializable. */
|
|
272
|
+
export interface MarkdownPreset extends MarkdownConfig {
|
|
273
|
+
name: string;
|
|
274
|
+
}
|
|
275
|
+
export interface MarkdownSlugger {
|
|
276
|
+
slug(value: string): string;
|
|
277
|
+
reset?(): void;
|
|
278
|
+
}
|
|
279
|
+
export interface MarkdownElementLike {
|
|
280
|
+
tag: string;
|
|
281
|
+
attrs: Record<string, string>;
|
|
282
|
+
}
|
|
283
|
+
export type MarkdownUrlTransform = (url: string, key: string, node: MarkdownElementLike) => string | null | undefined;
|
|
284
|
+
export type AllowElement = (node: MarkdownElementNode, index: number | undefined, parent: MarkdownElementNode | undefined) => boolean | null | undefined;
|
|
285
|
+
/** Result of a pipeline run: hast plus optional document metadata. */
|
|
286
|
+
export interface PipelineResult {
|
|
287
|
+
hast: Root;
|
|
288
|
+
frontmatter?: Record<string, unknown>;
|
|
289
|
+
}
|
|
290
|
+
export interface PipelineCapabilities {
|
|
291
|
+
/** The pipeline exposes a synchronous path. */
|
|
292
|
+
sync?: boolean;
|
|
293
|
+
/** The pipeline reports plugin names. */
|
|
294
|
+
plugins?: boolean;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Add-only extension for the built-in raw HTML sanitizer. Property names use
|
|
298
|
+
* hast property casing (for example `srcSet`, `dateTime`). Extensions cannot
|
|
299
|
+
* remove the built-in strip list, change the URL policy, or bypass the core
|
|
300
|
+
* attribute policy.
|
|
301
|
+
*/
|
|
302
|
+
export interface HtmlSchemaExtension {
|
|
303
|
+
/** Extra tag names to allow. Dangerous tags remain stripped. */
|
|
304
|
+
tags?: string[];
|
|
305
|
+
/** Extra properties per tag; `'*'` applies to every tag. */
|
|
306
|
+
attributes?: Record<string, string[]>;
|
|
307
|
+
}
|
|
308
|
+
export interface PluginContext {
|
|
309
|
+
source: string;
|
|
310
|
+
options: MarkdownDocumentOptions;
|
|
311
|
+
diagnostics: MarkdownDiagnostic[];
|
|
312
|
+
addDiagnostic(diagnostic: MarkdownDiagnostic): void;
|
|
313
|
+
document?: MarkdownDocument;
|
|
314
|
+
}
|
|
315
|
+
export interface MarkdownPlugin {
|
|
316
|
+
name: string;
|
|
317
|
+
/**
|
|
318
|
+
* Core invariant markers cannot be disabled. Their names remain in the
|
|
319
|
+
* resolved set for ordering and diagnostics only.
|
|
320
|
+
*/
|
|
321
|
+
core?: boolean;
|
|
322
|
+
phase?: 'pre' | 'normal' | 'post';
|
|
323
|
+
/**
|
|
324
|
+
* This plugin enables raw HTML parsing. Its rehype plugins run before the
|
|
325
|
+
* built-in sanitizer, and the official pipeline always sanitizes the result.
|
|
326
|
+
*/
|
|
327
|
+
html?: boolean;
|
|
328
|
+
/** Add-only extension for the built-in raw HTML sanitizer. */
|
|
329
|
+
htmlSchema?: HtmlSchemaExtension;
|
|
330
|
+
remarkPlugins?: PluggableList;
|
|
331
|
+
rehypePlugins?: PluggableList;
|
|
332
|
+
remarkRehypeOptions?: Record<string, unknown>;
|
|
333
|
+
transformSource?(source: string, ctx: PluginContext): string;
|
|
334
|
+
transformDocument?(document: MarkdownDocument, ctx: PluginContext): MarkdownDocument | void;
|
|
335
|
+
nodeComponents?: MarkdownNodeComponents;
|
|
336
|
+
components?: MarkdownTagComponents;
|
|
337
|
+
regions?: MarkdownRegionComponents;
|
|
338
|
+
labels?: Partial<MarkdownLabels>;
|
|
339
|
+
tokens?: Record<string, string>;
|
|
340
|
+
setup?(ctx: PluginContext): void | (() => void);
|
|
341
|
+
onError?(error: unknown, phase: DiagnosticPhase, ctx: PluginContext): void;
|
|
342
|
+
}
|
|
343
|
+
export type PluginInput = MarkdownPlugin | false | null | undefined;
|
|
344
|
+
export interface PipelineContext {
|
|
345
|
+
source: string;
|
|
346
|
+
/**
|
|
347
|
+
* The options that produced this run. Optional for custom pipelines that do
|
|
348
|
+
* not need plugin callbacks.
|
|
349
|
+
*/
|
|
350
|
+
options?: MarkdownDocumentOptions;
|
|
351
|
+
plugins: MarkdownPlugin[];
|
|
352
|
+
remarkPlugins: PluggableList;
|
|
353
|
+
rehypePlugins: PluggableList;
|
|
354
|
+
remarkRehypeOptions: Record<string, unknown>;
|
|
355
|
+
slugger: MarkdownSlugger;
|
|
356
|
+
idPrefix: string;
|
|
357
|
+
diagnostics: MarkdownDiagnostic[];
|
|
358
|
+
}
|
|
359
|
+
export interface MarkdownPipeline {
|
|
360
|
+
name: string;
|
|
361
|
+
capabilities?: PipelineCapabilities;
|
|
362
|
+
process(source: string, ctx: PipelineContext): Promise<PipelineResult>;
|
|
363
|
+
processSync?(source: string, ctx: PipelineContext): PipelineResult;
|
|
364
|
+
dispose?(): void;
|
|
365
|
+
}
|
|
366
|
+
export interface MarkdownDocumentOptions {
|
|
367
|
+
components?: MarkdownTagComponents;
|
|
368
|
+
nodeComponents?: MarkdownNodeComponents;
|
|
369
|
+
regions?: MarkdownRegionComponents;
|
|
370
|
+
labels?: Partial<MarkdownLabels>;
|
|
371
|
+
tokens?: Record<string, string>;
|
|
372
|
+
plugins?: PluginInput[];
|
|
373
|
+
disablePlugins?: string[];
|
|
374
|
+
remarkPlugins?: PluggableList;
|
|
375
|
+
rehypePlugins?: PluggableList;
|
|
376
|
+
remarkRehypeOptions?: Record<string, unknown>;
|
|
377
|
+
pipeline?: MarkdownPipeline;
|
|
378
|
+
slugger?: MarkdownSlugger;
|
|
379
|
+
allowedElements?: string[];
|
|
380
|
+
disallowedElements?: string[];
|
|
381
|
+
unwrapDisallowed?: boolean;
|
|
382
|
+
allowElement?: AllowElement;
|
|
383
|
+
urlTransform?: MarkdownUrlTransform;
|
|
384
|
+
linkTarget?: string;
|
|
385
|
+
externalLinkTarget?: string;
|
|
386
|
+
baseUrl?: string;
|
|
387
|
+
idPrefix?: string;
|
|
388
|
+
/** Host-provided search state; search segments are recomputed when set. */
|
|
389
|
+
search?: SearchOptions;
|
|
390
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-markdown-compatible URL transform.
|
|
3
|
+
*
|
|
4
|
+
* Relative URLs and the documented protocol set pass through. Dangerous
|
|
5
|
+
* protocols are removed. Image data URLs are accepted for raster formats only;
|
|
6
|
+
* `image/svg+xml` is rejected because it can carry script.
|
|
7
|
+
*/
|
|
8
|
+
export declare function defaultUrlTransform(url: string, key?: string): string;
|
|
9
|
+
export declare function isExternalUrl(url: string): boolean;
|
|
10
|
+
export declare function resolveUrl(url: string, baseUrl: string | undefined): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EditorView } from '@codemirror/view';
|
|
2
|
+
export interface MermaidEditorHandle {
|
|
3
|
+
destroy(): void;
|
|
4
|
+
focus(): void;
|
|
5
|
+
setValue(value: string): void;
|
|
6
|
+
focusLine(line: number): void;
|
|
7
|
+
}
|
|
8
|
+
export interface CreateEditorOptions {
|
|
9
|
+
value: string;
|
|
10
|
+
theme?: 'light' | 'dark' | 'auto' | 'custom';
|
|
11
|
+
onChange(value: string): void;
|
|
12
|
+
}
|
|
13
|
+
export declare function createMermaidEditor(parent: HTMLElement, options: CreateEditorOptions): Promise<MermaidEditorHandle>;
|
|
14
|
+
export type { EditorView };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as createMermaidEditor } from "../chunks/codemirror-DyphMAEg.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MarkdownDocumentOptions } from '../core/types';
|
|
2
|
+
export type StaticHtmlOptions = MarkdownDocumentOptions;
|
|
3
|
+
/** Render Markdown to static HTML with the same normalized document as rendering. */
|
|
4
|
+
export declare function exportMarkdownHtml(source: string, options?: StaticHtmlOptions): Promise<string>;
|
|
5
|
+
/** Synchronous static HTML export when every configured plugin is synchronous. */
|
|
6
|
+
export declare function exportMarkdownHtmlSync(source: string, options?: StaticHtmlOptions): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export * from './core/types';
|
|
2
|
+
export * from './core/parts';
|
|
3
|
+
export * from './core/labels';
|
|
4
|
+
export * from './core/diagnostics';
|
|
5
|
+
export * from './core/url';
|
|
6
|
+
export * from './core/model';
|
|
7
|
+
export * from './core/normalize';
|
|
8
|
+
export * from './core/search';
|
|
9
|
+
export * from './core/slugger';
|
|
10
|
+
export * from './core/manifest';
|
|
11
|
+
export * from './core/config';
|
|
12
|
+
export * from './core/preset';
|
|
13
|
+
export * from './core/adapters';
|
|
14
|
+
export * from './export';
|
|
15
|
+
export * from './core/memo';
|
|
16
|
+
export * from './pipeline';
|
|
17
|
+
export * from './plugins/define';
|
|
18
|
+
export * from './plugins/builtin';
|
|
19
|
+
export * from './plugins/registry';
|
|
20
|
+
export * from './composables/useMarkdownDocument';
|
|
21
|
+
export * from './composables/useActiveHeading';
|
package/dist/headless.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, p as c, r as l, s as u, t as d, u as f } from "./chunks/export-DZQ3cUry.js";
|
|
2
|
+
import { n as p, t as m } from "./chunks/labels-BtHiUTQI.js";
|
|
3
|
+
import { n as h, t as g } from "./chunks/diagnostics-CtHoJyiX.js";
|
|
4
|
+
import { n as _, r as v, t as y } from "./chunks/url-D2BoivaE.js";
|
|
5
|
+
import { a as b, i as x, n as S, r as C, t as w } from "./chunks/normalize-CRYv3Wqt.js";
|
|
6
|
+
import { a as T, d as E, f as D, i as O, n as k, o as A, p as j, r as M, s as N, t as P } from "./chunks/useActiveHeading-BaGVMJnB.js";
|
|
7
|
+
import { _ as F, a as I, c as L, d as R, f as z, g as B, h as V, i as H, l as U, n as W, o as G, p as K, r as q, s as J, t as Y, u as X } from "./chunks/registry-DLjr93-V.js";
|
|
8
|
+
import { a as Z, i as Q, n as $, r as ee, t as te } from "./chunks/preset-BjaOuJUL.js";
|
|
9
|
+
import { a as ne, i as re, n as ie, o as ae, r as oe, t as se } from "./chunks/adapters-CMwX_NEI.js";
|
|
10
|
+
import { a as ce, i as le, n as ue, o as de, r as fe, s as pe, t as me } from "./chunks/identity-jZEhX2d5.js";
|
|
11
|
+
import "./pipeline.js";
|
|
12
|
+
export { l as COMPONENT_MANIFESTS, m as DEFAULT_LABELS, u as PARTS, t as PART_NAMES, a as TOKENS, f as TOKEN_NAMES, n as VMD_CLASS_PREFIX, fe as assertPipelineResult, D as buildDocument, W as codePlugin, w as collectCustomTags, te as composePresets, V as countSearchMatches, g as createDiagnostic, me as createMemoKey, pe as createOfficialPipeline, ue as createPipelineIdentity, R as createPluginContext, q as customTagsPlugin, H as defaultPlugins, y as defaultUrlTransform, le as defineMarkdownPipeline, z as defineMarkdownPlugin, $ as defineMarkdownPreset, h as errorMessage, d as exportMarkdownHtml, o as exportMarkdownHtmlSync, S as extractToc, C as filterTocByDepth, P as findElementById, I as frontmatterPlugin, G as fullPlugins, i as getComponentManifest, J as gfmPlugin, _ as isExternalUrl, se as isValidDiagnosticFormatter, ie as isValidHighlighter, oe as isValidMathEngine, re as isValidMermaidRenderer, ne as isValidSlugger, ae as isValidUrlTransform, L as linkPlugin, O as memoClear, T as memoGet, A as memoSet, N as memoSize, Q as mergeMarkdownConfig, Z as mergeMarkdownPreset, x as normalizeHast, r as partAttrs, c as partClass, p as resolveLabel, ce as resolvePipeline, Y as resolvePlugins, ee as resolvePreset, v as resolveUrl, B as searchDocument, U as searchPlugin, F as segmentSearch, X as tocPlugin, k as useActiveHeading, M as useMarkdownDocument, e as validateManifest, s as validateManifestRegistry, de as validatePipeline, K as validatePlugin, b as walkNodes, j as withDerivedDocument, E as withUniqueSlugs };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MarkdownHighlighter } from '../core/types';
|
|
2
|
+
/**
|
|
3
|
+
* Default highlight.js adapter. It is intentionally synchronous so the
|
|
4
|
+
* renderer can produce highlighted output without blocking.
|
|
5
|
+
*/
|
|
6
|
+
export declare const highlightjs: MarkdownHighlighter;
|
|
7
|
+
export default highlightjs;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as e, i as t, n, o as r, r as i, t as a } from "../chunks/shared-DNAvZ-UY.js";
|
|
2
|
+
import { t as o } from "../chunks/highlightjs-BEh-YwEG.js";
|
|
3
|
+
export { a as clearHighlightCache, o as default, o as highlightjs, n as highlightedNodesFromHast, i as highlightedNodesFromHtml, t as plaintextHighlight, e as runHighlighter, r as splitHighlightLines };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HighlightOptions, HighlightResult, MarkdownHighlighter, MarkdownNode } from '../core/types';
|
|
2
|
+
import { hastToMarkdownNodes } from '../core/hast-nodes';
|
|
3
|
+
export declare function plaintextHighlight(code: string, language?: string): HighlightResult;
|
|
4
|
+
/** Convert trusted engine HTML into normalized nodes. */
|
|
5
|
+
export declare function highlightedNodesFromHtml(html: string): MarkdownNode[];
|
|
6
|
+
/** Convert an already-parsed hast subtree into normalized nodes. */
|
|
7
|
+
export declare function highlightedNodesFromHast(nodes: Parameters<typeof hastToMarkdownNodes>[0]): MarkdownNode[];
|
|
8
|
+
export declare function cacheKey(highlighter: MarkdownHighlighter, code: string, language: string, options: HighlightOptions): string;
|
|
9
|
+
export declare function clearHighlightCache(): void;
|
|
10
|
+
/**
|
|
11
|
+
* Run one adapter safely. Invalid adapters, thrown errors, and malformed
|
|
12
|
+
* results fall back to plain text instead of breaking the document.
|
|
13
|
+
*/
|
|
14
|
+
export declare function runHighlighter(highlighter: MarkdownHighlighter | undefined, code: string, language: string, options?: HighlightOptions): HighlightResult;
|
|
15
|
+
/** Split highlighted nodes into lines while preserving element wrappers. */
|
|
16
|
+
export declare function splitHighlightLines(nodes: readonly MarkdownNode[]): MarkdownNode[][];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MarkdownHighlighter } from '../core/types';
|
|
2
|
+
/**
|
|
3
|
+
* Optional Shiki adapter. The highlighter, themes, and requested languages
|
|
4
|
+
* load asynchronously; until then callers see plain text.
|
|
5
|
+
*/
|
|
6
|
+
export declare const shiki: MarkdownHighlighter;
|
|
7
|
+
export default shiki;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { t as e } from "../chunks/objectSpread2-CtBNx0TF.js";
|
|
2
|
+
import { t } from "../chunks/asyncToGenerator-ChigusFD.js";
|
|
3
|
+
import { i as n, n as r } from "../chunks/shared-DNAvZ-UY.js";
|
|
4
|
+
import { createHighlighter as i } from "shiki";
|
|
5
|
+
// src/highlight/shiki.ts
|
|
6
|
+
var a = {
|
|
7
|
+
light: "github-light",
|
|
8
|
+
dark: "github-dark"
|
|
9
|
+
}, o = [
|
|
10
|
+
"bash",
|
|
11
|
+
"css",
|
|
12
|
+
"diff",
|
|
13
|
+
"go",
|
|
14
|
+
"html",
|
|
15
|
+
"javascript",
|
|
16
|
+
"json",
|
|
17
|
+
"markdown",
|
|
18
|
+
"python",
|
|
19
|
+
"rust",
|
|
20
|
+
"shell",
|
|
21
|
+
"sql",
|
|
22
|
+
"tsx",
|
|
23
|
+
"typescript",
|
|
24
|
+
"xml",
|
|
25
|
+
"yaml"
|
|
26
|
+
], s, c;
|
|
27
|
+
function l() {
|
|
28
|
+
return u.apply(this, arguments);
|
|
29
|
+
}
|
|
30
|
+
function u() {
|
|
31
|
+
return u = t(function* () {
|
|
32
|
+
return c || (s || (s = i({
|
|
33
|
+
themes: [a.light, a.dark],
|
|
34
|
+
langs: o
|
|
35
|
+
}).then((e) => (c = e, e))), s);
|
|
36
|
+
}), u.apply(this, arguments);
|
|
37
|
+
}
|
|
38
|
+
function d(e) {
|
|
39
|
+
var t, n, r;
|
|
40
|
+
let i = e[0], a = i == null || (t = i.children) == null ? void 0 : t.find((e) => e.tagName === "pre"), o = a == null || (n = a.children) == null ? void 0 : n.find((e) => e.tagName === "code");
|
|
41
|
+
return (r = o == null ? void 0 : o.children) == null ? [] : r;
|
|
42
|
+
}
|
|
43
|
+
var f = {
|
|
44
|
+
id: "shiki",
|
|
45
|
+
languages: o,
|
|
46
|
+
load: function() {
|
|
47
|
+
var e = t(function* () {
|
|
48
|
+
yield l();
|
|
49
|
+
});
|
|
50
|
+
return function() {
|
|
51
|
+
return e.apply(this, arguments);
|
|
52
|
+
};
|
|
53
|
+
}(),
|
|
54
|
+
loadLanguage(e) {
|
|
55
|
+
return t(function* () {
|
|
56
|
+
let t = yield l();
|
|
57
|
+
t.getLoadedLanguages().includes(e) || (yield t.loadLanguage(e));
|
|
58
|
+
})();
|
|
59
|
+
},
|
|
60
|
+
highlight(t, i, o) {
|
|
61
|
+
var s;
|
|
62
|
+
if (!c) return n(t, i);
|
|
63
|
+
let l = c.getLoadedLanguages().includes(i) ? i : "text", u = (s = o.colorScheme) == null ? o.theme === "dark" ? "dark" : "light" : s, f = c.codeToHast(t, e({
|
|
64
|
+
lang: l,
|
|
65
|
+
themes: a,
|
|
66
|
+
defaultColor: u
|
|
67
|
+
}, o.theme ? { theme: o.theme } : {}));
|
|
68
|
+
return {
|
|
69
|
+
language: l,
|
|
70
|
+
nodes: r(d([f]))
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
export { f as default, f as shiki };
|
|
75
|
+
|
|
76
|
+
//# sourceMappingURL=shiki.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shiki.js","names":["_objectSpread2","plaintextHighlight","highlightedNodesFromHast","THEMES","DEFAULT_LANGUAGES","highlighterPromise","highlighter","getHighlighter","_getHighlighter","_asyncToGenerator","createHighlighter","instance","codeChildren","_root$children","_pre$children","_code$children","root","nodes","pre","node","code","shiki","_ref","language","_options$colorScheme","lang","colorScheme","options"],"sources":["../../src/highlight/shiki.ts"],"sourcesContent":["import { createHighlighter, type Highlighter } from 'shiki'\r\nimport type { MarkdownHighlighter } from '../core/types'\r\nimport { highlightedNodesFromHast, plaintextHighlight } from './shared'\r\n\r\nconst THEMES = {\r\n light: 'github-light',\r\n dark: 'github-dark',\r\n} as const\r\n\r\nconst DEFAULT_LANGUAGES = [\r\n 'bash',\r\n 'css',\r\n 'diff',\r\n 'go',\r\n 'html',\r\n 'javascript',\r\n 'json',\r\n 'markdown',\r\n 'python',\r\n 'rust',\r\n 'shell',\r\n 'sql',\r\n 'tsx',\r\n 'typescript',\r\n 'xml',\r\n 'yaml',\r\n]\r\n\r\nlet highlighterPromise: Promise<Highlighter> | undefined\r\nlet highlighter: Highlighter | undefined\r\n\r\nasync function getHighlighter(): Promise<Highlighter> {\r\n if (highlighter) return highlighter\r\n if (!highlighterPromise) {\r\n highlighterPromise = createHighlighter({\r\n themes: [THEMES.light, THEMES.dark],\r\n langs: DEFAULT_LANGUAGES,\r\n }).then((instance) => {\r\n highlighter = instance\r\n return instance\r\n })\r\n }\r\n return highlighterPromise\r\n}\r\n\r\nfunction codeChildren(nodes: readonly unknown[]): readonly unknown[] {\r\n const root = nodes[0] as { children?: readonly unknown[] } | undefined\r\n const pre = root?.children?.find(\r\n (node) => (node as { tagName?: string }).tagName === 'pre',\r\n ) as { children?: readonly unknown[] } | undefined\r\n const code = pre?.children?.find(\r\n (node) => (node as { tagName?: string }).tagName === 'code',\r\n ) as { children?: readonly unknown[] } | undefined\r\n return code?.children ?? []\r\n}\r\n\r\n/**\r\n * Optional Shiki adapter. The highlighter, themes, and requested languages\r\n * load asynchronously; until then callers see plain text.\r\n */\r\nexport const shiki: MarkdownHighlighter = {\r\n id: 'shiki',\r\n languages: DEFAULT_LANGUAGES,\r\n load: async () => {\r\n await getHighlighter()\r\n },\r\n async loadLanguage(language) {\r\n const instance = await getHighlighter()\r\n if (!instance.getLoadedLanguages().includes(language)) {\r\n await instance.loadLanguage(language as never)\r\n }\r\n },\r\n highlight(code, language, options) {\r\n if (!highlighter) return plaintextHighlight(code, language)\r\n const loaded = highlighter.getLoadedLanguages()\r\n const lang = loaded.includes(language as never) ? language : 'text'\r\n // Keep both theme variants in the token style while making the active\r\n // scheme the concrete color. Normalization preserves that constrained\r\n // style subset, so tokens keep their colors instead of rendering\r\n // monochrome.\r\n const colorScheme =\r\n options.colorScheme ?? (options.theme === 'dark' ? 'dark' : 'light')\r\n const root = highlighter.codeToHast(code, {\r\n lang: lang as never,\r\n themes: THEMES,\r\n defaultColor: colorScheme,\r\n ...(options.theme ? { theme: options.theme as never } : {}),\r\n })\r\n return {\r\n language: lang,\r\n nodes: highlightedNodesFromHast(\r\n codeChildren([root]) as never[],\r\n ),\r\n }\r\n },\r\n}\r\n\r\nexport default shiki\r\n"],"mappings":";;;;;AAIA,IAAMG,IAAS;CACb,OAAO;CACP,MAAM;AACR,GAEMC,IAAoB;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAEIC,GACAC;AAEJ,SAAeC,IAAA;;;;C,OAAuC,IAAAE,EAAA,aAAA;EAWpD,OAVIH,MACCD,MACH,IAAqBK,EAAkB;GACrC,QAAQ,CAACP,EAAO,OAAOA,EAAO,IAAI;GAClC,OAAOC;EACT,CAAC,CAAC,CAAC,MAAM,OACP,IAAcO,GACPA,EACR,IAEIN;CACT,CAAA,G;;AAEA,SAASO,EAAa,GAA+C;;CACnE,IAAMI,IAAOC,EAAM,IACbC,IAAAF,KAAA,SAAA,IAAMA,EAAM,aAAA,OAAA,KAAA,IAAAH,EAAU,MACzB,MAAUM,EAA8B,YAAY,KACvD,GACMC,IAAAF,KAAA,SAAA,IAAOA,EAAK,aAAA,OAAA,KAAA,IAAAJ,EAAU,MACzB,MAAUK,EAA8B,YAAY,MACvD;CACA,QAAA,IAAAC,KAAA,OAAA,KAAA,IAAOA,EAAM,aAAA,OAAY,CAAC,IAAbL;AACf;AAMA,IAAaM,IAA6B;CACxC,IAAI;CACJ,WAAWjB;CACX,MAAA,WAAA;EAAkB,IAAAkB,IAAAb,EAAA,aAAA;GAChB,MAAMF,EAAe;EACvB,CAAA;;;;;CACA,aAAmB,GAAA;EAAU,OAAAE,EAAA,aAAA;GAC3B,IAAME,IAAW,MAAMJ,EAAe;GACtC,AAAKI,EAAS,mBAAmB,CAAC,CAAC,SAASY,CAAQ,MAClD,MAAMZ,EAAS,aAAaY,CAAiB;EAEjD,CAAA,CAAA,CAAA;;CACA,UAAU,GAAM,GAAU,GAAS;;EACjC,IAAI,CAACjB,GAAa,OAAOL,EAAmBmB,GAAMG,CAAQ;EAE1D,IAAME,IADSnB,EAAY,mBACd,CAAA,CAAO,SAASiB,CAAiB,IAAIA,IAAW,QAKvDG,KAAA,IACJC,EAAQ,gBAAA,OAAgBA,EAAQ,UAAU,SAAS,SAAS,UAApDH,GACJR,IAAOV,EAAY,WAAWc,GAAApB,EAAA;GAC5B;GACN,QAAQG;GACR,cAAcuB;EACV,GAAAC,EAAQ,QAAQ,EAAE,OAAOA,EAAQ,MAAe,IAAI,CAAC,CAC3D,CAAC;EACD,OAAO;GACL,UAAUF;GACV,OAAOvB,EACLU,EAAa,CAACI,CAAI,CAAC,CACrB;EACF;CACF;AACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HtmlSchemaExtension, MarkdownPlugin } from '../core/types';
|
|
2
|
+
export interface HtmlPluginOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Add-only extension for the built-in raw HTML sanitizer. Property names use
|
|
5
|
+
* hast casing, for example `srcSet` and `dateTime`.
|
|
6
|
+
*/
|
|
7
|
+
schema?: HtmlSchemaExtension;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Enable sanitized raw HTML in the official pipeline.
|
|
11
|
+
*
|
|
12
|
+
* The plugin contributes `rehype-raw`; the official pipeline runs it before the
|
|
13
|
+
* built-in sanitizer and ignores manual `rehype-raw` entries. Importing this
|
|
14
|
+
* entry is the only supported way to render raw HTML.
|
|
15
|
+
*/
|
|
16
|
+
export declare function htmlPlugin(options?: HtmlPluginOptions): MarkdownPlugin;
|
|
17
|
+
export type { HtmlSchemaExtension };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["rehypeRaw","htmlPlugin","options"],"sources":["../../src/html/index.ts"],"sourcesContent":["import rehypeRaw from 'rehype-raw'\nimport type { HtmlSchemaExtension, MarkdownPlugin } from '../core/types'\n\nexport interface HtmlPluginOptions {\n /**\n * Add-only extension for the built-in raw HTML sanitizer. Property names use\n * hast casing, for example `srcSet` and `dateTime`.\n */\n schema?: HtmlSchemaExtension\n}\n\n/**\n * Enable sanitized raw HTML in the official pipeline.\n *\n * The plugin contributes `rehype-raw`; the official pipeline runs it before the\n * built-in sanitizer and ignores manual `rehype-raw` entries. Importing this\n * entry is the only supported way to render raw HTML.\n */\nexport function htmlPlugin(options: HtmlPluginOptions = {}): MarkdownPlugin {\n return {\n name: 'html',\n html: true,\n htmlSchema: options.schema,\n rehypePlugins: [[rehypeRaw, {}]],\n }\n}\n\nexport type { HtmlSchemaExtension }\n"],"mappings":";;AAkBA,SAAgBC,EAAW,IAA6B,CAAC,GAAmB;CAC1E,OAAO;EACL,MAAM;EACN,MAAM;EACN,YAAYC,EAAQ;EACpB,eAAe,CAAC,CAACF,GAAW,CAAC,CAAC,CAAC;CACjC;AACF"}
|