@canofold/markdown 0.2.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/LICENSE +21 -0
- package/README.md +50 -0
- package/README.zh-CN.md +50 -0
- package/dist/Markdown-DgolXL7g.js +2116 -0
- package/dist/Markdown-iU2W4KgV.js +2116 -0
- package/dist/base.css +2 -0
- package/dist/client/chunks/client-BkvCIcoZ.js +334 -0
- package/dist/client/chunks/client-kVNIqHQd.js +334 -0
- package/dist/client/chunks/gallery-BTg1qJjd.js +40 -0
- package/dist/client/chunks/gallery-q0WKbDeW.js +40 -0
- package/dist/client/chunks/image-BuMCsr5L.js +36 -0
- package/dist/client/chunks/image-_I24969q.js +36 -0
- package/dist/client/chunks/provider-DNSHvvN7.js +841 -0
- package/dist/client/chunks/provider-SSQfNDJA.js +841 -0
- package/dist/client/chunks/react-runtime-Dzgdzn6D.js +10571 -0
- package/dist/client/chunks/serialized-DajnRKXi.js +3464 -0
- package/dist/client/chunks/serialized-T1PzI4rG.js +3464 -0
- package/dist/client/chunks/table-JOSJsHgy.js +30 -0
- package/dist/client/chunks/table-PQvrpt1p.js +30 -0
- package/dist/client/index.js +4 -0
- package/dist/client/nativeBehaviors.d.ts +4 -0
- package/dist/client.d.ts +15 -0
- package/dist/compiler/analyze.d.ts +27 -0
- package/dist/compiler/assets.d.ts +29 -0
- package/dist/compiler/ast.d.ts +68 -0
- package/dist/compiler/createPipeline.d.ts +18 -0
- package/dist/compiler/defaultLabels.d.ts +28 -0
- package/dist/compiler/directiveValidation.d.ts +17 -0
- package/dist/compiler/highlighter.d.ts +3 -0
- package/dist/compiler/mdxModules.d.ts +19 -0
- package/dist/compiler/mdxPlugins.d.ts +16 -0
- package/dist/compiler/normalizeOptions.d.ts +16 -0
- package/dist/compiler/pluginPlan.d.ts +18 -0
- package/dist/compiler/plugins/code.d.ts +16 -0
- package/dist/compiler/plugins/directives.d.ts +24 -0
- package/dist/compiler/plugins/documentBlocks.d.ts +5 -0
- package/dist/compiler/plugins/tables.d.ts +5 -0
- package/dist/compiler/plugins.d.ts +24 -0
- package/dist/compiler/prepareMarkdown.d.ts +11 -0
- package/dist/compiler/sanitizeBoundary.d.ts +18 -0
- package/dist/compiler/stableJson.d.ts +2 -0
- package/dist/compiler/syntaxFeatures.d.ts +10 -0
- package/dist/compiler/types.d.ts +177 -0
- package/dist/components/blocks/MarkdownCodeBlock.d.ts +10 -0
- package/dist/components/blocks/MarkdownCopySnippet.d.ts +10 -0
- package/dist/components/blocks/MarkdownHeading.d.ts +13 -0
- package/dist/components/blocks/MarkdownImage.d.ts +16 -0
- package/dist/components/blocks/MarkdownTable.d.ts +12 -0
- package/dist/components/blocks/MarkdownTerminal.d.ts +9 -0
- package/dist/components/composite/MarkdownComposite.d.ts +37 -0
- package/dist/components/composite/MarkdownFileTree.d.ts +5 -0
- package/dist/components/composite/MarkdownTabs.d.ts +6 -0
- package/dist/components/gallery/ImageGallery.d.ts +25 -0
- package/dist/components/shared/MarkdownActions.d.ts +18 -0
- package/dist/components/shared/MarkdownDialog.d.ts +11 -0
- package/dist/components/shared/MarkdownFileIcon.d.ts +4 -0
- package/dist/components/shared/MarkdownIcon.d.ts +8 -0
- package/dist/components/shared/interactionConstants.d.ts +1 -0
- package/dist/components/shared/reactText.d.ts +14 -0
- package/dist/directiveValidation-CwXRsn5k.js +741 -0
- package/dist/directiveValidation-KWUIIjKw.js +741 -0
- package/dist/file-icons/LICENSE +21 -0
- package/dist/file-icons/astro.svg +1 -0
- package/dist/file-icons/bun.svg +1 -0
- package/dist/file-icons/bun_light.svg +1 -0
- package/dist/file-icons/config.svg +1 -0
- package/dist/file-icons/console.svg +1 -0
- package/dist/file-icons/css.svg +1 -0
- package/dist/file-icons/database.svg +1 -0
- package/dist/file-icons/deno.svg +1 -0
- package/dist/file-icons/deno_light.svg +1 -0
- package/dist/file-icons/diff.svg +1 -0
- package/dist/file-icons/docker.svg +1 -0
- package/dist/file-icons/document.svg +1 -0
- package/dist/file-icons/download.svg +1 -0
- package/dist/file-icons/environment.svg +1 -0
- package/dist/file-icons/excel.svg +1 -0
- package/dist/file-icons/git.svg +1 -0
- package/dist/file-icons/github-actions.svg +1 -0
- package/dist/file-icons/go.svg +1 -0
- package/dist/file-icons/javascript.svg +1 -0
- package/dist/file-icons/json.svg +1 -0
- package/dist/file-icons/markdown.svg +1 -0
- package/dist/file-icons/nodejs.svg +1 -0
- package/dist/file-icons/npm.svg +1 -0
- package/dist/file-icons/pdf.svg +1 -0
- package/dist/file-icons/pnpm.svg +1 -0
- package/dist/file-icons/pnpm_light.svg +1 -0
- package/dist/file-icons/powerpoint.svg +1 -0
- package/dist/file-icons/python.svg +1 -0
- package/dist/file-icons/react.svg +1 -0
- package/dist/file-icons/rust.svg +1 -0
- package/dist/file-icons/sass.svg +1 -0
- package/dist/file-icons/settings.svg +1 -0
- package/dist/file-icons/svelte.svg +1 -0
- package/dist/file-icons/typescript.svg +1 -0
- package/dist/file-icons/vue.svg +1 -0
- package/dist/file-icons/word.svg +1 -0
- package/dist/file-icons/yaml.svg +1 -0
- package/dist/file-icons/yarn.svg +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6 -0
- package/dist/islands/gallery.d.ts +2 -0
- package/dist/islands/image.d.ts +2 -0
- package/dist/islands/options.d.ts +8 -0
- package/dist/islands/provider.d.ts +4 -0
- package/dist/islands/serialized.d.ts +4 -0
- package/dist/islands/table.d.ts +2 -0
- package/dist/islands.d.ts +13 -0
- package/dist/plugins-CeQ-Bo89.js +288 -0
- package/dist/plugins-DQ-VUuCT.js +288 -0
- package/dist/prepareMarkdown-8N-OdLDS.js +852 -0
- package/dist/prepareMarkdown-Bug1ncYk.js +852 -0
- package/dist/protocol/serializedNode.d.ts +3 -0
- package/dist/react/Markdown.d.ts +54 -0
- package/dist/react/componentMap.d.ts +172 -0
- package/dist/react/semanticOverrideProps.d.ts +4 -0
- package/dist/react/slots.d.ts +39 -0
- package/dist/react/urlTransform.d.ts +12 -0
- package/dist/server/analyze.d.ts +6 -0
- package/dist/server/analyze.js +132 -0
- package/dist/server/cache.d.ts +16 -0
- package/dist/server/createMarkdownRenderer.d.ts +39 -0
- package/dist/server.d.ts +5 -0
- package/dist/server.js +137 -0
- package/dist/shared/copyText.d.ts +2 -0
- package/dist/shared/fileKinds.d.ts +6 -0
- package/dist/theme.css +183 -0
- package/dist/theme.d.ts +167 -0
- package/dist/theme.js +228 -0
- package/package.json +110 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { c as l, j as t } from "./react-runtime-Dzgdzn6D.js";
|
|
2
|
+
import { a as s, b as d } from "./serialized-T1PzI4rG.js";
|
|
3
|
+
import { w as b } from "./provider-DNSHvvN7.js";
|
|
4
|
+
function f(a, e) {
|
|
5
|
+
return l.hydrateRoot(
|
|
6
|
+
a,
|
|
7
|
+
b(
|
|
8
|
+
/* @__PURE__ */ t.jsx(
|
|
9
|
+
s,
|
|
10
|
+
{
|
|
11
|
+
className: a.className,
|
|
12
|
+
tableTitle: a.dataset.cfTableTitle,
|
|
13
|
+
copyLabel: a.dataset.cfCopyLabel,
|
|
14
|
+
copyFailureLabel: a.dataset.cfCopyFailureLabel,
|
|
15
|
+
downloadLabel: a.dataset.cfDownloadLabel,
|
|
16
|
+
zoomLabel: a.dataset.cfZoomLabel,
|
|
17
|
+
closeLabel: a.dataset.cfCloseLabel,
|
|
18
|
+
sortLabel: a.dataset.cfSortLabel,
|
|
19
|
+
serializedTable: a.dataset.cfTable,
|
|
20
|
+
inner: !0,
|
|
21
|
+
children: d(a.dataset.cfTable, e)
|
|
22
|
+
}
|
|
23
|
+
),
|
|
24
|
+
e
|
|
25
|
+
)
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
f as hydrate
|
|
30
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { c as l, j as d } from "./react-runtime-Dzgdzn6D.js";
|
|
2
|
+
import { a as t, b as s } from "./serialized-DajnRKXi.js";
|
|
3
|
+
import { w as b } from "./provider-SSQfNDJA.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 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;
|
package/dist/client.d.ts
ADDED
|
@@ -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 Canofold 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 `cf-*` 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,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;
|