@docusaurus/mdx-loader 3.6.0-canary-6135 → 3.6.0-canary-6137
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/lib/remark/admonitions/index.d.ts +9 -2
- package/lib/remark/admonitions/index.d.ts.map +1 -1
- package/lib/remark/admonitions/index.js +7 -8
- package/lib/remark/admonitions/index.js.map +1 -1
- package/lib/remark/contentTitle/index.d.ts +6 -2
- package/lib/remark/contentTitle/index.d.ts.map +1 -1
- package/lib/remark/contentTitle/index.js +7 -12
- package/lib/remark/contentTitle/index.js.map +1 -1
- package/lib/remark/details/index.d.ts +2 -1
- package/lib/remark/details/index.d.ts.map +1 -1
- package/lib/remark/details/index.js.map +1 -1
- package/lib/remark/head/index.d.ts +2 -1
- package/lib/remark/head/index.d.ts.map +1 -1
- package/lib/remark/head/index.js.map +1 -1
- package/lib/remark/headings/index.d.ts +4 -2
- package/lib/remark/headings/index.d.ts.map +1 -1
- package/lib/remark/headings/index.js +3 -3
- package/lib/remark/headings/index.js.map +1 -1
- package/lib/remark/mdx1Compat/codeCompatPlugin.d.ts +4 -2
- package/lib/remark/mdx1Compat/codeCompatPlugin.d.ts.map +1 -1
- package/lib/remark/mdx1Compat/codeCompatPlugin.js +3 -3
- package/lib/remark/mdx1Compat/codeCompatPlugin.js.map +1 -1
- package/lib/remark/mermaid/index.d.ts +2 -1
- package/lib/remark/mermaid/index.d.ts.map +1 -1
- package/lib/remark/mermaid/index.js.map +1 -1
- package/lib/remark/resolveMarkdownLinks/index.d.ts +3 -2
- package/lib/remark/resolveMarkdownLinks/index.d.ts.map +1 -1
- package/lib/remark/resolveMarkdownLinks/index.js.map +1 -1
- package/lib/remark/toc/index.d.ts +3 -3
- package/lib/remark/toc/index.d.ts.map +1 -1
- package/lib/remark/toc/index.js +3 -3
- package/lib/remark/toc/index.js.map +1 -1
- package/lib/remark/transformImage/index.d.ts +4 -3
- package/lib/remark/transformImage/index.d.ts.map +1 -1
- package/lib/remark/transformImage/index.js +6 -3
- package/lib/remark/transformImage/index.js.map +1 -1
- package/lib/remark/transformLinks/index.d.ts +4 -3
- package/lib/remark/transformLinks/index.d.ts.map +1 -1
- package/lib/remark/transformLinks/index.js +6 -3
- package/lib/remark/transformLinks/index.js.map +1 -1
- package/lib/remark/unusedDirectives/index.d.ts +3 -2
- package/lib/remark/unusedDirectives/index.d.ts.map +1 -1
- package/lib/remark/unusedDirectives/index.js.map +1 -1
- package/package.json +6 -6
- package/src/remark/admonitions/index.ts +13 -20
- package/src/remark/contentTitle/index.ts +13 -19
- package/src/remark/details/index.ts +3 -4
- package/src/remark/head/index.ts +3 -4
- package/src/remark/headings/index.ts +8 -6
- package/src/remark/mdx1Compat/codeCompatPlugin.ts +7 -5
- package/src/remark/mermaid/index.ts +3 -3
- package/src/remark/resolveMarkdownLinks/index.ts +5 -9
- package/src/remark/toc/index.ts +7 -3
- package/src/remark/transformImage/index.ts +12 -5
- package/src/remark/transformLinks/index.ts +13 -6
- package/src/remark/unusedDirectives/index.ts +5 -8
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import type { Plugin } from 'unified';
|
|
8
|
+
import type { Root } from 'mdast';
|
|
2
9
|
export type AdmonitionOptions = {
|
|
3
10
|
keywords: string[];
|
|
4
11
|
extendDefaults: boolean;
|
|
5
12
|
};
|
|
6
13
|
export declare const DefaultAdmonitionOptions: AdmonitionOptions;
|
|
7
14
|
export declare function normalizeAdmonitionOptions(providedOptions: Partial<AdmonitionOptions> | true): AdmonitionOptions;
|
|
8
|
-
declare const plugin: Plugin
|
|
15
|
+
declare const plugin: Plugin<Partial<AdmonitionOptions>[], Root>;
|
|
9
16
|
export default plugin;
|
|
10
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/admonitions/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/admonitions/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAc,MAAM,EAAC,MAAM,SAAS,CAAC;AAIjD,OAAO,KAAK,EAAS,IAAI,EAAC,MAAM,OAAO,CAAC;AAExC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,iBAatC,CAAC;AAEF,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,IAAI,GACjD,iBAAiB,CAiBnB;AA6BD,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,EAAE,IAAI,CAsDtD,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -55,26 +55,25 @@ const plugin = function plugin(optionsInput = {}) {
|
|
|
55
55
|
const { visit } = await import('unist-util-visit');
|
|
56
56
|
visit(root, (node) => {
|
|
57
57
|
if (node.type === 'containerDirective') {
|
|
58
|
-
const
|
|
59
|
-
const isAdmonition = keywords.includes(directive.name);
|
|
58
|
+
const isAdmonition = keywords.includes(node.name);
|
|
60
59
|
if (!isAdmonition) {
|
|
61
60
|
return;
|
|
62
61
|
}
|
|
63
|
-
const { directiveLabel, contentNodes } = parseDirective(
|
|
64
|
-
const textOnlyTitle =
|
|
62
|
+
const { directiveLabel, contentNodes } = parseDirective(node);
|
|
63
|
+
const textOnlyTitle = node.attributes?.title ??
|
|
65
64
|
(directiveLabel ? getTextOnlyTitle(directiveLabel) : undefined);
|
|
66
65
|
// Transform the mdast directive node to a hast admonition node
|
|
67
66
|
// See https://github.com/syntax-tree/mdast-util-to-hast#fields-on-nodes
|
|
68
67
|
// TODO in MDX v2 we should transform the whole directive to
|
|
69
68
|
// mdxJsxFlowElement instead of using hast
|
|
70
|
-
|
|
69
|
+
node.data = {
|
|
71
70
|
hName: 'admonition',
|
|
72
71
|
hProperties: {
|
|
73
72
|
...(textOnlyTitle && { title: textOnlyTitle }),
|
|
74
|
-
type:
|
|
73
|
+
type: node.name,
|
|
75
74
|
},
|
|
76
75
|
};
|
|
77
|
-
|
|
76
|
+
node.children = contentNodes;
|
|
78
77
|
// TODO legacy MDX v1 <mdxAdmonitionTitle> workaround
|
|
79
78
|
// v1: not possible to inject complex JSX elements as props
|
|
80
79
|
// v2: now possible: use a mdxJsxFlowElement element
|
|
@@ -88,7 +87,7 @@ const plugin = function plugin(optionsInput = {}) {
|
|
|
88
87
|
children: directiveLabel.children,
|
|
89
88
|
};
|
|
90
89
|
// @ts-expect-error: invented node type
|
|
91
|
-
|
|
90
|
+
node.children.unshift(complexTitleNode);
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
93
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/admonitions/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/admonitions/index.ts"],"names":[],"mappings":";;;AAiCA,gEAmBC;AAlCY,QAAA,wBAAwB,GAAsB;IACzD,QAAQ,EAAE;QACR,WAAW;QACX,MAAM;QACN,SAAS;QACT,QAAQ;QACR,MAAM;QACN,KAAK;QACL,SAAS;QACT,WAAW;QACX,SAAS;KACV;IACD,cAAc,EAAE,IAAI;CACrB,CAAC;AAEF,SAAgB,0BAA0B,CACxC,eAAkD;IAElD,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;QAC7B,OAAO,gCAAwB,CAAC;IAClC,CAAC;IAED,MAAM,OAAO,GAAG,EAA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C1C,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
|
@@ -4,12 +4,16 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
type Plugin
|
|
7
|
+
import type { Plugin } from 'unified';
|
|
8
|
+
import type { Root } from 'mdast';
|
|
9
|
+
interface PluginOptions {
|
|
10
|
+
removeContentTitle?: boolean;
|
|
11
|
+
}
|
|
8
12
|
/**
|
|
9
13
|
* A remark plugin to extract the h1 heading found in Markdown files
|
|
10
14
|
* This is exposed as "data.contentTitle" to the processed vfile
|
|
11
15
|
* Also gives the ability to strip that content title (used for the blog plugin)
|
|
12
16
|
*/
|
|
13
|
-
declare const plugin: Plugin
|
|
17
|
+
declare const plugin: Plugin<PluginOptions[], Root>;
|
|
14
18
|
export default plugin;
|
|
15
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/contentTitle/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/contentTitle/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAc,MAAM,EAAC,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAkB,IAAI,EAAC,MAAM,OAAO,CAAC;AAKjD,UAAU,aAAa;IACrB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAgBD;;;;GAIG;AACH,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,EAAE,IAAI,CAwCzC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
3
|
function wrapHeadingInJsxHeader(headingNode, parent, index) {
|
|
10
4
|
const header = {
|
|
@@ -27,25 +21,26 @@ const plugin = function plugin(options = {}) {
|
|
|
27
21
|
const { toString } = await import('mdast-util-to-string');
|
|
28
22
|
const { visit, EXIT } = await import('unist-util-visit');
|
|
29
23
|
visit(root, ['heading', 'thematicBreak'], (node, index, parent) => {
|
|
24
|
+
if (!parent || index === undefined) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
30
27
|
if (node.type === 'heading') {
|
|
31
|
-
const headingNode = node;
|
|
32
28
|
// console.log('headingNode:', headingNode);
|
|
33
|
-
if (
|
|
34
|
-
vfile.data.contentTitle = toString(
|
|
29
|
+
if (node.depth === 1) {
|
|
30
|
+
vfile.data.contentTitle = toString(node);
|
|
35
31
|
if (removeContentTitle) {
|
|
36
|
-
// @ts-expect-error: TODO how to fix?
|
|
37
32
|
parent.children.splice(index, 1);
|
|
38
33
|
}
|
|
39
34
|
else {
|
|
40
35
|
// TODO in the future it might be better to export contentTitle as
|
|
41
36
|
// as JSX node to keep this logic a theme concern?
|
|
42
37
|
// See https://github.com/facebook/docusaurus/pull/10335#issuecomment-2250187371
|
|
43
|
-
wrapHeadingInJsxHeader(
|
|
38
|
+
wrapHeadingInJsxHeader(node, parent, index);
|
|
44
39
|
}
|
|
45
40
|
return EXIT; // We only handle the very first heading
|
|
46
41
|
}
|
|
47
42
|
// We only handle contentTitle if it's the very first heading found
|
|
48
|
-
if (
|
|
43
|
+
if (node.depth >= 1) {
|
|
49
44
|
return EXIT;
|
|
50
45
|
}
|
|
51
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/contentTitle/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/contentTitle/index.ts"],"names":[],"mappings":";;AAiBA,SAAS,sBAAsB,CAC7B,WAAoB,EACpB,MAAc,EACd,KAAa;IAEb,MAAM,MAAM,GAAsB;QAChC,IAAI,EAAE,mBAAmB;QACzB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,CAAC,WAAW,CAAC;KACxB,CAAC;IACF,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;AAClC,CAAC;AAED;;;;GAIG;AACH,MAAM,MAAM,GAAkC,SAAS,MAAM,CAC3D,OAAO,GAAG,EAAE;IAEZ,mBAAmB;IACnB,MAAM,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,IAAI,KAAK,CAAC;IAE/D,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QAC3B,MAAM,EAAC,QAAQ,EAAC,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;QACxD,MAAM,EAAC,KAAK,EAAE,IAAI,EAAC,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;QACvD,KAAK,CAAC,IAAI,EAAE,CAAC,SAAS,EAAE,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YAChE,IAAI,CAAC,MAAM,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACnC,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBAC5B,4CAA4C;gBAE5C,IAAI,IAAI,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;oBACrB,KAAK,CAAC,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;oBACzC,IAAI,kBAAkB,EAAE,CAAC;wBACvB,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;oBACnC,CAAC;yBAAM,CAAC;wBACN,kEAAkE;wBAClE,kDAAkD;wBAClD,gFAAgF;wBAChF,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;oBAC9C,CAAC;oBACD,OAAO,IAAI,CAAC,CAAC,wCAAwC;gBACvD,CAAC;gBACD,mEAAmE;gBACnE,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC;oBACpB,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;YACD,uEAAuE;YACvE,IAAI,IAAI,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;gBAClC,OAAO,IAAI,CAAC;YACd,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
|
@@ -5,5 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { Transformer } from 'unified';
|
|
8
|
-
|
|
8
|
+
import type { Root } from 'mdast';
|
|
9
|
+
export default function plugin(): Transformer<Root>;
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/details/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/details/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAEzC,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,OAAO,CAAC;AAIhC,MAAM,CAAC,OAAO,UAAU,MAAM,IAAI,WAAW,CAAC,IAAI,CAAC,CASlD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/details/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/details/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AASH,yBASC;AAXD,mCAAmC;AACnC,4EAA4E;AAC5E,SAAwB,MAAM;IAC5B,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QACpB,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;QACjD,KAAK,CAAC,IAAI,EAAE,mBAAmB,EAAE,CAAC,IAAI,EAAE,EAAE;YACxC,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBAC5B,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;YACxB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -5,5 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { Transformer } from 'unified';
|
|
8
|
-
|
|
8
|
+
import type { Root } from 'mdast';
|
|
9
|
+
export default function plugin(): Transformer<Root>;
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/head/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/head/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAEzC,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,OAAO,CAAC;AAIhC,MAAM,CAAC,OAAO,UAAU,MAAM,IAAI,WAAW,CAAC,IAAI,CAAC,CASlD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/head/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/head/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AASH,yBASC;AAXD,6BAA6B;AAC7B,4EAA4E;AAC5E,SAAwB,MAAM;IAC5B,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QACpB,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;QACjD,KAAK,CAAC,IAAI,EAAE,mBAAmB,EAAE,CAAC,IAAI,EAAE,EAAE;YACxC,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBACzB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;YACrB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
7
|
+
import type { Plugin } from 'unified';
|
|
8
|
+
import type { Root } from 'mdast';
|
|
8
9
|
export interface PluginOptions {
|
|
9
10
|
anchorsMaintainCase: boolean;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
+
declare const plugin: Plugin<PluginOptions[], Root>;
|
|
13
|
+
export default plugin;
|
|
12
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/headings/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/headings/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAC,MAAM,EAAc,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAC,IAAI,EAAO,MAAM,OAAO,CAAC;AAEtC,MAAM,WAAW,aAAa;IAC5B,mBAAmB,EAAE,OAAO,CAAC;CAC9B;AAED,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,EAAE,IAAI,CA6DzC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -6,10 +6,9 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.default = plugin;
|
|
10
9
|
/* Based on remark-slug (https://github.com/remarkjs/remark-slug) and gatsby-remark-autolink-headers (https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-remark-autolink-headers) */
|
|
11
10
|
const utils_1 = require("@docusaurus/utils");
|
|
12
|
-
function plugin({ anchorsMaintainCase, }) {
|
|
11
|
+
const plugin = function plugin({ anchorsMaintainCase, }) {
|
|
13
12
|
return async (root) => {
|
|
14
13
|
const { toString } = await import('mdast-util-to-string');
|
|
15
14
|
const { visit } = await import('unist-util-visit');
|
|
@@ -55,5 +54,6 @@ function plugin({ anchorsMaintainCase, }) {
|
|
|
55
54
|
properties.id = id;
|
|
56
55
|
});
|
|
57
56
|
};
|
|
58
|
-
}
|
|
57
|
+
};
|
|
58
|
+
exports.default = plugin;
|
|
59
59
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/headings/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/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AC,OAAO,CAAC,CAAC;gBAEtD,EAAE;oBACA,aAAa,CAAC,EAAE;wBAChB,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,EAAC,YAAY,EAAE,mBAAmB,EAAC,CAAC,CAAC;gBAE3D,IAAI,aAAa,CAAC,EAAE,EAAE,CAAC;oBACrB,0DAA0D;oBAC1D,sEAAsE;oBACtE,SAAS;oBACT,+BAA+B;oBAC/B,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,CACnC,WAAW,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CACxB,CAAC;oBAEV,IAAI,WAAW,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBACpC,MAAM,YAAY,GAAG,IAAA,8BAAsB,EAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;wBACjE,iDAAiD;wBACjD,IAAI,YAAY,EAAE,CAAC;4BACjB,QAAQ,CAAC,KAAK,GAAG,YAAY,CAAC;wBAChC,CAAC;wBACD,mEAAmE;6BAC9D,CAAC;4BACJ,WAAW,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;wBAC7B,CAAC;oBACH,CAAC;yBAAM,CAAC;wBACN,QAAQ,CAAC,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC;oBACtC,CAAC;gBACH,CAAC;YACH,CAAC;YAED,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;YACb,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;QACrB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
8
|
-
|
|
7
|
+
import type { Plugin } from 'unified';
|
|
8
|
+
import type { Root } from 'mdast';
|
|
9
|
+
declare const plugin: Plugin<unknown[], Root>;
|
|
10
|
+
export default plugin;
|
|
9
11
|
//# sourceMappingURL=codeCompatPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codeCompatPlugin.d.ts","sourceRoot":"","sources":["../../../src/remark/mdx1Compat/codeCompatPlugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"codeCompatPlugin.d.ts","sourceRoot":"","sources":["../../../src/remark/mdx1Compat/codeCompatPlugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAc,MAAM,EAAC,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,OAAO,CAAC;AAShC,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,IAAI,CAenC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -6,14 +6,13 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.default = codeCompatPlugin;
|
|
10
9
|
// Solution inspired by https://github.com/pomber/docusaurus-mdx-2/blob/main/packages/mdx-loader/src/remark/codeCompat/index.ts
|
|
11
10
|
// TODO after MDX 2 we probably don't need this - remove soon?
|
|
12
11
|
// Only fenced code blocks are swapped by pre/code MDX components
|
|
13
12
|
// Using <pre><code> in JSX shouldn't use our MDX components anymore
|
|
14
13
|
// To make theme-classic/src/theme/MDXComponents/Pre work
|
|
15
14
|
// we need to fill two properties that mdx v2 doesn't provide anymore
|
|
16
|
-
function
|
|
15
|
+
const plugin = function plugin() {
|
|
17
16
|
return async (root) => {
|
|
18
17
|
const { visit } = await import('unist-util-visit');
|
|
19
18
|
visit(root, 'code', (node) => {
|
|
@@ -25,5 +24,6 @@ function codeCompatPlugin() {
|
|
|
25
24
|
node.data.hProperties.live = node.meta?.split(' ').includes('live');
|
|
26
25
|
});
|
|
27
26
|
};
|
|
28
|
-
}
|
|
27
|
+
};
|
|
28
|
+
exports.default = plugin;
|
|
29
29
|
//# sourceMappingURL=codeCompatPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codeCompatPlugin.js","sourceRoot":"","sources":["../../../src/remark/mdx1Compat/codeCompatPlugin.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;
|
|
1
|
+
{"version":3,"file":"codeCompatPlugin.js","sourceRoot":"","sources":["../../../src/remark/mdx1Compat/codeCompatPlugin.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAMH,+HAA+H;AAC/H,8DAA8D;AAC9D,iEAAiE;AACjE,oEAAoE;AAEpE,yDAAyD;AACzD,qEAAqE;AACrE,MAAM,MAAM,GAA4B,SAAS,MAAM;IACrD,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QACpB,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAEjD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;YAE5B,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC;YACpD,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC;YAE7C,wDAAwD;YACxD,qDAAqD;YACrD,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACtE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
|
@@ -5,5 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { Transformer } from 'unified';
|
|
8
|
-
|
|
8
|
+
import type { Root } from 'mdast';
|
|
9
|
+
export default function plugin(): Transformer<Root>;
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/mermaid/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/mermaid/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,OAAO,CAAC;AAMhC,MAAM,CAAC,OAAO,UAAU,MAAM,IAAI,WAAW,CAAC,IAAI,CAAC,CAmBlD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/mermaid/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAYH,yBAmBC;AA7BD,oCAAuC;AAMvC,wDAAwD;AACxD,+DAA+D;AAC/D,+EAA+E;AAC/E,0BAA0B;AAC1B,SAAwB,MAAM;IAC5B,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QACpB,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAEjD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/mermaid/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAYH,yBAmBC;AA7BD,oCAAuC;AAMvC,wDAAwD;AACxD,+DAA+D;AAC/D,+EAA+E;AAC/E,0BAA0B;AAC1B,SAAwB,MAAM;IAC5B,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QACpB,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAEjD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YAC3B,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBAC5B,oDAAoD;gBACpD,IAAA,qBAAa,EAAC,IAAI,EAAE;oBAClB,IAAI,EAAE,kBAAkB;oBACxB,IAAI,EAAE;wBACJ,KAAK,EAAE,SAAS;wBAChB,WAAW,EAAE;4BACX,KAAK,EAAE,IAAI,CAAC,KAAK;yBAClB;qBACF;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
+
import type { Plugin } from 'unified';
|
|
8
|
+
import type { Root } from 'mdast';
|
|
7
9
|
type ResolveMarkdownLinkParams = {
|
|
8
10
|
/**
|
|
9
11
|
* Absolute path to the source file containing this Markdown link.
|
|
@@ -19,12 +21,11 @@ export type ResolveMarkdownLink = (params: ResolveMarkdownLinkParams) => string
|
|
|
19
21
|
export interface PluginOptions {
|
|
20
22
|
resolveMarkdownLink: ResolveMarkdownLink;
|
|
21
23
|
}
|
|
22
|
-
type Plugin = any;
|
|
23
24
|
/**
|
|
24
25
|
* A remark plugin to extract the h1 heading found in Markdown files
|
|
25
26
|
* This is exposed as "data.contentTitle" to the processed vfile
|
|
26
27
|
* Also gives the ability to strip that content title (used for the blog plugin)
|
|
27
28
|
*/
|
|
28
|
-
declare const plugin: Plugin
|
|
29
|
+
declare const plugin: Plugin<PluginOptions[], Root>;
|
|
29
30
|
export default plugin;
|
|
30
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/resolveMarkdownLinks/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/resolveMarkdownLinks/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,OAAO,KAAK,EAAC,MAAM,EAAc,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAmB,IAAI,EAAC,MAAM,OAAO,CAAC;AAElD,KAAK,yBAAyB,GAAG;IAC/B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,CAChC,MAAM,EAAE,yBAAyB,KAC9B,MAAM,GAAG,IAAI,CAAC;AAEnB,MAAM,WAAW,aAAa;IAC5B,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C;AAoBD;;;;GAIG;AACH,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,EAAE,IAAI,CA6BzC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/resolveMarkdownLinks/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,6CAI2B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/resolveMarkdownLinks/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,6CAI2B;AA0B3B,MAAM,sBAAsB,GAAG,UAAU,CAAC;AAE1C,SAAS,wBAAwB,CAAC,IAAY;IAC5C,MAAM,OAAO,GAAG,IAAA,yBAAiB,EAAC,IAAI,CAAC,CAAC;IAExC,sEAAsE;IACtE,iEAAiE;IACjE,IA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
|
7
7
|
import type { Root } from 'mdast';
|
|
8
|
-
import type {
|
|
8
|
+
import type { Plugin } from 'unified';
|
|
9
9
|
interface PluginOptions {
|
|
10
10
|
name?: string;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
export
|
|
12
|
+
declare const plugin: Plugin<PluginOptions[], Root>;
|
|
13
|
+
export default plugin;
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/toc/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAO,KAAK,EAAU,IAAI,EAAC,MAAM,OAAO,CAAC;AAEzC,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/toc/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAO,KAAK,EAAU,IAAI,EAAC,MAAM,OAAO,CAAC;AAEzC,OAAO,KAAK,EAAC,MAAM,EAAc,MAAM,SAAS,CAAC;AASjD,UAAU,aAAa;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAiID,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,EAAE,IAAI,CA+BzC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/lib/remark/toc/index.js
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.default = plugin;
|
|
10
9
|
const utils_1 = require("./utils");
|
|
11
10
|
function createTocSliceImportName({ tocExportName, componentName, }) {
|
|
12
11
|
// The name of the toc slice import alias doesn't matter much
|
|
@@ -89,7 +88,7 @@ async function collectTOCItems({ root, tocExportName, markdownImports, }) {
|
|
|
89
88
|
});
|
|
90
89
|
}
|
|
91
90
|
}
|
|
92
|
-
function plugin(options = {}) {
|
|
91
|
+
const plugin = function plugin(options = {}) {
|
|
93
92
|
const tocExportName = options.name || 'toc';
|
|
94
93
|
return async (root) => {
|
|
95
94
|
const { markdownImports, existingTocExport } = await collectImportsExports({
|
|
@@ -112,5 +111,6 @@ function plugin(options = {}) {
|
|
|
112
111
|
tocItems,
|
|
113
112
|
}));
|
|
114
113
|
};
|
|
115
|
-
}
|
|
114
|
+
};
|
|
115
|
+
exports.default = plugin;
|
|
116
116
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/toc/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/toc/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,mCAOiB;AAsBjB,SAAS,wBAAwB,CAAC,EAChC,aAAa,EACb,aAAa,GAId;IACC,6DAA6D;IAC7D,wEAAwE;IACxE,OAAO,KAAK,aAAa,GAAG,aAAa,EAAE,CAAC;AAC9C,CAAC;AAED,KAAK,UAAU,qBAAqB,CAAC,EACnC,IAAI,EACJ,aAAa,GAId;IAIC,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;IAEjD,MAAM,eAAe,GAAG,IAAI,GAAG,EAA4C,CAAC;IAC5E,IAAI,iBAAiB,GAAoB,IAAI,CAAC;IAE9C,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE;QAC/B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;YACvB,OAAO;QACT,CAAC;QACD,IAAI,IAAA,qBAAa,EAAC,IAAI,EAAE,aAAa,CAAC,EAAE,CAAC;YACvC,iBAAiB,GAAG,IAAI,CAAC;QAC3B,CAAC;QAED,IAAA,6BAAqB,EAAC,IAAI,CAAC,IAAI,CAAC,MAA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AA,8BAAsB,EAAC;YAC3B,aAAa;YACb,QAAQ;SACT,CAAC,CACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
7
|
+
import type { Plugin } from 'unified';
|
|
8
|
+
import type { Root } from 'mdast';
|
|
8
9
|
type PluginOptions = {
|
|
9
10
|
staticDirs: string[];
|
|
10
11
|
siteDir: string;
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
-
export
|
|
13
|
+
declare const plugin: Plugin<PluginOptions[], Root>;
|
|
14
|
+
export default plugin;
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/transformImage/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkBH,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/transformImage/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkBH,OAAO,KAAK,EAAC,MAAM,EAAc,MAAM,SAAS,CAAC;AAGjD,OAAO,KAAK,EAAQ,IAAI,EAAC,MAAM,OAAO,CAAC;AAGvC,KAAK,aAAa,GAAG;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AA4JF,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,EAAE,IAAI,CAyBzC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.default = plugin;
|
|
10
9
|
const tslib_1 = require("tslib");
|
|
11
10
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
11
|
const url_1 = tslib_1.__importDefault(require("url"));
|
|
@@ -125,7 +124,7 @@ async function processImageNode(target, context) {
|
|
|
125
124
|
const imagePath = await getImageAbsolutePath(parsedUrl.pathname, context);
|
|
126
125
|
await toImageRequireNode(target, imagePath, context);
|
|
127
126
|
}
|
|
128
|
-
function plugin(options) {
|
|
127
|
+
const plugin = function plugin(options) {
|
|
129
128
|
return async (root, vfile) => {
|
|
130
129
|
const { visit } = await import('unist-util-visit');
|
|
131
130
|
const fileLoaderUtils = (0, utils_1.getFileLoaderUtils)(vfile.data.compilerName === 'server');
|
|
@@ -136,9 +135,13 @@ function plugin(options) {
|
|
|
136
135
|
};
|
|
137
136
|
const promises = [];
|
|
138
137
|
visit(root, 'image', (node, index, parent) => {
|
|
138
|
+
if (!parent || index === undefined) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
139
141
|
promises.push(processImageNode([node, index, parent], context));
|
|
140
142
|
});
|
|
141
143
|
await Promise.all(promises);
|
|
142
144
|
};
|
|
143
|
-
}
|
|
145
|
+
};
|
|
146
|
+
exports.default = plugin;
|
|
144
147
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/transformImage/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/transformImage/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,wDAAwB;AACxB,sDAAsB;AACtB,gEAA0B;AAC1B,+BAA+B;AAC/B,6CAM2B;AAC3B,sEAAqC;AACrC,oEAAgC;AAChC,wEAAwC;AACxC,oCAAmE;AAoBnE,KAAK,UAAU,kBAAkB,CAC/B,CAAC,IAAI,CAAS,EACd,SAAiB,EACjB,OAAgB;IAEhB,mGA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O,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YAC3C,IAAI,CAAC,MAAM,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACnC,OAAO;YACT,CAAC;YACD,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,MAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;QACH,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
7
|
+
import type { Plugin } from 'unified';
|
|
8
|
+
import type { Root } from 'mdast';
|
|
8
9
|
type PluginOptions = {
|
|
9
10
|
staticDirs: string[];
|
|
10
11
|
siteDir: string;
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
-
export
|
|
13
|
+
declare const plugin: Plugin<PluginOptions[], Root>;
|
|
14
|
+
export default plugin;
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/transformLinks/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/transformLinks/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH,OAAO,KAAK,EAAC,MAAM,EAAc,MAAM,SAAS,CAAC;AAIjD,OAAO,KAAK,EAAgB,IAAI,EAAC,MAAM,OAAO,CAAC;AAE/C,KAAK,aAAa,GAAG;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AA4KF,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,EAAE,IAAI,CAyBzC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.default = plugin;
|
|
10
9
|
const tslib_1 = require("tslib");
|
|
11
10
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
11
|
const url_1 = tslib_1.__importDefault(require("url"));
|
|
@@ -136,7 +135,7 @@ async function processLinkNode(target, context) {
|
|
|
136
135
|
await toAssetRequireNode(target, assetPath, context);
|
|
137
136
|
}
|
|
138
137
|
}
|
|
139
|
-
function plugin(options) {
|
|
138
|
+
const plugin = function plugin(options) {
|
|
140
139
|
return async (root, vfile) => {
|
|
141
140
|
const { visit } = await import('unist-util-visit');
|
|
142
141
|
const fileLoaderUtils = (0, utils_1.getFileLoaderUtils)(vfile.data.compilerName === 'server');
|
|
@@ -147,9 +146,13 @@ function plugin(options) {
|
|
|
147
146
|
};
|
|
148
147
|
const promises = [];
|
|
149
148
|
visit(root, 'link', (node, index, parent) => {
|
|
149
|
+
if (!parent || index === undefined) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
150
152
|
promises.push(processLinkNode([node, index, parent], context));
|
|
151
153
|
});
|
|
152
154
|
await Promise.all(promises);
|
|
153
155
|
};
|
|
154
|
-
}
|
|
156
|
+
};
|
|
157
|
+
exports.default = plugin;
|
|
155
158
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/transformLinks/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/transformLinks/index.ts"],"names":[],"mappings":";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AAY,KAAK,QAAQ,CACrC,CAAC;QACF,MAAM,OAAO,GAAY;YACvB,GAAG,OAAO;YACV,QAAQ,EAAE,KAAK,CAAC,IAAK;YACrB,4BAA4B,EAC1B,eAAe,CAAC,OAAO,CAAC,4BAA4B;SACvD,CAAC;QAEF,MAAM,QAAQ,GAAoB,EAAE,CAAC;QACrC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YAC1C,IAAI,CAAC,MAAM,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACnC,OAAO;YACT,CAAC;YACD,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;QACH,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/unusedDirectives/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/unusedDirectives/index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,OAAO,CAAC;AAGhC,OAAO,KAAK,EAAiC,MAAM,EAAC,MAAM,SAAS,CAAC;AAiHpE,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,IAAI,CAmCnC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/unusedDirectives/index.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,wDAAwB;AACxB,8DAA8B;AAC9B,wEAAwC;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C,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/mdx-loader",
|
|
3
|
-
"version": "3.6.0-canary-
|
|
3
|
+
"version": "3.6.0-canary-6137",
|
|
4
4
|
"description": "Docusaurus Loader for MDX",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/logger": "3.6.0-canary-
|
|
22
|
-
"@docusaurus/utils": "3.6.0-canary-
|
|
23
|
-
"@docusaurus/utils-validation": "3.6.0-canary-
|
|
21
|
+
"@docusaurus/logger": "3.6.0-canary-6137",
|
|
22
|
+
"@docusaurus/utils": "3.6.0-canary-6137",
|
|
23
|
+
"@docusaurus/utils-validation": "3.6.0-canary-6137",
|
|
24
24
|
"@mdx-js/mdx": "^3.0.0",
|
|
25
25
|
"@slorber/remark-comment": "^1.0.0",
|
|
26
26
|
"escape-html": "^1.0.3",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"webpack": "^5.88.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@docusaurus/types": "3.6.0-canary-
|
|
47
|
+
"@docusaurus/types": "3.6.0-canary-6137",
|
|
48
48
|
"@types/escape-html": "^1.0.2",
|
|
49
49
|
"@types/mdast": "^4.0.2",
|
|
50
50
|
"@types/stringify-object": "^3.3.1",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"engines": {
|
|
65
65
|
"node": ">=18.0"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "045cb8945e150ddd3824f1c15ec633fe4979a37c"
|
|
68
68
|
}
|
|
@@ -5,17 +5,11 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
|
|
8
|
-
import type {Transformer,
|
|
8
|
+
import type {Transformer, Plugin} from 'unified';
|
|
9
9
|
|
|
10
10
|
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
|
|
11
11
|
import type {ContainerDirective} from 'mdast-util-directive';
|
|
12
|
-
import type {Parent} from 'mdast';
|
|
13
|
-
|
|
14
|
-
// TODO as of April 2023, no way to import/re-export this ESM type easily :/
|
|
15
|
-
// This might change soon, likely after TS 5.2
|
|
16
|
-
// See https://github.com/microsoft/TypeScript/issues/49721#issuecomment-1517839391
|
|
17
|
-
// import type {Plugin} from 'unified';
|
|
18
|
-
type Plugin = any; // TODO fix this asap
|
|
12
|
+
import type {Parent, Root} from 'mdast';
|
|
19
13
|
|
|
20
14
|
export type AdmonitionOptions = {
|
|
21
15
|
keywords: string[];
|
|
@@ -85,10 +79,10 @@ function getTextOnlyTitle(directiveLabel: DirectiveLabel): string | undefined {
|
|
|
85
79
|
: undefined;
|
|
86
80
|
}
|
|
87
81
|
|
|
88
|
-
const plugin: Plugin = function plugin(
|
|
89
|
-
this
|
|
90
|
-
optionsInput
|
|
91
|
-
): Transformer {
|
|
82
|
+
const plugin: Plugin<Partial<AdmonitionOptions>[], Root> = function plugin(
|
|
83
|
+
this,
|
|
84
|
+
optionsInput = {},
|
|
85
|
+
): Transformer<Root> {
|
|
92
86
|
const {keywords} = normalizeAdmonitionOptions(optionsInput);
|
|
93
87
|
|
|
94
88
|
return async (root) => {
|
|
@@ -96,31 +90,30 @@ const plugin: Plugin = function plugin(
|
|
|
96
90
|
|
|
97
91
|
visit(root, (node) => {
|
|
98
92
|
if (node.type === 'containerDirective') {
|
|
99
|
-
const
|
|
100
|
-
const isAdmonition = keywords.includes(directive.name);
|
|
93
|
+
const isAdmonition = keywords.includes(node.name);
|
|
101
94
|
|
|
102
95
|
if (!isAdmonition) {
|
|
103
96
|
return;
|
|
104
97
|
}
|
|
105
98
|
|
|
106
|
-
const {directiveLabel, contentNodes} = parseDirective(
|
|
99
|
+
const {directiveLabel, contentNodes} = parseDirective(node);
|
|
107
100
|
|
|
108
101
|
const textOnlyTitle =
|
|
109
|
-
|
|
102
|
+
node.attributes?.title ??
|
|
110
103
|
(directiveLabel ? getTextOnlyTitle(directiveLabel) : undefined);
|
|
111
104
|
|
|
112
105
|
// Transform the mdast directive node to a hast admonition node
|
|
113
106
|
// See https://github.com/syntax-tree/mdast-util-to-hast#fields-on-nodes
|
|
114
107
|
// TODO in MDX v2 we should transform the whole directive to
|
|
115
108
|
// mdxJsxFlowElement instead of using hast
|
|
116
|
-
|
|
109
|
+
node.data = {
|
|
117
110
|
hName: 'admonition',
|
|
118
111
|
hProperties: {
|
|
119
112
|
...(textOnlyTitle && {title: textOnlyTitle}),
|
|
120
|
-
type:
|
|
113
|
+
type: node.name,
|
|
121
114
|
},
|
|
122
115
|
};
|
|
123
|
-
|
|
116
|
+
node.children = contentNodes;
|
|
124
117
|
|
|
125
118
|
// TODO legacy MDX v1 <mdxAdmonitionTitle> workaround
|
|
126
119
|
// v1: not possible to inject complex JSX elements as props
|
|
@@ -135,7 +128,7 @@ const plugin: Plugin = function plugin(
|
|
|
135
128
|
children: directiveLabel.children,
|
|
136
129
|
};
|
|
137
130
|
// @ts-expect-error: invented node type
|
|
138
|
-
|
|
131
|
+
node.children.unshift(complexTitleNode);
|
|
139
132
|
}
|
|
140
133
|
}
|
|
141
134
|
});
|
|
@@ -4,20 +4,13 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
7
|
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
|
|
9
|
-
import type {Transformer} from 'unified';
|
|
10
|
-
import type {Heading, Parent} from 'mdast';
|
|
8
|
+
import type {Transformer, Plugin} from 'unified';
|
|
9
|
+
import type {Heading, Parent, Root} from 'mdast';
|
|
11
10
|
|
|
12
11
|
// @ts-expect-error: ES support...
|
|
13
12
|
import type {MdxJsxFlowElement} from 'mdast-util-mdx';
|
|
14
13
|
|
|
15
|
-
// TODO as of April 2023, no way to import/re-export this ESM type easily :/
|
|
16
|
-
// TODO upgrade to TS 5.3
|
|
17
|
-
// See https://github.com/microsoft/TypeScript/issues/49721#issuecomment-1517839391
|
|
18
|
-
// import type {Plugin} from 'unified';
|
|
19
|
-
type Plugin = any; // TODO fix this asap
|
|
20
|
-
|
|
21
14
|
interface PluginOptions {
|
|
22
15
|
removeContentTitle?: boolean;
|
|
23
16
|
}
|
|
@@ -41,9 +34,9 @@ function wrapHeadingInJsxHeader(
|
|
|
41
34
|
* This is exposed as "data.contentTitle" to the processed vfile
|
|
42
35
|
* Also gives the ability to strip that content title (used for the blog plugin)
|
|
43
36
|
*/
|
|
44
|
-
const plugin: Plugin = function plugin(
|
|
45
|
-
options
|
|
46
|
-
): Transformer {
|
|
37
|
+
const plugin: Plugin<PluginOptions[], Root> = function plugin(
|
|
38
|
+
options = {},
|
|
39
|
+
): Transformer<Root> {
|
|
47
40
|
// content title is
|
|
48
41
|
const removeContentTitle = options.removeContentTitle ?? false;
|
|
49
42
|
|
|
@@ -51,25 +44,26 @@ const plugin: Plugin = function plugin(
|
|
|
51
44
|
const {toString} = await import('mdast-util-to-string');
|
|
52
45
|
const {visit, EXIT} = await import('unist-util-visit');
|
|
53
46
|
visit(root, ['heading', 'thematicBreak'], (node, index, parent) => {
|
|
47
|
+
if (!parent || index === undefined) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
54
50
|
if (node.type === 'heading') {
|
|
55
|
-
const headingNode = node as Heading;
|
|
56
51
|
// console.log('headingNode:', headingNode);
|
|
57
52
|
|
|
58
|
-
if (
|
|
59
|
-
vfile.data.contentTitle = toString(
|
|
53
|
+
if (node.depth === 1) {
|
|
54
|
+
vfile.data.contentTitle = toString(node);
|
|
60
55
|
if (removeContentTitle) {
|
|
61
|
-
|
|
62
|
-
parent!.children.splice(index, 1);
|
|
56
|
+
parent.children.splice(index, 1);
|
|
63
57
|
} else {
|
|
64
58
|
// TODO in the future it might be better to export contentTitle as
|
|
65
59
|
// as JSX node to keep this logic a theme concern?
|
|
66
60
|
// See https://github.com/facebook/docusaurus/pull/10335#issuecomment-2250187371
|
|
67
|
-
wrapHeadingInJsxHeader(
|
|
61
|
+
wrapHeadingInJsxHeader(node, parent, index);
|
|
68
62
|
}
|
|
69
63
|
return EXIT; // We only handle the very first heading
|
|
70
64
|
}
|
|
71
65
|
// We only handle contentTitle if it's the very first heading found
|
|
72
|
-
if (
|
|
66
|
+
if (node.depth >= 1) {
|
|
73
67
|
return EXIT;
|
|
74
68
|
}
|
|
75
69
|
}
|
|
@@ -8,15 +8,14 @@
|
|
|
8
8
|
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
|
|
9
9
|
import type {Transformer} from 'unified';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
import type {MdxJsxFlowElement} from 'mdast-util-mdx';
|
|
11
|
+
import type {Root} from 'mdast';
|
|
13
12
|
|
|
14
13
|
// Transform <details> to <Details>
|
|
15
14
|
// MDX 2 doesn't allow to substitute html elements with the provider anymore
|
|
16
|
-
export default function plugin(): Transformer {
|
|
15
|
+
export default function plugin(): Transformer<Root> {
|
|
17
16
|
return async (root) => {
|
|
18
17
|
const {visit} = await import('unist-util-visit');
|
|
19
|
-
visit(root, 'mdxJsxFlowElement', (node
|
|
18
|
+
visit(root, 'mdxJsxFlowElement', (node) => {
|
|
20
19
|
if (node.name === 'details') {
|
|
21
20
|
node.name = 'Details';
|
|
22
21
|
}
|
package/src/remark/head/index.ts
CHANGED
|
@@ -8,15 +8,14 @@
|
|
|
8
8
|
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
|
|
9
9
|
import type {Transformer} from 'unified';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
import type {MdxJsxFlowElement} from 'mdast-util-mdx';
|
|
11
|
+
import type {Root} from 'mdast';
|
|
13
12
|
|
|
14
13
|
// Transform <head> to <Head>
|
|
15
14
|
// MDX 2 doesn't allow to substitute html elements with the provider anymore
|
|
16
|
-
export default function plugin(): Transformer {
|
|
15
|
+
export default function plugin(): Transformer<Root> {
|
|
17
16
|
return async (root) => {
|
|
18
17
|
const {visit} = await import('unist-util-visit');
|
|
19
|
-
visit(root, 'mdxJsxFlowElement', (node
|
|
18
|
+
visit(root, 'mdxJsxFlowElement', (node) => {
|
|
20
19
|
if (node.name === 'head') {
|
|
21
20
|
node.name = 'Head';
|
|
22
21
|
}
|
|
@@ -9,22 +9,22 @@
|
|
|
9
9
|
|
|
10
10
|
import {parseMarkdownHeadingId, createSlugger} from '@docusaurus/utils';
|
|
11
11
|
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
|
|
12
|
-
import type {Transformer} from 'unified';
|
|
13
|
-
import type {
|
|
12
|
+
import type {Plugin, Transformer} from 'unified';
|
|
13
|
+
import type {Root, Text} from 'mdast';
|
|
14
14
|
|
|
15
15
|
export interface PluginOptions {
|
|
16
16
|
anchorsMaintainCase: boolean;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
const plugin: Plugin<PluginOptions[], Root> = function plugin({
|
|
20
20
|
anchorsMaintainCase,
|
|
21
|
-
}
|
|
21
|
+
}): Transformer<Root> {
|
|
22
22
|
return async (root) => {
|
|
23
23
|
const {toString} = await import('mdast-util-to-string');
|
|
24
24
|
const {visit} = await import('unist-util-visit');
|
|
25
25
|
|
|
26
26
|
const slugs = createSlugger();
|
|
27
|
-
visit(root, 'heading', (headingNode
|
|
27
|
+
visit(root, 'heading', (headingNode) => {
|
|
28
28
|
const data = headingNode.data ?? (headingNode.data = {});
|
|
29
29
|
const properties = (data.hProperties || (data.hProperties = {})) as {
|
|
30
30
|
id: string;
|
|
@@ -77,4 +77,6 @@ export default function plugin({
|
|
|
77
77
|
properties.id = id;
|
|
78
78
|
});
|
|
79
79
|
};
|
|
80
|
-
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default plugin;
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
|
|
9
|
-
import type {Transformer,
|
|
10
|
-
import type {
|
|
9
|
+
import type {Transformer, Plugin} from 'unified';
|
|
10
|
+
import type {Root} from 'mdast';
|
|
11
11
|
|
|
12
12
|
// Solution inspired by https://github.com/pomber/docusaurus-mdx-2/blob/main/packages/mdx-loader/src/remark/codeCompat/index.ts
|
|
13
13
|
// TODO after MDX 2 we probably don't need this - remove soon?
|
|
@@ -16,11 +16,11 @@ import type {Code} from 'mdast';
|
|
|
16
16
|
|
|
17
17
|
// To make theme-classic/src/theme/MDXComponents/Pre work
|
|
18
18
|
// we need to fill two properties that mdx v2 doesn't provide anymore
|
|
19
|
-
|
|
19
|
+
const plugin: Plugin<unknown[], Root> = function plugin(): Transformer<Root> {
|
|
20
20
|
return async (root) => {
|
|
21
21
|
const {visit} = await import('unist-util-visit');
|
|
22
22
|
|
|
23
|
-
visit(root, 'code', (node
|
|
23
|
+
visit(root, 'code', (node) => {
|
|
24
24
|
node.data = node.data || {};
|
|
25
25
|
|
|
26
26
|
node.data.hProperties = node.data.hProperties || {};
|
|
@@ -31,4 +31,6 @@ export default function codeCompatPlugin(this: Processor): Transformer {
|
|
|
31
31
|
node.data.hProperties.live = node.meta?.split(' ').includes('live');
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
-
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default plugin;
|
|
@@ -9,17 +9,17 @@ import {transformNode} from '../utils';
|
|
|
9
9
|
|
|
10
10
|
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
|
|
11
11
|
import type {Transformer} from 'unified';
|
|
12
|
-
import type {
|
|
12
|
+
import type {Root} from 'mdast';
|
|
13
13
|
|
|
14
14
|
// TODO: this plugin shouldn't be in the core MDX loader
|
|
15
15
|
// After we allow plugins to provide Remark/Rehype plugins (see
|
|
16
16
|
// https://github.com/facebook/docusaurus/issues/6370), this should be provided
|
|
17
17
|
// by theme-mermaid itself
|
|
18
|
-
export default function plugin(): Transformer {
|
|
18
|
+
export default function plugin(): Transformer<Root> {
|
|
19
19
|
return async (root) => {
|
|
20
20
|
const {visit} = await import('unist-util-visit');
|
|
21
21
|
|
|
22
|
-
visit(root, 'code', (node
|
|
22
|
+
visit(root, 'code', (node) => {
|
|
23
23
|
if (node.lang === 'mermaid') {
|
|
24
24
|
// TODO migrate to mdxJsxFlowElement? cf admonitions
|
|
25
25
|
transformNode(node, {
|
|
@@ -12,8 +12,8 @@ import {
|
|
|
12
12
|
} from '@docusaurus/utils';
|
|
13
13
|
|
|
14
14
|
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
|
|
15
|
-
import type {Transformer} from 'unified';
|
|
16
|
-
import type {Definition, Link} from 'mdast';
|
|
15
|
+
import type {Plugin, Transformer} from 'unified';
|
|
16
|
+
import type {Definition, Link, Root} from 'mdast';
|
|
17
17
|
|
|
18
18
|
type ResolveMarkdownLinkParams = {
|
|
19
19
|
/**
|
|
@@ -35,12 +35,6 @@ export interface PluginOptions {
|
|
|
35
35
|
resolveMarkdownLink: ResolveMarkdownLink;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
// TODO as of April 2023, no way to import/re-export this ESM type easily :/
|
|
39
|
-
// TODO upgrade to TS 5.3
|
|
40
|
-
// See https://github.com/microsoft/TypeScript/issues/49721#issuecomment-1517839391
|
|
41
|
-
// import type {Plugin} from 'unified';
|
|
42
|
-
type Plugin = any; // TODO fix this asap
|
|
43
|
-
|
|
44
38
|
const HAS_MARKDOWN_EXTENSION = /\.mdx?$/i;
|
|
45
39
|
|
|
46
40
|
function parseMarkdownLinkURLPath(link: string): URLPath | null {
|
|
@@ -64,7 +58,9 @@ function parseMarkdownLinkURLPath(link: string): URLPath | null {
|
|
|
64
58
|
* This is exposed as "data.contentTitle" to the processed vfile
|
|
65
59
|
* Also gives the ability to strip that content title (used for the blog plugin)
|
|
66
60
|
*/
|
|
67
|
-
const plugin: Plugin = function plugin(
|
|
61
|
+
const plugin: Plugin<PluginOptions[], Root> = function plugin(
|
|
62
|
+
options,
|
|
63
|
+
): Transformer<Root> {
|
|
68
64
|
const {resolveMarkdownLink} = options;
|
|
69
65
|
return async (root, file) => {
|
|
70
66
|
const {visit} = await import('unist-util-visit');
|
package/src/remark/toc/index.ts
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from './utils';
|
|
16
16
|
import type {Heading, Root} from 'mdast';
|
|
17
17
|
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
|
|
18
|
-
import type {Transformer} from 'unified';
|
|
18
|
+
import type {Plugin, Transformer} from 'unified';
|
|
19
19
|
import type {
|
|
20
20
|
MdxjsEsm,
|
|
21
21
|
MdxJsxFlowElement,
|
|
@@ -155,7 +155,9 @@ async function collectTOCItems({
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
const plugin: Plugin<PluginOptions[], Root> = function plugin(
|
|
159
|
+
options = {},
|
|
160
|
+
): Transformer<Root> {
|
|
159
161
|
const tocExportName = options.name || 'toc';
|
|
160
162
|
|
|
161
163
|
return async (root) => {
|
|
@@ -184,4 +186,6 @@ export default function plugin(options: PluginOptions = {}): Transformer<Root> {
|
|
|
184
186
|
}),
|
|
185
187
|
);
|
|
186
188
|
};
|
|
187
|
-
}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
export default plugin;
|
|
@@ -21,10 +21,10 @@ import sizeOf from 'image-size';
|
|
|
21
21
|
import logger from '@docusaurus/logger';
|
|
22
22
|
import {assetRequireAttributeValue, transformNode} from '../utils';
|
|
23
23
|
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
|
|
24
|
-
import type {Transformer} from 'unified';
|
|
24
|
+
import type {Plugin, Transformer} from 'unified';
|
|
25
25
|
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
|
|
26
26
|
import type {MdxJsxTextElement} from 'mdast-util-mdx';
|
|
27
|
-
import type {Image} from 'mdast';
|
|
27
|
+
import type {Image, Root} from 'mdast';
|
|
28
28
|
import type {Parent} from 'unist';
|
|
29
29
|
|
|
30
30
|
type PluginOptions = {
|
|
@@ -186,7 +186,9 @@ async function processImageNode(target: Target, context: Context) {
|
|
|
186
186
|
await toImageRequireNode(target, imagePath, context);
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
|
|
189
|
+
const plugin: Plugin<PluginOptions[], Root> = function plugin(
|
|
190
|
+
options,
|
|
191
|
+
): Transformer<Root> {
|
|
190
192
|
return async (root, vfile) => {
|
|
191
193
|
const {visit} = await import('unist-util-visit');
|
|
192
194
|
|
|
@@ -201,9 +203,14 @@ export default function plugin(options: PluginOptions): Transformer {
|
|
|
201
203
|
};
|
|
202
204
|
|
|
203
205
|
const promises: Promise<void>[] = [];
|
|
204
|
-
visit(root, 'image', (node
|
|
206
|
+
visit(root, 'image', (node, index, parent) => {
|
|
207
|
+
if (!parent || index === undefined) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
205
210
|
promises.push(processImageNode([node, index, parent!], context));
|
|
206
211
|
});
|
|
207
212
|
await Promise.all(promises);
|
|
208
213
|
};
|
|
209
|
-
}
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
export default plugin;
|
|
@@ -18,11 +18,11 @@ import {
|
|
|
18
18
|
import escapeHtml from 'escape-html';
|
|
19
19
|
import {assetRequireAttributeValue, transformNode} from '../utils';
|
|
20
20
|
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
|
|
21
|
-
import type {Transformer} from 'unified';
|
|
21
|
+
import type {Plugin, Transformer} from 'unified';
|
|
22
22
|
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
|
|
23
23
|
import type {MdxJsxTextElement} from 'mdast-util-mdx';
|
|
24
24
|
import type {Parent} from 'unist';
|
|
25
|
-
import type {Link, Literal} from 'mdast';
|
|
25
|
+
import type {Link, Literal, Root} from 'mdast';
|
|
26
26
|
|
|
27
27
|
type PluginOptions = {
|
|
28
28
|
staticDirs: string[];
|
|
@@ -199,7 +199,9 @@ async function processLinkNode(target: Target, context: Context) {
|
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
|
|
202
|
+
const plugin: Plugin<PluginOptions[], Root> = function plugin(
|
|
203
|
+
options,
|
|
204
|
+
): Transformer<Root> {
|
|
203
205
|
return async (root, vfile) => {
|
|
204
206
|
const {visit} = await import('unist-util-visit');
|
|
205
207
|
|
|
@@ -214,9 +216,14 @@ export default function plugin(options: PluginOptions): Transformer {
|
|
|
214
216
|
};
|
|
215
217
|
|
|
216
218
|
const promises: Promise<void>[] = [];
|
|
217
|
-
visit(root, 'link', (node
|
|
218
|
-
|
|
219
|
+
visit(root, 'link', (node, index, parent) => {
|
|
220
|
+
if (!parent || index === undefined) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
promises.push(processLinkNode([node, index, parent], context));
|
|
219
224
|
});
|
|
220
225
|
await Promise.all(promises);
|
|
221
226
|
};
|
|
222
|
-
}
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export default plugin;
|
|
@@ -9,21 +9,16 @@ import process from 'process';
|
|
|
9
9
|
import logger from '@docusaurus/logger';
|
|
10
10
|
import {posixPath} from '@docusaurus/utils';
|
|
11
11
|
import {transformNode} from '../utils';
|
|
12
|
+
import type {Root} from 'mdast';
|
|
12
13
|
|
|
13
14
|
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
|
|
14
|
-
import type {Transformer, Processor, Parent} from 'unified';
|
|
15
|
+
import type {Transformer, Processor, Parent, Plugin} from 'unified';
|
|
15
16
|
import type {
|
|
16
17
|
Directives,
|
|
17
18
|
TextDirective,
|
|
18
19
|
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
|
|
19
20
|
} from 'mdast-util-directive';
|
|
20
21
|
|
|
21
|
-
// TODO as of April 2023, no way to import/re-export this ESM type easily :/
|
|
22
|
-
// This might change soon, likely after TS 5.2
|
|
23
|
-
// See https://github.com/microsoft/TypeScript/issues/49721#issuecomment-1517839391
|
|
24
|
-
// import type {Plugin} from 'unified';
|
|
25
|
-
type Plugin = any; // TODO fix this asap
|
|
26
|
-
|
|
27
22
|
type DirectiveType = Directives['type'];
|
|
28
23
|
|
|
29
24
|
const directiveTypes: DirectiveType[] = [
|
|
@@ -130,7 +125,9 @@ function isUnusedDirective(directive: Directives) {
|
|
|
130
125
|
return !directive.data;
|
|
131
126
|
}
|
|
132
127
|
|
|
133
|
-
const plugin: Plugin = function plugin(
|
|
128
|
+
const plugin: Plugin<unknown[], Root> = function plugin(
|
|
129
|
+
this: Processor,
|
|
130
|
+
): Transformer<Root> {
|
|
134
131
|
return async (tree, file) => {
|
|
135
132
|
const {visit} = await import('unist-util-visit');
|
|
136
133
|
|