@docfuse/markdown 0.1.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.
Files changed (121) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +50 -0
  3. package/README.zh-CN.md +50 -0
  4. package/dist/Markdown-D33gcJbF.js +2116 -0
  5. package/dist/base.css +2 -0
  6. package/dist/client/chunks/client-DIoaSmq2.js +334 -0
  7. package/dist/client/chunks/gallery-BPqV7HsS.js +40 -0
  8. package/dist/client/chunks/image-BGExZy1g.js +36 -0
  9. package/dist/client/chunks/provider-DL6V8F7z.js +841 -0
  10. package/dist/client/chunks/react-runtime-ByABE9MG.js +10571 -0
  11. package/dist/client/chunks/serialized-BvfsNeRQ.js +3464 -0
  12. package/dist/client/chunks/table-DBiKAEbC.js +30 -0
  13. package/dist/client/index.js +4 -0
  14. package/dist/client/nativeBehaviors.d.ts +4 -0
  15. package/dist/client.d.ts +15 -0
  16. package/dist/compiler/analyze.d.ts +27 -0
  17. package/dist/compiler/assets.d.ts +29 -0
  18. package/dist/compiler/ast.d.ts +68 -0
  19. package/dist/compiler/createPipeline.d.ts +18 -0
  20. package/dist/compiler/defaultLabels.d.ts +28 -0
  21. package/dist/compiler/directiveValidation.d.ts +17 -0
  22. package/dist/compiler/highlighter.d.ts +3 -0
  23. package/dist/compiler/mdxModules.d.ts +19 -0
  24. package/dist/compiler/mdxPlugins.d.ts +16 -0
  25. package/dist/compiler/normalizeOptions.d.ts +16 -0
  26. package/dist/compiler/pluginPlan.d.ts +18 -0
  27. package/dist/compiler/plugins/code.d.ts +16 -0
  28. package/dist/compiler/plugins/directives.d.ts +24 -0
  29. package/dist/compiler/plugins/documentBlocks.d.ts +5 -0
  30. package/dist/compiler/plugins/tables.d.ts +5 -0
  31. package/dist/compiler/plugins.d.ts +24 -0
  32. package/dist/compiler/prepareMarkdown.d.ts +11 -0
  33. package/dist/compiler/sanitizeBoundary.d.ts +18 -0
  34. package/dist/compiler/stableJson.d.ts +2 -0
  35. package/dist/compiler/syntaxFeatures.d.ts +10 -0
  36. package/dist/compiler/types.d.ts +177 -0
  37. package/dist/components/blocks/MarkdownCodeBlock.d.ts +10 -0
  38. package/dist/components/blocks/MarkdownCopySnippet.d.ts +10 -0
  39. package/dist/components/blocks/MarkdownHeading.d.ts +13 -0
  40. package/dist/components/blocks/MarkdownImage.d.ts +16 -0
  41. package/dist/components/blocks/MarkdownTable.d.ts +12 -0
  42. package/dist/components/blocks/MarkdownTerminal.d.ts +9 -0
  43. package/dist/components/composite/MarkdownComposite.d.ts +37 -0
  44. package/dist/components/composite/MarkdownFileTree.d.ts +5 -0
  45. package/dist/components/composite/MarkdownTabs.d.ts +6 -0
  46. package/dist/components/gallery/ImageGallery.d.ts +25 -0
  47. package/dist/components/shared/MarkdownActions.d.ts +18 -0
  48. package/dist/components/shared/MarkdownDialog.d.ts +11 -0
  49. package/dist/components/shared/MarkdownFileIcon.d.ts +4 -0
  50. package/dist/components/shared/MarkdownIcon.d.ts +8 -0
  51. package/dist/components/shared/interactionConstants.d.ts +1 -0
  52. package/dist/components/shared/reactText.d.ts +14 -0
  53. package/dist/directiveValidation-BdIao7Yn.js +741 -0
  54. package/dist/file-icons/LICENSE +21 -0
  55. package/dist/file-icons/astro.svg +1 -0
  56. package/dist/file-icons/bun.svg +1 -0
  57. package/dist/file-icons/bun_light.svg +1 -0
  58. package/dist/file-icons/config.svg +1 -0
  59. package/dist/file-icons/console.svg +1 -0
  60. package/dist/file-icons/css.svg +1 -0
  61. package/dist/file-icons/database.svg +1 -0
  62. package/dist/file-icons/deno.svg +1 -0
  63. package/dist/file-icons/deno_light.svg +1 -0
  64. package/dist/file-icons/diff.svg +1 -0
  65. package/dist/file-icons/docker.svg +1 -0
  66. package/dist/file-icons/document.svg +1 -0
  67. package/dist/file-icons/download.svg +1 -0
  68. package/dist/file-icons/environment.svg +1 -0
  69. package/dist/file-icons/excel.svg +1 -0
  70. package/dist/file-icons/git.svg +1 -0
  71. package/dist/file-icons/github-actions.svg +1 -0
  72. package/dist/file-icons/go.svg +1 -0
  73. package/dist/file-icons/javascript.svg +1 -0
  74. package/dist/file-icons/json.svg +1 -0
  75. package/dist/file-icons/markdown.svg +1 -0
  76. package/dist/file-icons/nodejs.svg +1 -0
  77. package/dist/file-icons/npm.svg +1 -0
  78. package/dist/file-icons/pdf.svg +1 -0
  79. package/dist/file-icons/pnpm.svg +1 -0
  80. package/dist/file-icons/pnpm_light.svg +1 -0
  81. package/dist/file-icons/powerpoint.svg +1 -0
  82. package/dist/file-icons/python.svg +1 -0
  83. package/dist/file-icons/react.svg +1 -0
  84. package/dist/file-icons/rust.svg +1 -0
  85. package/dist/file-icons/sass.svg +1 -0
  86. package/dist/file-icons/settings.svg +1 -0
  87. package/dist/file-icons/svelte.svg +1 -0
  88. package/dist/file-icons/typescript.svg +1 -0
  89. package/dist/file-icons/vue.svg +1 -0
  90. package/dist/file-icons/word.svg +1 -0
  91. package/dist/file-icons/yaml.svg +1 -0
  92. package/dist/file-icons/yarn.svg +1 -0
  93. package/dist/index.d.ts +7 -0
  94. package/dist/index.js +6 -0
  95. package/dist/islands/gallery.d.ts +2 -0
  96. package/dist/islands/image.d.ts +2 -0
  97. package/dist/islands/options.d.ts +8 -0
  98. package/dist/islands/provider.d.ts +4 -0
  99. package/dist/islands/serialized.d.ts +4 -0
  100. package/dist/islands/table.d.ts +2 -0
  101. package/dist/islands.d.ts +13 -0
  102. package/dist/plugins-DQ-VUuCT.js +288 -0
  103. package/dist/prepareMarkdown-CHqN2JF5.js +852 -0
  104. package/dist/protocol/serializedNode.d.ts +3 -0
  105. package/dist/react/Markdown.d.ts +54 -0
  106. package/dist/react/componentMap.d.ts +172 -0
  107. package/dist/react/semanticOverrideProps.d.ts +4 -0
  108. package/dist/react/slots.d.ts +39 -0
  109. package/dist/react/urlTransform.d.ts +12 -0
  110. package/dist/server/analyze.d.ts +6 -0
  111. package/dist/server/analyze.js +132 -0
  112. package/dist/server/cache.d.ts +16 -0
  113. package/dist/server/createMarkdownRenderer.d.ts +39 -0
  114. package/dist/server.d.ts +5 -0
  115. package/dist/server.js +137 -0
  116. package/dist/shared/copyText.d.ts +2 -0
  117. package/dist/shared/fileKinds.d.ts +6 -0
  118. package/dist/theme.css +183 -0
  119. package/dist/theme.d.ts +167 -0
  120. package/dist/theme.js +228 -0
  121. package/package.json +110 -0
