fumadocs-core 16.9.0 → 16.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{algolia-D56Eex2h.d.ts → algolia-Dy_nhfqJ.d.ts} +1 -1
- package/dist/breadcrumb.d.ts +1 -1
- package/dist/{client-D6TKpTxv.d.ts → client-CjDMTbRr.d.ts} +3 -3
- package/dist/content/mdx/preset-bundler.d.ts +7 -7
- package/dist/content/mdx/preset-runtime.d.ts +7 -7
- package/dist/content/toc.d.ts +1 -1
- package/dist/{definitions-Cob-Q8-8.d.ts → definitions-DQRPsvc7.d.ts} +7 -4
- package/dist/highlight/shiki/full.d.ts +1 -1
- package/dist/highlight/shiki/index.d.ts +1 -1
- package/dist/highlight/shiki/react.d.ts +2 -2
- package/dist/i18n/index.d.ts +1 -1
- package/dist/i18n/index.js +29 -5
- package/dist/i18n/middleware.d.ts +1 -1
- package/dist/{index-CKvjS08M2.d.ts → index-C7Im4R_D2.d.ts} +8 -7
- package/dist/{index-DzLmtQFW.d.ts → index-CFaAAU5K.d.ts} +1 -1
- package/dist/{index-D2f_P1Zo.d.ts → index-D36IQyWl.d.ts} +1 -1
- package/dist/{index-DRvW7IXg.d.ts → index-L7sAY8Os.d.ts} +1 -1
- package/dist/{index-YTOeewZk.d.ts → index-iV26Yxbg.d.ts} +4 -2
- package/dist/{loader-DWaWaGZg.js → loader-AC1aN-MX.js} +88 -60
- package/dist/mdx-plugins/codeblock-utils.d.ts +1 -1
- package/dist/mdx-plugins/index.d.ts +17 -16
- package/dist/mdx-plugins/index.js +2 -1
- package/dist/mdx-plugins/rehype-code.core.d.ts +2 -1
- package/dist/mdx-plugins/rehype-code.core.js +2 -1
- package/dist/mdx-plugins/rehype-code.d.ts +3 -2
- package/dist/mdx-plugins/rehype-code.js +2 -1
- package/dist/mdx-plugins/rehype-toc.d.ts +1 -1
- package/dist/mdx-plugins/remark-admonition.d.ts +1 -1
- package/dist/mdx-plugins/remark-code-tab.d.ts +1 -1
- package/dist/mdx-plugins/remark-directive-admonition.d.ts +1 -1
- package/dist/mdx-plugins/remark-feedback-block.d.ts +1 -1
- package/dist/mdx-plugins/remark-heading.d.ts +1 -1
- package/dist/mdx-plugins/remark-image.d.ts +1 -1
- package/dist/mdx-plugins/remark-llms.d.ts +1 -1
- package/dist/mdx-plugins/remark-llms.runtime.d.ts +1 -1
- package/dist/mdx-plugins/remark-mdx-files.d.ts +1 -1
- package/dist/mdx-plugins/remark-mdx-mermaid.d.ts +1 -1
- package/dist/mdx-plugins/remark-npm.d.ts +1 -1
- package/dist/mdx-plugins/remark-steps.d.ts +1 -1
- package/dist/mdx-plugins/remark-structure.d.ts +1 -1
- package/dist/mdx-plugins/stringifier.d.ts +1 -1
- package/dist/mdx-plugins/transformer-icon.d.ts +2 -0
- package/dist/{rehype-code.core-D2jcAuJI.js → mdx-plugins/transformer-icon.js} +1 -521
- package/dist/page-tree/index.d.ts +2 -2
- package/dist/{rehype-code-DXCf4vCa.d.ts → rehype-code-x0ZobImp.d.ts} +1 -1
- package/dist/{rehype-code.core-BZyEKRRx.d.ts → rehype-code.core--x00T7TS.d.ts} +4 -18
- package/dist/rehype-code.core-DejBJh_Q.js +527 -0
- package/dist/{remark-heading-BkmtL7mJ.d.ts → remark-heading-D2b5W0U-.d.ts} +1 -1
- package/dist/{remark-llms-CC6AjEDH.d.ts → remark-llms-Djf4WpEV.d.ts} +1 -1
- package/dist/{remark-structure-C2-K9_ko.d.ts → remark-structure-D5lZwhf5.d.ts} +1 -1
- package/dist/search/algolia.d.ts +1 -1
- package/dist/search/client/algolia.d.ts +1 -1
- package/dist/search/client/fetch.d.ts +1 -1
- package/dist/search/client/flexsearch-static.d.ts +1 -1
- package/dist/search/client/mixedbread.d.ts +1 -1
- package/dist/search/client/orama-cloud-legacy.d.ts +1 -1
- package/dist/search/client/orama-cloud.d.ts +1 -1
- package/dist/search/client/orama-static.d.ts +1 -1
- package/dist/search/client.d.ts +1 -1
- package/dist/search/flexsearch.d.ts +4 -4
- package/dist/search/index.d.ts +1 -1
- package/dist/search/mixedbread.d.ts +2 -2
- package/dist/search/orama-cloud-legacy.d.ts +1 -1
- package/dist/search/orama-cloud.d.ts +1 -1
- package/dist/search/server.d.ts +1 -1
- package/dist/{server-BmBBtKX6.d.ts → server-DkUTyWt-.d.ts} +5 -5
- package/dist/source/client/index.d.ts +1 -1
- package/dist/source/dynamic.d.ts +1 -1
- package/dist/source/dynamic.js +1 -1
- package/dist/source/index.d.ts +1 -1
- package/dist/source/index.js +1 -1
- package/dist/source/llms.d.ts +1 -1
- package/dist/source/plugins/lucide-icons.d.ts +1 -1
- package/dist/source/plugins/slugs.d.ts +1 -1
- package/dist/source/plugins/status-badges.d.ts +2 -2
- package/dist/source/schema.d.ts +1 -0
- package/dist/source/schema.js +2 -0
- package/dist/toc.d.ts +1 -1
- package/dist/transformer-icon-DxbdvNM7.d.ts +18 -0
- package/package.json +9 -8
- /package/dist/{codeblock-utils-BFx9G8T-.d.ts → codeblock-utils-Cu2hs3HP.d.ts} +0 -0
- /package/dist/{index-qM4PwHTs.d.ts → index-Dw5cCt-A.d.ts} +0 -0
- /package/dist/{index-Bcms_L7o.d.ts → index-Yi-xJspv.d.ts} +0 -0
- /package/dist/{rehype-toc-D5_U8iEU.d.ts → rehype-toc-S6N-sHdy.d.ts} +0 -0
- /package/dist/{remark-admonition-Do12F5_K.d.ts → remark-admonition-CgSEZPK6.d.ts} +0 -0
- /package/dist/{remark-code-tab-Ct56s_uQ.d.ts → remark-code-tab-d-IsnJUp.d.ts} +0 -0
- /package/dist/{remark-directive-admonition-WTw742i0.d.ts → remark-directive-admonition-B2K0zXhU.d.ts} +0 -0
- /package/dist/{remark-feedback-block-CF-ABTc-.d.ts → remark-feedback-block-l4uW7jta.d.ts} +0 -0
- /package/dist/{remark-image-B8S2Lk0J.d.ts → remark-image-CLCoFL38.d.ts} +0 -0
- /package/dist/{remark-mdx-files-DXcBGoX9.d.ts → remark-mdx-files-ulgvmf4K.d.ts} +0 -0
- /package/dist/{remark-mdx-mermaid-CQU6XhYd.d.ts → remark-mdx-mermaid-CcK-F03B.d.ts} +0 -0
- /package/dist/{remark-npm-BZsXR24w.d.ts → remark-npm-DRJJDIR0.d.ts} +0 -0
- /package/dist/{remark-steps-BcG9tJSi.d.ts → remark-steps-Q_rsCX_o.d.ts} +0 -0
- /package/dist/{stringifier-B_MrdMwd.d.ts → stringifier-beK5yGbT.d.ts} +0 -0
- /package/dist/{toc-B04VAipv.d.ts → toc-De7dlxnI.d.ts} +0 -0
- /package/dist/{types-DpbpliNk.d.ts → types-FiLV8L2L.d.ts} +0 -0
- /package/dist/{util-CaBjK5m2.d.ts → util-Ds0K_QFY.d.ts} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as remarkAdmonition, t as RemarkAdmonitionOptions } from "../remark-admonition-
|
|
1
|
+
import { n as remarkAdmonition, t as RemarkAdmonitionOptions } from "../remark-admonition-CgSEZPK6.js";
|
|
2
2
|
export { RemarkAdmonitionOptions, remarkAdmonition };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as remarkCodeTab, t as RemarkCodeTabOptions } from "../remark-code-tab-
|
|
1
|
+
import { n as remarkCodeTab, t as RemarkCodeTabOptions } from "../remark-code-tab-d-IsnJUp.js";
|
|
2
2
|
export { RemarkCodeTabOptions, remarkCodeTab };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as remarkDirectiveAdmonition, t as RemarkDirectiveAdmonitionOptions } from "../remark-directive-admonition-
|
|
1
|
+
import { n as remarkDirectiveAdmonition, t as RemarkDirectiveAdmonitionOptions } from "../remark-directive-admonition-B2K0zXhU.js";
|
|
2
2
|
export { RemarkDirectiveAdmonitionOptions, remarkDirectiveAdmonition };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as RemarkFeedbackBlockOptions, r as remarkFeedbackBlock, t as FeedbackBlockProps } from "../remark-feedback-block-
|
|
1
|
+
import { n as RemarkFeedbackBlockOptions, r as remarkFeedbackBlock, t as FeedbackBlockProps } from "../remark-feedback-block-l4uW7jta.js";
|
|
2
2
|
export { FeedbackBlockProps, RemarkFeedbackBlockOptions, remarkFeedbackBlock };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as remarkHeading, t as RemarkHeadingOptions } from "../remark-heading-
|
|
1
|
+
import { n as remarkHeading, t as RemarkHeadingOptions } from "../remark-heading-D2b5W0U-.js";
|
|
2
2
|
export { RemarkHeadingOptions, remarkHeading };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as remarkImage, t as RemarkImageOptions } from "../remark-image-
|
|
1
|
+
import { n as remarkImage, t as RemarkImageOptions } from "../remark-image-CLCoFL38.js";
|
|
2
2
|
export { RemarkImageOptions, remarkImage };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as placeholder, r as remarkLLMs, t as LLMsOptions } from "../remark-llms-
|
|
1
|
+
import { n as placeholder, r as remarkLLMs, t as LLMsOptions } from "../remark-llms-Djf4WpEV.js";
|
|
2
2
|
export { LLMsOptions, placeholder, remarkLLMs };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as remarkMdxFiles, i as ToMdxOptions, n as FolderNode, r as RemarkMdxFilesOptions, t as FileNode } from "../remark-mdx-files-
|
|
1
|
+
import { a as remarkMdxFiles, i as ToMdxOptions, n as FolderNode, r as RemarkMdxFilesOptions, t as FileNode } from "../remark-mdx-files-ulgvmf4K.js";
|
|
2
2
|
export { FileNode, FolderNode, RemarkMdxFilesOptions, ToMdxOptions, remarkMdxFiles };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as remarkMdxMermaid, t as RemarkMdxMermaidOptions } from "../remark-mdx-mermaid-
|
|
1
|
+
import { n as remarkMdxMermaid, t as RemarkMdxMermaidOptions } from "../remark-mdx-mermaid-CcK-F03B.js";
|
|
2
2
|
export { RemarkMdxMermaidOptions, remarkMdxMermaid };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as remarkNpm, t as RemarkNpmOptions } from "../remark-npm-
|
|
1
|
+
import { n as remarkNpm, t as RemarkNpmOptions } from "../remark-npm-DRJJDIR0.js";
|
|
2
2
|
export { RemarkNpmOptions, remarkNpm };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as remarkSteps, t as RemarkStepsOptions } from "../remark-steps-
|
|
1
|
+
import { n as remarkSteps, t as RemarkStepsOptions } from "../remark-steps-Q_rsCX_o.js";
|
|
2
2
|
export { RemarkStepsOptions, remarkSteps };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as defaultStringifier, c as structure, i as StructuredData, n as StringifyOptions, o as remarkStructure, r as StructureOptions, s as remarkStructureDefaultOptions, t as Stringifier } from "../remark-structure-
|
|
1
|
+
import { a as defaultStringifier, c as structure, i as StructuredData, n as StringifyOptions, o as remarkStructure, r as StructureOptions, s as remarkStructureDefaultOptions, t as Stringifier } from "../remark-structure-D5lZwhf5.js";
|
|
2
2
|
export { Stringifier, StringifyOptions, StructureOptions, StructuredData, defaultStringifier, remarkStructure, remarkStructureDefaultOptions, structure };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as StringifyOptions, r as defaultStringifier, t as Stringifier } from "../stringifier-
|
|
1
|
+
import { n as StringifyOptions, r as defaultStringifier, t as Stringifier } from "../stringifier-beK5yGbT.js";
|
|
2
2
|
export { Stringifier, StringifyOptions, defaultStringifier };
|
|
@@ -1,440 +1,3 @@
|
|
|
1
|
-
import { n as flattenNodeHast } from "./utils-pSG8hSr9.js";
|
|
2
|
-
import { n as defaultThemes, r as getRequiredThemes } from "./utils-tAukrbtB.js";
|
|
3
|
-
import { parseCodeBlockAttributes } from "./mdx-plugins/codeblock-utils.js";
|
|
4
|
-
import { visit } from "unist-util-visit";
|
|
5
|
-
import { isSpecialLang } from "shiki/core";
|
|
6
|
-
//#region src/mdx-plugins/rehype-code/parsers.ts
|
|
7
|
-
const RE_TAILING_CURLY_COLON = /(.+)\{:([\w-]+)\}$/;
|
|
8
|
-
const InlineCodeParsers = { "tailing-curly-colon": (_tree, node) => {
|
|
9
|
-
const raw = flattenNodeHast(node);
|
|
10
|
-
const match = raw.match(RE_TAILING_CURLY_COLON);
|
|
11
|
-
if (!match) return;
|
|
12
|
-
return {
|
|
13
|
-
structure: "inline",
|
|
14
|
-
code: match[1] ?? raw,
|
|
15
|
-
lang: match.at(2)
|
|
16
|
-
};
|
|
17
|
-
} };
|
|
18
|
-
const languagePrefix = "language-";
|
|
19
|
-
const PreParser = (_tree, node) => {
|
|
20
|
-
const head = node.children[0];
|
|
21
|
-
if (!head || head.type !== "element" || head.tagName !== "code" || !head.properties) return;
|
|
22
|
-
const classes = head.properties.className;
|
|
23
|
-
const languageClass = Array.isArray(classes) ? classes.find((d) => typeof d === "string" && d.startsWith(languagePrefix)) : void 0;
|
|
24
|
-
return {
|
|
25
|
-
structure: "classic",
|
|
26
|
-
lang: typeof languageClass === "string" ? languageClass.slice(9) : void 0,
|
|
27
|
-
code: flattenNodeHast(head),
|
|
28
|
-
meta: head.data?.meta ?? head.properties.metastring?.toString() ?? ""
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/mdx-plugins/rehype-code/shiki.ts
|
|
33
|
-
function rehypeShikiFromHighlighter(highlighter, options) {
|
|
34
|
-
const { addLanguageClass = false, parseMetaString, filterMetaString, cache, defaultLanguage, fallbackLanguage, onError, stripEndNewline = true, inline = false, lazy = true, ...rest } = options;
|
|
35
|
-
function isLanguageLoaded(lang) {
|
|
36
|
-
return isSpecialLang(lang) || highlighter.getLoadedLanguages().includes(lang);
|
|
37
|
-
}
|
|
38
|
-
async function onNode(tree, node, parsed) {
|
|
39
|
-
let { meta: metaString = "", lang = defaultLanguage, code } = parsed;
|
|
40
|
-
if (!lang) return;
|
|
41
|
-
if (!isLanguageLoaded(lang)) {
|
|
42
|
-
if (lazy && lang in highlighter.getBundledLanguages()) await highlighter.loadLanguage(lang);
|
|
43
|
-
else if (fallbackLanguage) {
|
|
44
|
-
lang = fallbackLanguage;
|
|
45
|
-
if (!isLanguageLoaded(fallbackLanguage)) await highlighter.loadLanguage(fallbackLanguage);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (filterMetaString) metaString = filterMetaString(metaString);
|
|
49
|
-
const cacheKey = `${lang}:${metaString}:${code}`;
|
|
50
|
-
const cachedValue = cache?.get(cacheKey);
|
|
51
|
-
if (cachedValue) return cachedValue;
|
|
52
|
-
const transformers = rest.transformers ? [...rest.transformers] : [];
|
|
53
|
-
let _fd_postprocess;
|
|
54
|
-
transformers.push({
|
|
55
|
-
enforce: "post",
|
|
56
|
-
root() {
|
|
57
|
-
_fd_postprocess = this.meta._fd_postprocess;
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
if (addLanguageClass) transformers.push(transformerAddLanguage(lang));
|
|
61
|
-
const codeOptions = {
|
|
62
|
-
...rest,
|
|
63
|
-
lang,
|
|
64
|
-
structure: parsed.structure,
|
|
65
|
-
transformers,
|
|
66
|
-
meta: {
|
|
67
|
-
...rest.meta,
|
|
68
|
-
__raw: metaString,
|
|
69
|
-
...parseMetaString?.(metaString, node, tree)
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
if (stripEndNewline && code.endsWith("\n")) code = code.slice(0, -1);
|
|
73
|
-
const fragment = highlighter.codeToHast(code, codeOptions);
|
|
74
|
-
if (_fd_postprocess && _fd_postprocess.length > 0) {
|
|
75
|
-
const ctx = { highlighter };
|
|
76
|
-
await Promise.all(_fd_postprocess.map((v) => v(ctx)));
|
|
77
|
-
}
|
|
78
|
-
cache?.set(cacheKey, fragment);
|
|
79
|
-
if (parsed.structure === "classic") return fragment;
|
|
80
|
-
return {
|
|
81
|
-
type: "element",
|
|
82
|
-
tagName: "code",
|
|
83
|
-
properties: { class: "shiki" },
|
|
84
|
-
children: fragment.children
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
return async (tree) => {
|
|
88
|
-
const queue = [];
|
|
89
|
-
visit(tree, "element", (node, index, parent) => {
|
|
90
|
-
let parsed;
|
|
91
|
-
if (!parent || index == null) return;
|
|
92
|
-
if (node.tagName === "pre") parsed = PreParser(tree, node);
|
|
93
|
-
else if (node.tagName === "code" && inline) parsed = InlineCodeParsers[inline](tree, node);
|
|
94
|
-
else return;
|
|
95
|
-
if (!parsed) return "skip";
|
|
96
|
-
queue.push(onNode(tree, node, parsed).then((fragment) => {
|
|
97
|
-
if (fragment) parent.children[index] = fragment;
|
|
98
|
-
}).catch((error) => {
|
|
99
|
-
if (onError) onError(error);
|
|
100
|
-
else throw error;
|
|
101
|
-
}));
|
|
102
|
-
return "skip";
|
|
103
|
-
});
|
|
104
|
-
if (queue.length > 0) await Promise.all(queue);
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
function transformerAddLanguage(lang) {
|
|
108
|
-
return {
|
|
109
|
-
name: "rehype-shiki:code-language-class",
|
|
110
|
-
code(node) {
|
|
111
|
-
this.addClassToHast(node, `language-${lang}`);
|
|
112
|
-
return node;
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
//#endregion
|
|
117
|
-
//#region ../../node_modules/.pnpm/@shikijs+transformers@4.0.2/node_modules/@shikijs/transformers/dist/index.mjs
|
|
118
|
-
/**
|
|
119
|
-
* some comment formats have to be located at the end of line
|
|
120
|
-
* hence we can skip matching them for other tokens
|
|
121
|
-
*/
|
|
122
|
-
const matchers = [
|
|
123
|
-
[/^(<!--)(.+)(-->)$/, false],
|
|
124
|
-
[/^(\/\*)(.+)(\*\/)$/, false],
|
|
125
|
-
[/^(\/\/|["'#]|;{1,2}|%{1,2}|--)(.*)$/, true],
|
|
126
|
-
[/^(\*)(.+)$/, true]
|
|
127
|
-
];
|
|
128
|
-
/**
|
|
129
|
-
* @param lines line tokens
|
|
130
|
-
* @param jsx enable JSX parsing
|
|
131
|
-
* @param matchAlgorithm matching algorithm
|
|
132
|
-
*/
|
|
133
|
-
function parseComments(lines, jsx, matchAlgorithm) {
|
|
134
|
-
const out = [];
|
|
135
|
-
for (const line of lines) {
|
|
136
|
-
if (matchAlgorithm === "v3") {
|
|
137
|
-
const splittedElements = line.children.flatMap((element, idx) => {
|
|
138
|
-
if (element.type !== "element") return element;
|
|
139
|
-
const token = element.children[0];
|
|
140
|
-
if (token.type !== "text") return element;
|
|
141
|
-
const isLast = idx === line.children.length - 1;
|
|
142
|
-
if (!matchToken(token.value, isLast)) return element;
|
|
143
|
-
const rawSplits = token.value.split(/(\s+\/\/)/);
|
|
144
|
-
if (rawSplits.length <= 1) return element;
|
|
145
|
-
let splits = [rawSplits[0]];
|
|
146
|
-
for (let i = 1; i < rawSplits.length; i += 2) splits.push(rawSplits[i] + (rawSplits[i + 1] || ""));
|
|
147
|
-
splits = splits.filter(Boolean);
|
|
148
|
-
if (splits.length <= 1) return element;
|
|
149
|
-
return splits.map((split) => {
|
|
150
|
-
return {
|
|
151
|
-
...element,
|
|
152
|
-
children: [{
|
|
153
|
-
type: "text",
|
|
154
|
-
value: split
|
|
155
|
-
}]
|
|
156
|
-
};
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
if (splittedElements.length !== line.children.length) line.children = splittedElements;
|
|
160
|
-
}
|
|
161
|
-
const elements = line.children;
|
|
162
|
-
let start = elements.length - 1;
|
|
163
|
-
if (matchAlgorithm === "v1") start = 0;
|
|
164
|
-
else if (jsx) start = elements.length - 2;
|
|
165
|
-
for (let i = Math.max(start, 0); i < elements.length; i++) {
|
|
166
|
-
const token = elements[i];
|
|
167
|
-
if (token.type !== "element") continue;
|
|
168
|
-
const head = token.children.at(0);
|
|
169
|
-
if (head?.type !== "text") continue;
|
|
170
|
-
const isLast = i === elements.length - 1;
|
|
171
|
-
let match = matchToken(head.value, isLast);
|
|
172
|
-
let additionalTokens;
|
|
173
|
-
if (!match && i > 0 && head.value.trim().startsWith("[!code")) {
|
|
174
|
-
const prevToken = elements[i - 1];
|
|
175
|
-
if (prevToken?.type === "element") {
|
|
176
|
-
const prevHead = prevToken.children.at(0);
|
|
177
|
-
if (prevHead?.type === "text" && prevHead.value.includes("//")) {
|
|
178
|
-
const combinedMatch = matchToken(prevHead.value + head.value, isLast);
|
|
179
|
-
if (combinedMatch) {
|
|
180
|
-
match = combinedMatch;
|
|
181
|
-
out.push({
|
|
182
|
-
info: combinedMatch,
|
|
183
|
-
line,
|
|
184
|
-
token: prevToken,
|
|
185
|
-
isLineCommentOnly: elements.length === 2 && prevToken.children.length === 1 && token.children.length === 1,
|
|
186
|
-
isJsxStyle: false,
|
|
187
|
-
additionalTokens: [token]
|
|
188
|
-
});
|
|
189
|
-
continue;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
if (!match) continue;
|
|
195
|
-
if (jsx && !isLast && i !== 0) {
|
|
196
|
-
const isJsxStyle = isValue(elements[i - 1], "{") && isValue(elements[i + 1], "}");
|
|
197
|
-
out.push({
|
|
198
|
-
info: match,
|
|
199
|
-
line,
|
|
200
|
-
token,
|
|
201
|
-
isLineCommentOnly: elements.length === 3 && token.children.length === 1,
|
|
202
|
-
isJsxStyle,
|
|
203
|
-
additionalTokens
|
|
204
|
-
});
|
|
205
|
-
} else out.push({
|
|
206
|
-
info: match,
|
|
207
|
-
line,
|
|
208
|
-
token,
|
|
209
|
-
isLineCommentOnly: elements.length === 1 && token.children.length === 1,
|
|
210
|
-
isJsxStyle: false,
|
|
211
|
-
additionalTokens
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
return out;
|
|
216
|
-
}
|
|
217
|
-
function isValue(element, value) {
|
|
218
|
-
if (element.type !== "element") return false;
|
|
219
|
-
const text = element.children[0];
|
|
220
|
-
if (text.type !== "text") return false;
|
|
221
|
-
return text.value.trim() === value;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* @param text text value of comment node
|
|
225
|
-
* @param isLast whether the token is located at the end of line
|
|
226
|
-
*/
|
|
227
|
-
function matchToken(text, isLast) {
|
|
228
|
-
let trimmed = text.trimStart();
|
|
229
|
-
const spaceFront = text.length - trimmed.length;
|
|
230
|
-
trimmed = trimmed.trimEnd();
|
|
231
|
-
const spaceEnd = text.length - trimmed.length - spaceFront;
|
|
232
|
-
for (const [matcher, endOfLine] of matchers) {
|
|
233
|
-
if (endOfLine && !isLast) continue;
|
|
234
|
-
const result = matcher.exec(trimmed);
|
|
235
|
-
if (!result) continue;
|
|
236
|
-
return [
|
|
237
|
-
" ".repeat(spaceFront) + result[1],
|
|
238
|
-
result[2],
|
|
239
|
-
result[3] ? result[3] + " ".repeat(spaceEnd) : void 0
|
|
240
|
-
];
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Remove empty comment prefixes at line end, e.g. `// `
|
|
245
|
-
*
|
|
246
|
-
* For matchAlgorithm v1
|
|
247
|
-
*/
|
|
248
|
-
function v1ClearEndCommentPrefix(text) {
|
|
249
|
-
const match = text.match(/(?:\/\/|["'#]|;{1,2}|%{1,2}|--)(\s*)$/);
|
|
250
|
-
if (match && match[1].trim().length === 0) return text.slice(0, match.index);
|
|
251
|
-
return text;
|
|
252
|
-
}
|
|
253
|
-
function createCommentNotationTransformer(name, regex, onMatch, matchAlgorithm) {
|
|
254
|
-
if (matchAlgorithm == null) matchAlgorithm = "v3";
|
|
255
|
-
return {
|
|
256
|
-
name,
|
|
257
|
-
code(code) {
|
|
258
|
-
const lines = code.children.filter((i) => i.type === "element");
|
|
259
|
-
const linesToRemove = [];
|
|
260
|
-
code.data ??= {};
|
|
261
|
-
const data = code.data;
|
|
262
|
-
data._shiki_notation ??= parseComments(lines, ["jsx", "tsx"].includes(this.options.lang), matchAlgorithm);
|
|
263
|
-
const parsed = data._shiki_notation;
|
|
264
|
-
for (const comment of parsed) {
|
|
265
|
-
if (comment.info[1].length === 0) continue;
|
|
266
|
-
let lineIdx = lines.indexOf(comment.line);
|
|
267
|
-
if (comment.isLineCommentOnly && matchAlgorithm !== "v1") lineIdx++;
|
|
268
|
-
let replaced = false;
|
|
269
|
-
comment.info[1] = comment.info[1].replace(regex, (...match) => {
|
|
270
|
-
if (onMatch.call(this, match, comment.line, comment.token, lines, lineIdx)) {
|
|
271
|
-
replaced = true;
|
|
272
|
-
return "";
|
|
273
|
-
}
|
|
274
|
-
return match[0];
|
|
275
|
-
});
|
|
276
|
-
if (!replaced) continue;
|
|
277
|
-
if (matchAlgorithm === "v1") comment.info[1] = v1ClearEndCommentPrefix(comment.info[1]);
|
|
278
|
-
const isEmpty = comment.info[1].trim().length === 0;
|
|
279
|
-
if (isEmpty) comment.info[1] = "";
|
|
280
|
-
if (isEmpty && comment.isLineCommentOnly) linesToRemove.push(comment.line);
|
|
281
|
-
else if (isEmpty && comment.isJsxStyle) comment.line.children.splice(comment.line.children.indexOf(comment.token) - 1, 3);
|
|
282
|
-
else if (isEmpty) {
|
|
283
|
-
if (comment.additionalTokens) for (let j = comment.additionalTokens.length - 1; j >= 0; j--) {
|
|
284
|
-
const additionalToken = comment.additionalTokens[j];
|
|
285
|
-
const tokenIndex = comment.line.children.indexOf(additionalToken);
|
|
286
|
-
if (tokenIndex !== -1) comment.line.children.splice(tokenIndex, 1);
|
|
287
|
-
}
|
|
288
|
-
comment.line.children.splice(comment.line.children.indexOf(comment.token), 1);
|
|
289
|
-
} else {
|
|
290
|
-
const head = comment.token.children[0];
|
|
291
|
-
if (head.type === "text") {
|
|
292
|
-
head.value = comment.info.join("");
|
|
293
|
-
if (comment.additionalTokens) for (const additionalToken of comment.additionalTokens) {
|
|
294
|
-
const additionalHead = additionalToken.children[0];
|
|
295
|
-
if (additionalHead?.type === "text") additionalHead.value = "";
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
for (const line of linesToRemove) {
|
|
301
|
-
const index = code.children.indexOf(line);
|
|
302
|
-
const nextLine = code.children[index + 1];
|
|
303
|
-
let removeLength = 1;
|
|
304
|
-
if (nextLine?.type === "text" && nextLine?.value === "\n") removeLength = 2;
|
|
305
|
-
code.children.splice(index, removeLength);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
function escapeRegExp(str) {
|
|
311
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
312
|
-
}
|
|
313
|
-
function transformerNotationMap(options = {}, name = "@shikijs/transformers:notation-map") {
|
|
314
|
-
const { classMap = {}, classActivePre = void 0, classActiveCode = void 0 } = options;
|
|
315
|
-
return createCommentNotationTransformer(name, new RegExp(`#?\\s*\\[!code (${Object.keys(classMap).map(escapeRegExp).join("|")})(:\\d+)?\\]`, "gi"), function([_, match, range = ":1"], _line, _comment, lines, index) {
|
|
316
|
-
const lineNum = Number.parseInt(range.slice(1), 10);
|
|
317
|
-
for (let i = index; i < Math.min(index + lineNum, lines.length); i++) this.addClassToHast(lines[i], classMap[match]);
|
|
318
|
-
if (classActivePre) this.addClassToHast(this.pre, classActivePre);
|
|
319
|
-
if (classActiveCode) this.addClassToHast(this.code, classActiveCode);
|
|
320
|
-
return true;
|
|
321
|
-
}, options.matchAlgorithm);
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Use `[!code ++]` and `[!code --]` to mark added and removed lines.
|
|
325
|
-
*/
|
|
326
|
-
function transformerNotationDiff(options = {}) {
|
|
327
|
-
const { classLineAdd = "diff add", classLineRemove = "diff remove", classActivePre = "has-diff", classActiveCode } = options;
|
|
328
|
-
return transformerNotationMap({
|
|
329
|
-
classMap: {
|
|
330
|
-
"++": classLineAdd,
|
|
331
|
-
"--": classLineRemove
|
|
332
|
-
},
|
|
333
|
-
classActivePre,
|
|
334
|
-
classActiveCode,
|
|
335
|
-
matchAlgorithm: options.matchAlgorithm
|
|
336
|
-
}, "@shikijs/transformers:notation-diff");
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* Allow using `[!code focus]` notation in code to mark focused lines.
|
|
340
|
-
*/
|
|
341
|
-
function transformerNotationFocus(options = {}) {
|
|
342
|
-
const { classActiveLine = "focused", classActivePre = "has-focused", classActiveCode } = options;
|
|
343
|
-
return transformerNotationMap({
|
|
344
|
-
classMap: { focus: classActiveLine },
|
|
345
|
-
classActivePre,
|
|
346
|
-
classActiveCode,
|
|
347
|
-
matchAlgorithm: options.matchAlgorithm
|
|
348
|
-
}, "@shikijs/transformers:notation-focus");
|
|
349
|
-
}
|
|
350
|
-
/**
|
|
351
|
-
* Allow using `[!code highlight]` notation in code to mark highlighted lines.
|
|
352
|
-
*/
|
|
353
|
-
function transformerNotationHighlight(options = {}) {
|
|
354
|
-
const { classActiveLine = "highlighted", classActivePre = "has-highlighted", classActiveCode } = options;
|
|
355
|
-
return transformerNotationMap({
|
|
356
|
-
classMap: {
|
|
357
|
-
highlight: classActiveLine,
|
|
358
|
-
hl: classActiveLine
|
|
359
|
-
},
|
|
360
|
-
classActivePre,
|
|
361
|
-
classActiveCode,
|
|
362
|
-
matchAlgorithm: options.matchAlgorithm
|
|
363
|
-
}, "@shikijs/transformers:notation-highlight");
|
|
364
|
-
}
|
|
365
|
-
function highlightWordInLine(line, ignoredElement, word, className) {
|
|
366
|
-
const content = getTextContent(line);
|
|
367
|
-
let index = content.indexOf(word);
|
|
368
|
-
while (index !== -1) {
|
|
369
|
-
highlightRange.call(this, line.children, ignoredElement, index, word.length, className);
|
|
370
|
-
index = content.indexOf(word, index + 1);
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
function getTextContent(element) {
|
|
374
|
-
if (element.type === "text") return element.value;
|
|
375
|
-
if (element.type === "element" && element.tagName === "span") return element.children.map(getTextContent).join("");
|
|
376
|
-
return "";
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* @param elements
|
|
380
|
-
* @param ignoredElement
|
|
381
|
-
* @param index highlight beginning index
|
|
382
|
-
* @param len highlight length
|
|
383
|
-
* @param className class name to add to highlighted nodes
|
|
384
|
-
*/
|
|
385
|
-
function highlightRange(elements, ignoredElement, index, len, className) {
|
|
386
|
-
let currentIdx = 0;
|
|
387
|
-
for (let i = 0; i < elements.length; i++) {
|
|
388
|
-
const element = elements[i];
|
|
389
|
-
if (element.type !== "element" || element.tagName !== "span" || element === ignoredElement) continue;
|
|
390
|
-
const textNode = element.children[0];
|
|
391
|
-
if (textNode.type !== "text") continue;
|
|
392
|
-
if (hasOverlap([currentIdx, currentIdx + textNode.value.length - 1], [index, index + len])) {
|
|
393
|
-
const start = Math.max(0, index - currentIdx);
|
|
394
|
-
const length = len - Math.max(0, currentIdx - index);
|
|
395
|
-
if (length === 0) continue;
|
|
396
|
-
const separated = separateToken(element, textNode, start, length);
|
|
397
|
-
this.addClassToHast(separated[1], className);
|
|
398
|
-
const output = separated.filter(Boolean);
|
|
399
|
-
elements.splice(i, 1, ...output);
|
|
400
|
-
i += output.length - 1;
|
|
401
|
-
}
|
|
402
|
-
currentIdx += textNode.value.length;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
function hasOverlap(range1, range2) {
|
|
406
|
-
return range1[0] <= range2[1] && range1[1] >= range2[0];
|
|
407
|
-
}
|
|
408
|
-
function separateToken(span, textNode, index, len) {
|
|
409
|
-
const text = textNode.value;
|
|
410
|
-
const createNode = (value) => inheritElement(span, { children: [{
|
|
411
|
-
type: "text",
|
|
412
|
-
value
|
|
413
|
-
}] });
|
|
414
|
-
return [
|
|
415
|
-
index > 0 ? createNode(text.slice(0, index)) : void 0,
|
|
416
|
-
createNode(text.slice(index, index + len)),
|
|
417
|
-
index + len < text.length ? createNode(text.slice(index + len)) : void 0
|
|
418
|
-
];
|
|
419
|
-
}
|
|
420
|
-
function inheritElement(original, overrides) {
|
|
421
|
-
return {
|
|
422
|
-
...original,
|
|
423
|
-
properties: { ...original.properties },
|
|
424
|
-
...overrides
|
|
425
|
-
};
|
|
426
|
-
}
|
|
427
|
-
function transformerNotationWordHighlight(options = {}) {
|
|
428
|
-
const { classActiveWord = "highlighted-word", classActivePre = void 0 } = options;
|
|
429
|
-
return createCommentNotationTransformer("@shikijs/transformers:notation-highlight-word", /\s*\[!code word:((?:\\.|[^:\]])+)(:\d+)?\]/, function([_, word, range], _line, comment, lines, index) {
|
|
430
|
-
const lineNum = range ? Number.parseInt(range.slice(1), 10) : lines.length;
|
|
431
|
-
word = word.replace(/\\(.)/g, "$1");
|
|
432
|
-
for (let i = index; i < Math.min(index + lineNum, lines.length); i++) highlightWordInLine.call(this, lines[i], comment, word, classActiveWord);
|
|
433
|
-
if (classActivePre) this.addClassToHast(this.pre, classActivePre);
|
|
434
|
-
return true;
|
|
435
|
-
}, options.matchAlgorithm);
|
|
436
|
-
}
|
|
437
|
-
//#endregion
|
|
438
1
|
//#region src/mdx-plugins/transformer-icon.ts
|
|
439
2
|
const defaultShortcuts = {
|
|
440
3
|
js: "javascript",
|
|
@@ -579,87 +142,4 @@ function transformerIcon(options = {}) {
|
|
|
579
142
|
};
|
|
580
143
|
}
|
|
581
144
|
//#endregion
|
|
582
|
-
|
|
583
|
-
function rehypeCodeDefaultOptions() {
|
|
584
|
-
return {
|
|
585
|
-
...defaultThemes,
|
|
586
|
-
defaultLanguage: "plaintext",
|
|
587
|
-
transformers: [
|
|
588
|
-
transformerNotationHighlight({ matchAlgorithm: "v3" }),
|
|
589
|
-
transformerNotationWordHighlight({ matchAlgorithm: "v3" }),
|
|
590
|
-
transformerNotationDiff({ matchAlgorithm: "v3" }),
|
|
591
|
-
transformerNotationFocus({ matchAlgorithm: "v3" })
|
|
592
|
-
],
|
|
593
|
-
parseMetaString(meta) {
|
|
594
|
-
const parsed = parseCodeBlockAttributes(meta, ["title", "tab"]);
|
|
595
|
-
const data = parsed.attributes;
|
|
596
|
-
parsed.rest = parseLineNumber(parsed.rest, data);
|
|
597
|
-
data.__raw = parsed.rest;
|
|
598
|
-
return data;
|
|
599
|
-
}
|
|
600
|
-
};
|
|
601
|
-
}
|
|
602
|
-
function parseLineNumber(str, data) {
|
|
603
|
-
return str.replace(/lineNumbers=(\d+)|lineNumbers/, (_, ...args) => {
|
|
604
|
-
data["data-line-numbers"] = true;
|
|
605
|
-
if (args[0] !== void 0) data["data-line-numbers-start"] = Number(args[0]);
|
|
606
|
-
return "";
|
|
607
|
-
});
|
|
608
|
-
}
|
|
609
|
-
function createRehypeCode(highlighterFactory) {
|
|
610
|
-
async function initTransformer(_options) {
|
|
611
|
-
let highlighter;
|
|
612
|
-
let options;
|
|
613
|
-
if (typeof highlighterFactory === "function") {
|
|
614
|
-
const out = await highlighterFactory(_options);
|
|
615
|
-
highlighter = out.highlighter;
|
|
616
|
-
options = out.options;
|
|
617
|
-
} else {
|
|
618
|
-
highlighter = _options?.langAlias ? await highlighterFactory.init(_options) : await highlighterFactory.getOrInit();
|
|
619
|
-
options = _options ?? {};
|
|
620
|
-
}
|
|
621
|
-
const transformers = options.transformers ? [...options.transformers] : [];
|
|
622
|
-
if (options.icon !== false) transformers.push(transformerIcon(options.icon));
|
|
623
|
-
if (options.tab !== false) transformers.push(transformerTab());
|
|
624
|
-
const lazy = options.lazy ?? true;
|
|
625
|
-
let preloadLangs = options.langs;
|
|
626
|
-
if (!lazy) preloadLangs ??= Object.keys(highlighter.getBundledLanguages());
|
|
627
|
-
await Promise.all([highlighter.loadTheme(...getRequiredThemes(options)), preloadLangs && highlighter.loadLanguage(...preloadLangs)]);
|
|
628
|
-
return rehypeShikiFromHighlighter(highlighter, {
|
|
629
|
-
...options,
|
|
630
|
-
transformers
|
|
631
|
-
});
|
|
632
|
-
}
|
|
633
|
-
return function rehypeCode(_options) {
|
|
634
|
-
const transformer = initTransformer(_options);
|
|
635
|
-
return async (tree, file) => {
|
|
636
|
-
await (await transformer)(tree, file, () => void 0);
|
|
637
|
-
};
|
|
638
|
-
};
|
|
639
|
-
}
|
|
640
|
-
function transformerTab() {
|
|
641
|
-
return {
|
|
642
|
-
name: "rehype-code:tab",
|
|
643
|
-
root(root) {
|
|
644
|
-
const value = this.options.meta?.tab;
|
|
645
|
-
if (typeof value !== "string") return root;
|
|
646
|
-
console.warn("[Fumadocs] For `tab=\"value\" in codeblocks, please use `remarkCodeTab` plugin instead.");
|
|
647
|
-
return {
|
|
648
|
-
type: "root",
|
|
649
|
-
children: [{
|
|
650
|
-
type: "mdxJsxFlowElement",
|
|
651
|
-
name: "Tab",
|
|
652
|
-
data: { _codeblock: true },
|
|
653
|
-
attributes: [{
|
|
654
|
-
type: "mdxJsxAttribute",
|
|
655
|
-
name: "value",
|
|
656
|
-
value
|
|
657
|
-
}],
|
|
658
|
-
children: root.children
|
|
659
|
-
}]
|
|
660
|
-
};
|
|
661
|
-
}
|
|
662
|
-
};
|
|
663
|
-
}
|
|
664
|
-
//#endregion
|
|
665
|
-
export { transformerIcon as i, rehypeCodeDefaultOptions as n, transformerTab as r, createRehypeCode as t };
|
|
145
|
+
export { transformerIcon };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as Separator, i as Root, n as Item, r as Node, t as Folder } from "../definitions-
|
|
2
|
-
import { a as flattenTree, c as visit, i as findSiblings, n as findParent, o as getPageTreePeers, r as findPath, s as getPageTreeRoots, t as findNeighbour } from "../index-
|
|
1
|
+
import { a as Separator, i as Root, n as Item, r as Node, t as Folder } from "../definitions-DQRPsvc7.js";
|
|
2
|
+
import { a as flattenTree, c as visit, i as findSiblings, n as findParent, o as getPageTreePeers, r as findPath, s as getPageTreeRoots, t as findNeighbour } from "../index-L7sAY8Os.js";
|
|
3
3
|
export { Folder, Item, Node, Root, Separator, findNeighbour, findParent, findPath, findSiblings, flattenTree, getPageTreePeers, getPageTreeRoots, visit };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { n as IconOptions } from "./transformer-icon-DxbdvNM7.js";
|
|
2
|
+
import { t as Awaitable } from "./types-FiLV8L2L.js";
|
|
3
|
+
import { n as ShikiFactory } from "./index-CFaAAU5K.js";
|
|
3
4
|
import { Processor, Transformer } from "unified";
|
|
4
5
|
import { Element, Root } from "hast";
|
|
5
6
|
import { BuiltinLanguage, BuiltinTheme, CodeOptionsMeta, CodeOptionsThemes, CodeToHastOptionsCommon, HighlighterCore, LanguageInput, ShikiTransformer, TransformerOptions } from "shiki";
|
|
@@ -83,21 +84,6 @@ declare module 'shiki' {
|
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
//#endregion
|
|
86
|
-
//#region src/mdx-plugins/transformer-icon.d.ts
|
|
87
|
-
type CodeBlockIcon = {
|
|
88
|
-
viewBox: string;
|
|
89
|
-
fill: string;
|
|
90
|
-
d: string;
|
|
91
|
-
} | string;
|
|
92
|
-
interface IconOptions {
|
|
93
|
-
shortcuts?: Record<string, string>;
|
|
94
|
-
extend?: Record<string, CodeBlockIcon>;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Inject icons to `icon` property (as HTML)
|
|
98
|
-
*/
|
|
99
|
-
declare function transformerIcon(options?: IconOptions): ShikiTransformer;
|
|
100
|
-
//#endregion
|
|
101
87
|
//#region src/mdx-plugins/rehype-code.core.d.ts
|
|
102
88
|
declare function rehypeCodeDefaultOptions(): RehypeCodeOptionsCommon;
|
|
103
89
|
type RehypeCodeOptionsCommon = RehypeShikiCoreOptions & {
|
|
@@ -127,4 +113,4 @@ declare function createRehypeCode<Options extends Partial<RehypeCodeOptionsCommo
|
|
|
127
113
|
}>)): (this: Processor, _options?: Options) => Transformer<Root, Root>;
|
|
128
114
|
declare function transformerTab(): ShikiTransformer;
|
|
129
115
|
//#endregion
|
|
130
|
-
export {
|
|
116
|
+
export { transformerTab as i, createRehypeCode as n, rehypeCodeDefaultOptions as r, RehypeCodeOptionsCommon as t };
|