@@ -0,0 +1,30 @@
1
+ import { c as l, j as d } from "./react-runtime-ByABE9MG.js";
2
+ import { a as t, b as s } from "./serialized-BvfsNeRQ.js";
3
+ import { w as b } from "./provider-DL6V8F7z.js";
4
+ function n(a, e) {
5
+ return l.hydrateRoot(
6
+ a,
7
+ b(
8
+ /* @__PURE__ */ d.jsx(
9
+ t,
10
+ {
11
+ className: a.className,
12
+ tableTitle: a.dataset.dfTableTitle,
13
+ copyLabel: a.dataset.dfCopyLabel,
14
+ copyFailureLabel: a.dataset.dfCopyFailureLabel,
15
+ downloadLabel: a.dataset.dfDownloadLabel,
16
+ zoomLabel: a.dataset.dfZoomLabel,
17
+ closeLabel: a.dataset.dfCloseLabel,
18
+ sortLabel: a.dataset.dfSortLabel,
19
+ serializedTable: a.dataset.dfTable,
20
+ inner: !0,
21
+ children: s(a.dataset.dfTable, e)
22
+ }
23
+ ),
24
+ e
25
+ )
26
+ );
27
+ }
28
+ export {
29
+ n as hydrate
30
+ };
@@ -0,0 +1,4 @@
1
+ import { e as n } from "./chunks/client-DIoaSmq2.js";
2
+ export {
3
+ n as enhanceMarkdown
4
+ };
@@ -0,0 +1,4 @@
1
+ import type { MarkdownBehaviorName } from '../compiler/assets';
2
+ /** Behaviors implemented through reversible delegated DOM enhancement. */
3
+ export declare const NATIVE_MARKDOWN_BEHAVIOR_NAMES: readonly ["code-toolbar", "copy-snippet", "terminal-toolbar", "heading", "tabs", "details", "file-tree"];
4
+ export declare function enhanceNativeMarkdown(root: ParentNode, behaviors: readonly MarkdownBehaviorName[]): () => void;
@@ -0,0 +1,15 @@
1
+ import { type MarkdownAssets } from './compiler/assets';
2
+ export interface MarkdownEnhancement {
3
+ /** Resolves when all requested rich behaviors have loaded. */
4
+ ready: Promise<void>;
5
+ /** Removes native listeners and unmounts rich behavior roots. */
6
+ dispose(): void;
7
+ }
8
+ /**
9
+ * Enhance the semantic Markdown DOM produced by the server renderer.
10
+ *
11
+ * The implementation chooses native DOM behavior or a lazy rich runtime for
12
+ * each resource fact; hosts do not need to know how an interaction is built.
13
+ */
14
+ export declare function enhanceMarkdown(root?: ParentNode, assets?: Pick<MarkdownAssets, 'behaviors'>): MarkdownEnhancement;
15
+ export type { MarkdownAssets, MarkdownBehaviorName } from './compiler/assets';
@@ -0,0 +1,27 @@
1
+ import { type MarkdownDirectiveIssue } from './directiveValidation';
2
+ import type { MarkdownPlugin } from './types';
3
+ export interface MarkdownHeading {
4
+ level: number;
5
+ text: string;
6
+ slug: string;
7
+ }
8
+ export interface MarkdownCodeExample {
9
+ language: string;
10
+ meta?: string;
11
+ code: string;
12
+ }
13
+ export interface MarkdownAnalysis {
14
+ text: string;
15
+ headings: MarkdownHeading[];
16
+ codeExamples: MarkdownCodeExample[];
17
+ links: string[];
18
+ images: string[];
19
+ missingCodeBlockLanguages: number;
20
+ directiveIssues: MarkdownDirectiveIssue[];
21
+ }
22
+ export interface AnalyzeMarkdownOptions {
23
+ /** Plugins whose declared directives should be accepted for this source. */
24
+ plugins?: readonly MarkdownPlugin[];
25
+ }
26
+ /** Parse navigation/search metadata using syntax that is always part of the Markdown core. */
27
+ export declare function analyzeMarkdown(source: string, options?: AnalyzeMarkdownOptions): MarkdownAnalysis;
@@ -0,0 +1,29 @@
1
+ import type { MarkdownPlugin, MarkdownPluginClientAsset, MarkdownPluginStyleAsset } from './types';
2
+ export interface MarkdownAssets {
3
+ /** Browser behaviors required by the rendered document. */
4
+ behaviors: MarkdownBehaviorName[];
5
+ /** Whether the document needs KaTeX CSS and font resources. */
6
+ math: boolean;
7
+ /** Browser entries contributed by active compiler plugins. */
8
+ pluginClients: MarkdownPluginClientAsset[];
9
+ /** Published CSS entries contributed by active compiler plugins. */
10
+ pluginStyles: MarkdownPluginStyleAsset[];
11
+ }
12
+ /** Canonical browser behavior facts shared by the compiler and client runtime. */
13
+ export declare const MARKDOWN_BEHAVIOR_NAMES: readonly ["gallery", "code-toolbar", "copy-snippet", "terminal-toolbar", "table", "image", "heading", "tabs", "details", "file-tree"];
14
+ export type MarkdownBehaviorName = (typeof MARKDOWN_BEHAVIOR_NAMES)[number];
15
+ export interface MarkdownAssetCollector {
16
+ markBehavior(name: MarkdownBehaviorName): void;
17
+ markMath(): void;
18
+ markPluginAssets(plugin: MarkdownPlugin): void;
19
+ snapshot(): MarkdownAssets;
20
+ }
21
+ export declare function createMarkdownAssetCollector(): MarkdownAssetCollector;
22
+ /**
23
+ * Conservative source-level detection for MDX pages.
24
+ *
25
+ * MDX is evaluated by its own compiler, so it cannot reuse the Markdown HAST
26
+ * visitor without first executing trusted JSX. This detector intentionally
27
+ * prefers a false positive over omitting an interaction script.
28
+ */
29
+ export declare function detectMarkdownAssets(source: string, plugins?: readonly MarkdownPlugin[], mode?: 'markdown' | 'mdx'): MarkdownAssets;
@@ -0,0 +1,68 @@
1
+ import type { BlockContent, Data, RootContent } from 'mdast';
2
+ import type { Properties } from 'hast';
3
+ import type { Parent } from 'unist';
4
+ interface TabItemData extends Data {
5
+ tabLabel: string;
6
+ tabLanguage?: string;
7
+ tabValue: string;
8
+ tabIndex: number;
9
+ }
10
+ export interface TabItem extends Parent {
11
+ type: 'tabItem';
12
+ data: TabItemData;
13
+ children: BlockContent[];
14
+ }
15
+ interface TabGroupData extends Data {
16
+ tabGroupLabel: string;
17
+ tabGroupKind: 'tabs' | 'code-group';
18
+ }
19
+ export interface TabGroup extends Parent {
20
+ type: 'tabGroup';
21
+ data: TabGroupData;
22
+ children: TabItem[];
23
+ }
24
+ interface StepItemData extends Data {
25
+ stepTitle: string;
26
+ stepIndex: number;
27
+ }
28
+ export interface StepItem extends Parent {
29
+ type: 'stepItem';
30
+ data: StepItemData;
31
+ children: BlockContent[];
32
+ }
33
+ interface StepGroupData extends Data {
34
+ stepLabel: string;
35
+ }
36
+ export interface StepGroup extends Parent {
37
+ type: 'stepGroup';
38
+ data: StepGroupData;
39
+ children: StepItem[];
40
+ }
41
+ export interface CalloutPart extends Parent {
42
+ type: 'calloutBody' | 'calloutTitle';
43
+ children: RootContent[];
44
+ }
45
+ declare module 'unist' {
46
+ interface Data {
47
+ directiveLabel?: boolean | null;
48
+ hName?: string;
49
+ hProperties?: Properties;
50
+ }
51
+ }
52
+ declare module 'mdast' {
53
+ interface BlockContentMap {
54
+ tabGroup: TabGroup;
55
+ tabItem: TabItem;
56
+ stepGroup: StepGroup;
57
+ stepItem: StepItem;
58
+ calloutPart: CalloutPart;
59
+ }
60
+ interface RootContentMap {
61
+ tabGroup: TabGroup;
62
+ tabItem: TabItem;
63
+ stepGroup: StepGroup;
64
+ stepItem: StepItem;
65
+ calloutPart: CalloutPart;
66
+ }
67
+ }
68
+ export {};
@@ -0,0 +1,18 @@
1
+ import { type Pluggable, type Plugin, type Transformer } from 'unified';
2
+ import type { Root as HastRoot } from 'hast';
3
+ import type { MarkdownAssetCollector } from './assets';
4
+ import type { NormalizedMarkdownOptions } from './normalizeOptions';
5
+ import type { MarkdownSyntaxFeatures } from './syntaxFeatures';
6
+ import type { Options as SanitizeOptions } from 'rehype-sanitize';
7
+ interface CreateMarkdownProcessorOptions {
8
+ assets: MarkdownAssetCollector;
9
+ options: NormalizedMarkdownOptions;
10
+ rehypeRaw?: () => Transformer<HastRoot, HastRoot>;
11
+ rehypeSanitize?: Plugin<[SanitizeOptions?], HastRoot, HastRoot>;
12
+ sanitizeSchema?: SanitizeOptions;
13
+ syntax: MarkdownSyntaxFeatures;
14
+ syntaxHighlighter?: Pluggable;
15
+ }
16
+ /** Assemble Markdown and MDX from the same ordered plugin plan. */
17
+ export declare function createMarkdownProcessor({ assets, options, rehypeRaw, rehypeSanitize, sanitizeSchema, syntax, syntaxHighlighter }: CreateMarkdownProcessorOptions): import("unified").Processor<import("mdast").Root, import("mdast").Root, HastRoot, undefined, undefined>;
18
+ export {};
@@ -0,0 +1,28 @@
1
+ export declare const DEFAULT_MARKDOWN_LABELS: {
2
+ copyCode: string;
3
+ copyFailed: string;
4
+ copySnippet: string;
5
+ copyTerminal: string;
6
+ terminalTitle: string;
7
+ tabsTitle: string;
8
+ tabItem: string;
9
+ codeGroupTitle: string;
10
+ codeGroupItem: string;
11
+ taskCompleted: string;
12
+ taskIncomplete: string;
13
+ copySectionLink: string;
14
+ tableTitle: string;
15
+ copyTableCsv: string;
16
+ downloadTableCsv: string;
17
+ zoomTable: string;
18
+ closeTablePreview: string;
19
+ sortTableColumn: string;
20
+ zoomImage: string;
21
+ closeImagePreview: string;
22
+ imageGallery: string;
23
+ closeImageGallery: string;
24
+ previousGalleryImage: string;
25
+ nextGalleryImage: string;
26
+ galleryThumbnails: string;
27
+ galleryImage: string;
28
+ };
@@ -0,0 +1,17 @@
1
+ import type { Root } from 'mdast';
2
+ import type { Node } from 'unist';
3
+ export interface MarkdownDirectiveIssue {
4
+ message: string;
5
+ line?: number;
6
+ column?: number;
7
+ }
8
+ interface LocatedDirectiveIssue extends MarkdownDirectiveIssue {
9
+ node: Node;
10
+ }
11
+ /** Validate the public Docfuse directive grammar and explicitly declared plugin directives. */
12
+ export declare function collectRichDirectiveIssues(tree: Root, pluginDirectiveNames?: ReadonlySet<string>): LocatedDirectiveIssue[];
13
+ /** Stop rendering malformed core directives before a transform can discard content. */
14
+ export declare const remarkValidateRichDirectives: (pluginDirectiveNames?: ReadonlySet<string>) => (tree: Root, file: {
15
+ fail(message: string, node?: Node): never;
16
+ }) => void;
17
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { Pluggable } from 'unified';
2
+ import type { NormalizedMarkdownOptions } from './normalizeOptions';
3
+ export declare function createSyntaxHighlighterPlugin(codeLanguages: readonly string[], options: NormalizedMarkdownOptions, warnedLanguages?: Set<string>, excludedLanguages?: ReadonlySet<string>): Promise<Pluggable>;
@@ -0,0 +1,19 @@
1
+ export interface MdxImportBinding {
2
+ imported: string;
3
+ local: string;
4
+ namespace?: boolean;
5
+ }
6
+ export interface MdxImportDeclaration {
7
+ specifier: string;
8
+ bindings: MdxImportBinding[];
9
+ }
10
+ export interface MdxModuleBoundary {
11
+ imports: MdxImportDeclaration[];
12
+ sourceWithoutImports: string;
13
+ unsupportedReferences: Array<{
14
+ kind: 'dynamic-import' | 'export-from';
15
+ specifier?: string;
16
+ }>;
17
+ }
18
+ /** Parse only real top-level MDX module syntax, leaving fenced examples intact. */
19
+ export declare function analyzeMdxModuleBoundary(source: string): MdxModuleBoundary;
@@ -0,0 +1,16 @@
1
+ import { type MarkdownAssets } from './assets';
2
+ import type { RenderMarkdownOptions } from './types';
3
+ import type { PluggableList } from 'unified';
4
+ import type { MarkdownHandlers } from './pluginPlan';
5
+ import type { MarkdownCompilerContext } from './prepareMarkdown';
6
+ interface MarkdownMdxPlugins {
7
+ remarkPlugins: PluggableList;
8
+ rehypePlugins: PluggableList;
9
+ remarkRehypeOptions: {
10
+ handlers: MarkdownHandlers;
11
+ };
12
+ getAssets: () => MarkdownAssets;
13
+ }
14
+ /** MDX owns JSX evaluation while sharing Markdown's ordered plugin plan. */
15
+ export declare function createMarkdownMdxPlugins(options?: RenderMarkdownOptions, source?: string, context?: MarkdownCompilerContext): Promise<MarkdownMdxPlugins>;
16
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { LanguageInput, ThemeRegistration } from '@shikijs/types';
2
+ import type { MarkdownFeatureOptions, MarkdownHtmlPolicy, MarkdownLabels, MarkdownPlugin, MarkdownUnknownLanguagePolicy, RenderMarkdownOptions } from './types';
3
+ export interface NormalizedMarkdownOptions {
4
+ htmlPolicy: MarkdownHtmlPolicy;
5
+ codeThemes: {
6
+ light: string | ThemeRegistration;
7
+ dark: string | ThemeRegistration;
8
+ };
9
+ fallbackLanguage: string;
10
+ codeLanguages: Readonly<Record<string, LanguageInput>>;
11
+ unknownLanguage: MarkdownUnknownLanguagePolicy;
12
+ features: Required<MarkdownFeatureOptions>;
13
+ labels: MarkdownLabels;
14
+ plugins: readonly MarkdownPlugin[];
15
+ }
16
+ export declare function normalizeOptions(options?: RenderMarkdownOptions): NormalizedMarkdownOptions;
@@ -0,0 +1,18 @@
1
+ import type { Options as RemarkRehypeOptions } from 'remark-rehype';
2
+ import type { Pluggable, PluggableList } from 'unified';
3
+ import type { MarkdownAssetCollector } from './assets';
4
+ import type { NormalizedMarkdownOptions } from './normalizeOptions';
5
+ import { rehypeStepGroup, rehypeStepItem, rehypeTabGroup, rehypeTabItem } from './plugins/directives';
6
+ import type { MarkdownSyntaxFeatures } from './syntaxFeatures';
7
+ export interface MarkdownPluginPlan {
8
+ remarkPlugins: PluggableList;
9
+ rehypePlugins: PluggableList;
10
+ handlers: MarkdownHandlers;
11
+ }
12
+ export type MarkdownHandlers = NonNullable<RemarkRehypeOptions['handlers']> & {
13
+ tabGroup: typeof rehypeTabGroup;
14
+ tabItem: typeof rehypeTabItem;
15
+ stepGroup: typeof rehypeStepGroup;
16
+ stepItem: typeof rehypeStepItem;
17
+ };
18
+ export declare function createMarkdownPluginPlan(mode: 'markdown' | 'mdx', assets: MarkdownAssetCollector, options: NormalizedMarkdownOptions, syntax: MarkdownSyntaxFeatures, syntaxHighlighter?: Pluggable): MarkdownPluginPlan;
@@ -0,0 +1,16 @@
1
+ import type { Root as HastRoot } from 'hast';
2
+ import type { Root as MdastRoot } from 'mdast';
3
+ import type { MarkdownAssetCollector } from '../assets';
4
+ import type { NormalizedMarkdownOptions } from '../normalizeOptions';
5
+ /** Track explicit React components embedded in trusted MDX. */
6
+ export declare const remarkMdxIslandTracker: (assets: MarkdownAssetCollector) => (tree: MdastRoot) => void;
7
+ /** Preserve fenced block metadata through raw HTML sanitization. */
8
+ export declare const remarkFenceMetadata: (options: NormalizedMarkdownOptions) => (tree: MdastRoot) => void;
9
+ /** Copy authored code titles onto the pre element before Shiki replaces code children. */
10
+ export declare const rehypeFenceMetadata: () => (tree: HastRoot) => void;
11
+ /** Convert special fenced code into serializable inputs for React blocks. */
12
+ export declare const rehypeRichFences: (assets: MarkdownAssetCollector, options: NormalizedMarkdownOptions) => (tree: HastRoot) => void;
13
+ /** Convert rich fences into React components for the MDX recma pipeline. */
14
+ export declare const remarkMdxRichBlocks: (assets: MarkdownAssetCollector, options: NormalizedMarkdownOptions) => (tree: MdastRoot) => void;
15
+ /** Wrap each highlighted code block with a file/language label and copy action. */
16
+ export declare const rehypeCodeBlocks: (assets: MarkdownAssetCollector, labels: NormalizedMarkdownOptions["labels"], excludedLanguages?: ReadonlySet<string>) => (tree: HastRoot) => void;
@@ -0,0 +1,24 @@
1
+ import type { Element, Root as HastRoot } from 'hast';
2
+ import type { Root } from 'mdast';
3
+ import type { State } from 'mdast-util-to-hast';
4
+ import type { NormalizedMarkdownOptions } from '../normalizeOptions';
5
+ import type { StepGroup, StepItem, TabGroup, TabItem } from '../ast';
6
+ /**
7
+ * Keep the authoring interface small: directives describe intent and the
8
+ * compiler owns every `df-*` class, data attribute, slot, and ARIA detail.
9
+ */
10
+ export declare const remarkRichDirectives: () => (tree: Root) => void;
11
+ /** Finish rich directive structure after Markdown has become semantic HTML. */
12
+ export declare const rehypeRichDirectives: () => (tree: HastRoot) => void;
13
+ /** Allow the friendly `:::tip 标题` authoring syntax. */
14
+ export declare function normalizeCallouts(markdown: string): string;
15
+ /** Convert stable Tabs and Code Group directives into the shared tab model. */
16
+ export declare const remarkTabGroups: (options: NormalizedMarkdownOptions) => (tree: Root) => void;
17
+ /** Convert Steps directives into the shared ordered-list visual contract. */
18
+ export declare const remarkSteps: (options: NormalizedMarkdownOptions) => (tree: Root) => void;
19
+ export declare function rehypeStepItem(state: State, node: StepItem): Element;
20
+ export declare function rehypeStepGroup(state: State, node: StepGroup): Element;
21
+ export declare function rehypeTabItem(state: State, node: TabItem): Element;
22
+ export declare function rehypeTabGroup(state: State, node: TabGroup): Element;
23
+ /** Map `:::tip` containers onto the shared callout markup. */
24
+ export declare const remarkCallouts: () => (tree: Root) => void;
@@ -0,0 +1,5 @@
1
+ import type { Root } from 'hast';
2
+ import type { MarkdownAssetCollector } from '../assets';
3
+ import type { NormalizedMarkdownOptions } from '../normalizeOptions';
4
+ /** Add document-level semantics shared by the static and React renderers. */
5
+ export declare const rehypeDocumentBlocks: (assets: MarkdownAssetCollector, labels: NormalizedMarkdownOptions["labels"]) => (tree: Root) => void;
@@ -0,0 +1,5 @@
1
+ import type { Root } from 'hast';
2
+ import type { MarkdownAssetCollector } from '../assets';
3
+ import type { NormalizedMarkdownOptions } from '../normalizeOptions';
4
+ /** Turn GFM tables into a serializable data block; React owns table UI/state. */
5
+ export declare const rehypeTables: (assets: MarkdownAssetCollector, labels: NormalizedMarkdownOptions["labels"]) => (tree: Root) => void;
@@ -0,0 +1,24 @@
1
+ import type { MarkdownPlugin, MarkdownPluginContext } from './types';
2
+ /** Validate plugin names and reject duplicates before the plan consumes them. */
3
+ export declare function normalizeMarkdownPlugins(plugins?: readonly MarkdownPlugin[]): readonly MarkdownPlugin[];
4
+ /**
5
+ * Serializable identity used by render caches and build fingerprints. Plugin
6
+ * functions cannot be fingerprinted, so `name`, `version` and `cacheKey` form
7
+ * the invalidation contract: bump `version` when the transform changes and
8
+ * derive `cacheKey` from resolved options.
9
+ */
10
+ export declare function markdownPluginsIdentity(plugins?: readonly MarkdownPlugin[]): {
11
+ name: string;
12
+ version: string;
13
+ cacheKey: string | number | boolean | import("./types").MarkdownPluginCacheValue[] | {
14
+ [key: string]: import("./types").MarkdownPluginCacheValue;
15
+ } | null;
16
+ }[];
17
+ /** Typed identity helper that validates the plugin shape eagerly. */
18
+ export declare function defineMarkdownPlugin(plugin: MarkdownPlugin): MarkdownPlugin;
19
+ /** Resolve the plugins that apply to one source document. */
20
+ export declare function activeMarkdownPlugins(plugins: readonly MarkdownPlugin[], context: MarkdownPluginContext): readonly MarkdownPlugin[];
21
+ /** Collect normalized fenced-code labels owned by the active plugins. */
22
+ export declare function markdownPluginFenceLanguages(plugins: readonly MarkdownPlugin[]): ReadonlySet<string>;
23
+ /** Collect normalized directive names owned by the active plugins. */
24
+ export declare function markdownPluginDirectiveNames(plugins: readonly MarkdownPlugin[]): ReadonlySet<string>;
@@ -0,0 +1,11 @@
1
+ import type { PreparedMarkdown, RenderMarkdownOptions } from './types';
2
+ export type { MarkdownAssets } from './assets';
3
+ export type { MarkdownCodeOptions, MarkdownFeatureOptions, MarkdownHtmlPolicy, MarkdownLabels, MarkdownPlugin, MarkdownPluginBrowserCompiler, MarkdownPluginCacheValue, MarkdownPluginClientAsset, MarkdownPluginClientResource, MarkdownPluginClientResourceDirectory, MarkdownPluginContext, MarkdownPluginStyleAsset, MarkdownUnknownLanguagePolicy, RenderMarkdownOptions } from './types';
4
+ export interface MarkdownCompilerContext {
5
+ warnedLanguages: Set<string>;
6
+ }
7
+ /**
8
+ * Prepare Markdown as a transformed HAST document for the package's React
9
+ * renderers. This compiler boundary remains internal to the package.
10
+ */
11
+ export declare function prepareMarkdown(source: string, options?: RenderMarkdownOptions, context?: MarkdownCompilerContext): Promise<PreparedMarkdown>;
@@ -0,0 +1,18 @@
1
+ import type { Root } from 'hast';
2
+ import type { Options as SanitizeOptions } from 'rehype-sanitize';
3
+ import type { Plugin } from 'unified';
4
+ export interface CompilerSanitizeBoundary {
5
+ mark: Plugin<[], Root, Root>;
6
+ protect: Plugin<[], Root, Root>;
7
+ restore: Plugin<[], Root, Root>;
8
+ schema: SanitizeOptions;
9
+ }
10
+ /**
11
+ * Preserve trusted compiler contracts while the default rehype schema cleans
12
+ * author HTML. This includes ids generated by remark-rehype: sanitizing those
13
+ * ids a second time would break footnote references. Raw author HTML is not an
14
+ * element until after `mark`, so its ids still receive the sanitizer's clobber
15
+ * prefix. A per-render nonce prevents authored markup from forging the
16
+ * temporary bridge, and only the exact compiler snapshots are restored.
17
+ */
18
+ export declare function createCompilerSanitizeBoundary(defaultSchema: SanitizeOptions): CompilerSanitizeBoundary;
@@ -0,0 +1,2 @@
1
+ /** Deterministic JSON used only for optional cache identities. */
2
+ export declare function stableJson(value: unknown): string | undefined;
@@ -0,0 +1,10 @@
1
+ export interface MarkdownSyntaxFeatures {
2
+ highlightedCode: boolean;
3
+ codeLanguages: readonly string[];
4
+ }
5
+ /**
6
+ * Cheap line scan used to skip transforms that cannot match. Tracking the
7
+ * opening marker prevents fenced examples inside longer fences from being
8
+ * mistaken for real code blocks.
9
+ */
10
+ export declare function detectMarkdownSyntax(source?: string, pluginFenceLanguages?: ReadonlySet<string>): MarkdownSyntaxFeatures;
@@ -0,0 +1,177 @@
1
+ import type { MarkdownAssets } from './assets';
2
+ import type { Root } from 'hast';
3
+ import type { LanguageInput } from '@shikijs/types';
4
+ import type { PluggableList } from 'unified';
5
+ export type MarkdownHtmlPolicy = 'trusted' | 'sanitize' | 'strip';
6
+ export type MarkdownUnknownLanguagePolicy = 'warn' | 'error' | 'plain-text';
7
+ export type MarkdownPluginCacheValue = string | number | boolean | null | MarkdownPluginCacheValue[] | {
8
+ [key: string]: MarkdownPluginCacheValue;
9
+ };
10
+ export interface MarkdownPluginBrowserCompiler {
11
+ /** Browser-safe package export that contains the plugin factory. */
12
+ module: string;
13
+ /** Named factory export, for example `mermaid` or `plantUml`. */
14
+ exportName: string;
15
+ /** JSON-serializable factory options used by browser-side Markdown compilers. */
16
+ options?: MarkdownPluginCacheValue;
17
+ }
18
+ export interface MarkdownCodeOptions {
19
+ themes?: {
20
+ light?: string;
21
+ dark?: string;
22
+ };
23
+ fallbackLanguage?: string;
24
+ /**
25
+ * Additional fence-language loaders keyed by the label authors use after
26
+ * the opening fence. Built-in technical-document languages remain enabled.
27
+ */
28
+ languages?: Readonly<Record<string, LanguageInput>>;
29
+ /** Behavior when neither a built-in nor custom language matches a fence. */
30
+ unknownLanguage?: MarkdownUnknownLanguagePolicy;
31
+ }
32
+ export interface MarkdownFeatureOptions {
33
+ callouts?: boolean;
34
+ tabs?: boolean;
35
+ codeGroups?: boolean;
36
+ steps?: boolean;
37
+ terminals?: boolean;
38
+ documentBlocks?: boolean;
39
+ /** Enhance GFM tables independently from other rich document blocks. */
40
+ tables?: boolean;
41
+ codeBlocks?: boolean;
42
+ }
43
+ export interface MarkdownLabels {
44
+ copyCode: string;
45
+ copyFailed: string;
46
+ copySnippet: string;
47
+ copyTerminal: string;
48
+ terminalTitle: string;
49
+ tabsTitle: string;
50
+ tabItem: string;
51
+ codeGroupTitle: string;
52
+ codeGroupItem: string;
53
+ taskCompleted: string;
54
+ taskIncomplete: string;
55
+ copySectionLink: string;
56
+ tableTitle: string;
57
+ copyTableCsv: string;
58
+ downloadTableCsv: string;
59
+ zoomTable: string;
60
+ closeTablePreview: string;
61
+ sortTableColumn: string;
62
+ zoomImage: string;
63
+ closeImagePreview: string;
64
+ imageGallery: string;
65
+ closeImageGallery: string;
66
+ previousGalleryImage: string;
67
+ nextGalleryImage: string;
68
+ galleryThumbnails: string;
69
+ galleryImage: string;
70
+ }
71
+ /**
72
+ * A build-time trusted compiler plugin. Plugins extend the shared Markdown and
73
+ * MDX pipeline with additional remark (mdast) and rehype (hast) transforms.
74
+ *
75
+ * Plugin functions cannot participate in cache fingerprints, so `name`,
76
+ * `version` and `cacheKey` carry the cache identity instead: bump `version`
77
+ * whenever the transform behavior changes and derive `cacheKey` from the
78
+ * plugin's resolved options.
79
+ */
80
+ export interface MarkdownPlugin {
81
+ /** Unique lowercase kebab-case slug, e.g. "external-links". */
82
+ name: string;
83
+ /** Implementation revision; part of the cache identity. */
84
+ version?: string;
85
+ /** JSON-serializable configuration identity, typically resolved options. */
86
+ cacheKey?: MarkdownPluginCacheValue;
87
+ /**
88
+ * Optional browser compiler entry. Static sites use this only for explicit
89
+ * authoring surfaces such as the Playground; ordinary pages do not load it.
90
+ */
91
+ browserCompiler?: MarkdownPluginBrowserCompiler;
92
+ /** Applied before the core rich-block conversion, before remark-rehype. */
93
+ remarkPlugins?: PluggableList;
94
+ /** Appended after the built-in rehype plugins, at the end of the pipeline. */
95
+ rehypePlugins?: PluggableList;
96
+ /**
97
+ * Fenced-code language labels consumed by this plugin's remark transforms.
98
+ * Declaring them prevents the core Shiki loader from treating plugin-owned
99
+ * fences as ordinary code or reporting them as unsupported languages.
100
+ */
101
+ fenceLanguages?: readonly string[];
102
+ /**
103
+ * Directive names owned by this plugin. Undeclared directive names are
104
+ * rejected so author typos cannot silently degrade to generic HTML.
105
+ */
106
+ directiveNames?: readonly string[];
107
+ /**
108
+ * Optional source-level activation gate. Use this for expensive opt-in
109
+ * syntax so ordinary documents do not load or run the plugin.
110
+ */
111
+ appliesTo?: (context: MarkdownPluginContext) => boolean;
112
+ /** Static assets required whenever this plugin is active for a document. */
113
+ assets?: {
114
+ math?: boolean;
115
+ /** Browser entry points loaded only for pages that activate this plugin. */
116
+ clients?: readonly MarkdownPluginClientAsset[];
117
+ /** Published CSS entry points appended only for pages that activate this plugin. */
118
+ styles?: readonly MarkdownPluginStyleAsset[];
119
+ };
120
+ }
121
+ export interface MarkdownPluginClientAsset {
122
+ /** Stable identifier used for output naming and de-duplication. */
123
+ id: string;
124
+ /** Public package export, for example `@scope/plugin/client`. */
125
+ module: string;
126
+ /** Extra package files copied beside this client under a directory named after `id`. */
127
+ resources?: readonly MarkdownPluginClientResource[];
128
+ }
129
+ export interface MarkdownPluginClientResourceDirectory {
130
+ /** Directory relative to the resource entry point. Parent traversal is rejected. */
131
+ source: string;
132
+ /** Output directory relative to this client's resource directory. */
133
+ output: string;
134
+ /** Optional file suffix allowlist, for example `[".mjs"]`. */
135
+ extensions?: readonly string[];
136
+ }
137
+ export interface MarkdownPluginClientResource {
138
+ /** Package export resolved from the client asset's owning package. */
139
+ module: string;
140
+ /** Output file relative to this client's resource directory. */
141
+ output: string;
142
+ /** Chunk directories located beside the resolved resource entry. */
143
+ directories?: readonly MarkdownPluginClientResourceDirectory[];
144
+ }
145
+ export interface MarkdownPluginStyleAsset {
146
+ /** Stable identifier used for output naming and de-duplication. */
147
+ id: string;
148
+ /** Public package export, for example `@docfuse/plugins/diagram.css`. */
149
+ module: string;
150
+ }
151
+ export interface MarkdownPluginContext {
152
+ source: string;
153
+ mode: 'markdown' | 'mdx';
154
+ }
155
+ export interface RenderMarkdownOptions {
156
+ /**
157
+ * Raw HTML policy for markdown input.
158
+ *
159
+ * `trusted` preserves inline HTML and is intended for build-time docs content.
160
+ * `sanitize` parses HTML and removes unsafe elements, attributes and URLs.
161
+ * `strip` disables raw HTML parsing entirely.
162
+ * MDX remains executable trusted code and does not support safe HTML modes.
163
+ */
164
+ html?: MarkdownHtmlPolicy;
165
+ code?: MarkdownCodeOptions;
166
+ features?: MarkdownFeatureOptions;
167
+ labels?: Partial<MarkdownLabels>;
168
+ /** BCP 47 locale exposed to compiler plugins for locale-aware output. */
169
+ locale?: string;
170
+ /** Compiler plugins applied to both the Markdown and MDX pipelines. */
171
+ plugins?: readonly MarkdownPlugin[];
172
+ }
173
+ /** Serializable HAST output before HTML stringification. */
174
+ export interface PreparedMarkdown {
175
+ document: Root;
176
+ assets: MarkdownAssets;
177
+ }
@@ -0,0 +1,10 @@
1
+ import { type HTMLAttributes, type ReactNode } from 'react';
2
+ export interface MarkdownCodeBlockProps extends Omit<HTMLAttributes<HTMLElement>, 'children'> {
3
+ children?: ReactNode;
4
+ language?: string;
5
+ filename?: string;
6
+ source?: string;
7
+ copyLabel?: string;
8
+ copyFailureLabel?: string;
9
+ }
10
+ export declare function MarkdownCodeBlock({ children, source: directSource, language: directLanguage, filename: directFilename, copyLabel: directCopyLabel, copyFailureLabel: directCopyFailureLabel, ...inputProps }: MarkdownCodeBlockProps): import("react").JSX.Element;