@readme/markdown 11.7.1 → 11.7.3
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/components/Code/index.tsx +1 -0
- package/components/CodeTabs/index.tsx +3 -1
- package/dist/368.node.js +406 -0
- package/dist/368.node.js.map +1 -0
- package/dist/main.js +354 -62
- package/dist/main.node.js +350 -65
- package/dist/main.node.js.map +1 -1
- package/dist/processor/plugin/toc.d.ts +1 -1
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -11,6 +11,332 @@
|
|
|
11
11
|
return /******/ (() => { // webpackBootstrap
|
|
12
12
|
/******/ var __webpack_modules__ = ({
|
|
13
13
|
|
|
14
|
+
/***/ 9762:
|
|
15
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
16
|
+
|
|
17
|
+
"use strict";
|
|
18
|
+
|
|
19
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
20
|
+
const modeAliases = {
|
|
21
|
+
aspx: 'asp',
|
|
22
|
+
bash: 'shell',
|
|
23
|
+
'c++': 'cplusplus',
|
|
24
|
+
'c#': 'csharp',
|
|
25
|
+
clj: 'clojure',
|
|
26
|
+
cljc: 'clojure',
|
|
27
|
+
cljx: 'clojure',
|
|
28
|
+
coffeescript: 'javascript',
|
|
29
|
+
cpp: 'cplusplus',
|
|
30
|
+
cql: 'sql',
|
|
31
|
+
cs: 'csharp',
|
|
32
|
+
docker: 'dockerfile',
|
|
33
|
+
ecmascript: 'javascript',
|
|
34
|
+
erl: 'erlang',
|
|
35
|
+
gql: 'graphql',
|
|
36
|
+
gradle: 'groovy',
|
|
37
|
+
handlebars: 'html',
|
|
38
|
+
hbs: 'html',
|
|
39
|
+
jl: 'julia',
|
|
40
|
+
jruby: 'ruby',
|
|
41
|
+
js: 'javascript',
|
|
42
|
+
kt: 'kotlin',
|
|
43
|
+
less: 'css',
|
|
44
|
+
macruby: 'ruby',
|
|
45
|
+
md: 'markdown',
|
|
46
|
+
ml: 'ocaml',
|
|
47
|
+
mssql: 'sql',
|
|
48
|
+
mysql: 'sql',
|
|
49
|
+
node: 'javascript',
|
|
50
|
+
'obj-c': 'objectivec',
|
|
51
|
+
'obj-c++': 'objectivecplusplus',
|
|
52
|
+
'objc++': 'objectivecplusplus',
|
|
53
|
+
objc: 'objectivec',
|
|
54
|
+
objcpp: 'objectivecplusplus',
|
|
55
|
+
objectivecpp: 'objectivecplusplus',
|
|
56
|
+
pgsql: 'sql',
|
|
57
|
+
pl: 'perl',
|
|
58
|
+
plsql: 'sql',
|
|
59
|
+
postgres: 'sql',
|
|
60
|
+
postgresql: 'sql',
|
|
61
|
+
ps1: 'powershell',
|
|
62
|
+
py: 'python',
|
|
63
|
+
rake: 'ruby',
|
|
64
|
+
rb: 'ruby',
|
|
65
|
+
rbx: 'ruby',
|
|
66
|
+
rs: 'rust',
|
|
67
|
+
sass: 'css',
|
|
68
|
+
scss: 'css',
|
|
69
|
+
sh: 'shell',
|
|
70
|
+
solidity: 'sol',
|
|
71
|
+
sqlite: 'sql',
|
|
72
|
+
styl: 'css',
|
|
73
|
+
stylus: 'css',
|
|
74
|
+
xhtml: 'html',
|
|
75
|
+
yml: 'yaml',
|
|
76
|
+
zsh: 'shell',
|
|
77
|
+
};
|
|
78
|
+
const canonical = (language) => {
|
|
79
|
+
if (language in modeAliases)
|
|
80
|
+
return modeAliases[language];
|
|
81
|
+
return language;
|
|
82
|
+
};
|
|
83
|
+
exports["default"] = canonical;
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
/***/ }),
|
|
87
|
+
|
|
88
|
+
/***/ 7900:
|
|
89
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
90
|
+
|
|
91
|
+
"use strict";
|
|
92
|
+
|
|
93
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
94
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
95
|
+
};
|
|
96
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
97
|
+
const canonical_1 = __importDefault(__webpack_require__(9762));
|
|
98
|
+
const modes_1 = __webpack_require__(1412);
|
|
99
|
+
const uppercase_1 = __importDefault(__webpack_require__(8892));
|
|
100
|
+
exports["default"] = { uppercase: uppercase_1.default, canonical: canonical_1.default, modes: modes_1.modes, getMode: modes_1.getMode };
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
/***/ }),
|
|
104
|
+
|
|
105
|
+
/***/ 1412:
|
|
106
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
107
|
+
|
|
108
|
+
"use strict";
|
|
109
|
+
|
|
110
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
111
|
+
exports.modes = void 0;
|
|
112
|
+
exports.getMode = getMode;
|
|
113
|
+
// This is a mapping of languages that we support, but aren't directly loading the mode extension
|
|
114
|
+
// Within `/src/codeMirror/index.jsx` and /src/codeEditor.index.jsx
|
|
115
|
+
//
|
|
116
|
+
// This list also includes a number of language aliases, as because of the way we're using
|
|
117
|
+
// `CodeMirror.runMode` we can't take advantage of its known aliases in the mode extensions that
|
|
118
|
+
// we're loading.
|
|
119
|
+
//
|
|
120
|
+
// There are 2 types of lookup, single and array. e.g. `html` needs to be rendered using
|
|
121
|
+
// `htmlmixed`, but `java`, needs to be rendered using the `clike` mode.
|
|
122
|
+
//
|
|
123
|
+
exports.modes = {
|
|
124
|
+
asp: 'clike',
|
|
125
|
+
aspx: 'clike',
|
|
126
|
+
bash: 'shell',
|
|
127
|
+
c: 'clike',
|
|
128
|
+
'c#': ['clike', 'text/x-csharp'],
|
|
129
|
+
'c++': ['clike', 'text/x-c++src'],
|
|
130
|
+
clj: 'clojure',
|
|
131
|
+
cljc: 'clojure',
|
|
132
|
+
cljx: 'clojure',
|
|
133
|
+
coffeescript: 'javascript',
|
|
134
|
+
cplusplus: ['clike', 'text/x-c++src'],
|
|
135
|
+
cpp: ['clike', 'text/x-c++src'],
|
|
136
|
+
cql: ['sql', 'text/x-cassandra'],
|
|
137
|
+
cs: ['clike', 'text/x-csharp'],
|
|
138
|
+
csharp: ['clike', 'text/x-csharp'],
|
|
139
|
+
curl: 'shell',
|
|
140
|
+
d: 'd',
|
|
141
|
+
diff: 'diff',
|
|
142
|
+
ecmascript: 'javascript',
|
|
143
|
+
erl: 'erlang',
|
|
144
|
+
go: ['go', 'text/x-go'],
|
|
145
|
+
gradle: 'groovy',
|
|
146
|
+
gql: 'graphql',
|
|
147
|
+
handlebars: 'htmlmixed',
|
|
148
|
+
hbs: 'htmlmixed',
|
|
149
|
+
html: 'htmlmixed',
|
|
150
|
+
java: ['clike', 'text/x-java'],
|
|
151
|
+
jl: 'julia',
|
|
152
|
+
js: 'javascript',
|
|
153
|
+
jsx: 'jsx',
|
|
154
|
+
json: ['javascript', 'application/ld+json'],
|
|
155
|
+
jruby: 'ruby',
|
|
156
|
+
kotlin: ['clike', 'text/x-kotlin'],
|
|
157
|
+
kt: ['clike', 'text/x-kotlin'],
|
|
158
|
+
less: 'css',
|
|
159
|
+
liquid: 'htmlmixed',
|
|
160
|
+
lua: 'lua',
|
|
161
|
+
node: 'javascript',
|
|
162
|
+
macruby: 'ruby',
|
|
163
|
+
markdown: 'gfm',
|
|
164
|
+
ml: ['mllike', 'text/x-ocaml'],
|
|
165
|
+
mssql: ['sql', 'text/x-mssql'],
|
|
166
|
+
mysql: ['sql', 'text/x-mysql'],
|
|
167
|
+
objc: ['clike', 'text/x-objectivec'],
|
|
168
|
+
'objc++': ['clike', 'text/x-objectivec++'],
|
|
169
|
+
objcpp: ['clike', 'text/x-objectivec++'],
|
|
170
|
+
objectivec: ['clike', 'text/x-objectivec'],
|
|
171
|
+
objectivecpp: ['clike', 'text/x-objectivec++'],
|
|
172
|
+
objectivecplusplus: ['clike', 'text/x-objectivec++'],
|
|
173
|
+
ocaml: ['mllike', 'text/x-ocaml'],
|
|
174
|
+
php: ['php', 'text/x-php'],
|
|
175
|
+
pgsql: ['sql', 'text/x-pgsql'],
|
|
176
|
+
pl: 'perl',
|
|
177
|
+
plsql: ['sql', 'text/x-plsql'],
|
|
178
|
+
postgres: ['sql', 'text/x-pgsql'],
|
|
179
|
+
postgresql: ['sql', 'text/x-pgsql'],
|
|
180
|
+
ps1: 'powershell',
|
|
181
|
+
py: 'python',
|
|
182
|
+
r: 'r',
|
|
183
|
+
rake: 'ruby',
|
|
184
|
+
rb: 'ruby',
|
|
185
|
+
rbx: 'ruby',
|
|
186
|
+
rs: 'rust',
|
|
187
|
+
sass: 'css',
|
|
188
|
+
scala: ['clike', 'text/x-scala'],
|
|
189
|
+
scss: 'css',
|
|
190
|
+
sh: 'shell',
|
|
191
|
+
sol: 'solidity',
|
|
192
|
+
solidity: 'solidity',
|
|
193
|
+
sql: ['sql', 'text/x-sql'],
|
|
194
|
+
sqlite: ['sql', 'text/x-sqlite'],
|
|
195
|
+
styl: 'css',
|
|
196
|
+
stylus: 'css',
|
|
197
|
+
text: ['null', 'text/plain'],
|
|
198
|
+
ts: ['javascript', 'text/typescript'],
|
|
199
|
+
typescript: ['javascript', 'text/typescript'],
|
|
200
|
+
xhtml: 'htmlmixed',
|
|
201
|
+
yml: 'yaml',
|
|
202
|
+
zsh: 'shell',
|
|
203
|
+
};
|
|
204
|
+
function getMode(lang) {
|
|
205
|
+
let mode = lang;
|
|
206
|
+
if (mode in exports.modes) {
|
|
207
|
+
mode = exports.modes[mode];
|
|
208
|
+
if (Array.isArray(mode)) {
|
|
209
|
+
[, mode] = mode;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return mode;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
/***/ }),
|
|
217
|
+
|
|
218
|
+
/***/ 8892:
|
|
219
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
220
|
+
|
|
221
|
+
"use strict";
|
|
222
|
+
|
|
223
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
224
|
+
exports["default"] = uppercase;
|
|
225
|
+
const codeTypes = {
|
|
226
|
+
asp: 'ASP.NET',
|
|
227
|
+
aspx: 'ASP.NET',
|
|
228
|
+
bash: 'Bash',
|
|
229
|
+
c: 'C',
|
|
230
|
+
'c#': 'C#',
|
|
231
|
+
'c++': 'C++',
|
|
232
|
+
coffeescript: 'CoffeeScript',
|
|
233
|
+
clj: 'Clojure',
|
|
234
|
+
cljc: 'Clojure',
|
|
235
|
+
cljx: 'Clojure',
|
|
236
|
+
clojure: 'Clojure',
|
|
237
|
+
cplusplus: 'C++',
|
|
238
|
+
cpp: 'C++',
|
|
239
|
+
cql: 'Cassandra',
|
|
240
|
+
cs: 'C#',
|
|
241
|
+
csharp: 'C#',
|
|
242
|
+
css: 'CSS',
|
|
243
|
+
curl: 'cURL',
|
|
244
|
+
d: 'D',
|
|
245
|
+
dart: 'Dart',
|
|
246
|
+
diff: 'Diff',
|
|
247
|
+
dockerfile: 'Dockerfile',
|
|
248
|
+
ecmascript: 'ECMAScript',
|
|
249
|
+
erl: 'Erlang',
|
|
250
|
+
erlang: 'Erlang',
|
|
251
|
+
go: 'Go',
|
|
252
|
+
gql: 'GraphQL',
|
|
253
|
+
gradle: 'Gradle',
|
|
254
|
+
graphql: 'GraphQL',
|
|
255
|
+
groovy: 'Groovy',
|
|
256
|
+
handlebars: 'Handlebars',
|
|
257
|
+
hbs: 'Handlebars',
|
|
258
|
+
haml: 'HAML',
|
|
259
|
+
haxe: 'Haxe',
|
|
260
|
+
html: 'HTML',
|
|
261
|
+
http: 'HTTP',
|
|
262
|
+
java: 'Java',
|
|
263
|
+
javascript: 'JavaScript',
|
|
264
|
+
jinja2: 'Jinja2',
|
|
265
|
+
jl: 'Julia',
|
|
266
|
+
jruby: 'JRuby',
|
|
267
|
+
js: 'JavaScript',
|
|
268
|
+
json: 'JSON',
|
|
269
|
+
jsx: 'JSX',
|
|
270
|
+
julia: 'Julia',
|
|
271
|
+
kotlin: 'Kotlin',
|
|
272
|
+
kt: 'Kotlin',
|
|
273
|
+
less: 'LESS',
|
|
274
|
+
liquid: 'Liquid',
|
|
275
|
+
lua: 'Lua',
|
|
276
|
+
macruby: 'MacRuby',
|
|
277
|
+
markdown: 'Markdown',
|
|
278
|
+
md: 'Markdown',
|
|
279
|
+
mermaid: 'Mermaid', // syntax highlighting not supported yet
|
|
280
|
+
ml: 'OCaml',
|
|
281
|
+
mssql: 'SQL Server',
|
|
282
|
+
mysql: 'MySQL',
|
|
283
|
+
node: 'Node',
|
|
284
|
+
objc: 'Objective-C',
|
|
285
|
+
'objc++': 'Objective-C++',
|
|
286
|
+
objcpp: 'Objective-C++',
|
|
287
|
+
objectivec: 'Objective-C',
|
|
288
|
+
objectivecpp: 'Objective-C++',
|
|
289
|
+
objectivecplusplus: 'Objective-C++',
|
|
290
|
+
ocaml: 'OCaml',
|
|
291
|
+
perl: 'Perl',
|
|
292
|
+
php: 'PHP',
|
|
293
|
+
pl: 'Perl',
|
|
294
|
+
pgsql: 'PL/pgSQL',
|
|
295
|
+
plsql: 'PL/SQL',
|
|
296
|
+
postgres: 'PostgreSQL',
|
|
297
|
+
postgresql: 'PostgreSQL',
|
|
298
|
+
powershell: 'PowerShell',
|
|
299
|
+
ps1: 'PowerShell',
|
|
300
|
+
python: 'Python',
|
|
301
|
+
py: 'Python',
|
|
302
|
+
r: 'R',
|
|
303
|
+
rake: 'Rake',
|
|
304
|
+
rb: 'Ruby',
|
|
305
|
+
rbx: 'Rubinius',
|
|
306
|
+
rs: 'Rust',
|
|
307
|
+
ruby: 'Ruby',
|
|
308
|
+
rust: 'Rust',
|
|
309
|
+
sass: 'Sass',
|
|
310
|
+
scala: 'Scala',
|
|
311
|
+
scss: 'SCSS',
|
|
312
|
+
sh: 'Shell',
|
|
313
|
+
shell: 'Shell',
|
|
314
|
+
smarty: 'Smarty',
|
|
315
|
+
solidity: 'Solidity',
|
|
316
|
+
sql: 'SQL',
|
|
317
|
+
sqlite: 'SQLite',
|
|
318
|
+
stylus: 'Stylus',
|
|
319
|
+
styl: 'Stylus',
|
|
320
|
+
swift: 'Swift',
|
|
321
|
+
text: 'Text',
|
|
322
|
+
toml: 'TOML',
|
|
323
|
+
twig: 'Twig',
|
|
324
|
+
typescript: 'TypeScript',
|
|
325
|
+
xhtml: 'XHTML',
|
|
326
|
+
xml: 'XML',
|
|
327
|
+
yaml: 'YAML',
|
|
328
|
+
yml: 'YAML',
|
|
329
|
+
zsh: 'Zsh',
|
|
330
|
+
};
|
|
331
|
+
function uppercase(language) {
|
|
332
|
+
if (language in codeTypes)
|
|
333
|
+
return codeTypes[language];
|
|
334
|
+
return language;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
/***/ }),
|
|
339
|
+
|
|
14
340
|
/***/ 9214:
|
|
15
341
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
16
342
|
|
|
@@ -8620,7 +8946,7 @@ module.exports = { nanoid, customAlphabet }
|
|
|
8620
8946
|
/******/ };
|
|
8621
8947
|
/******/
|
|
8622
8948
|
/******/ // Execute the module function
|
|
8623
|
-
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
8949
|
+
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
8624
8950
|
/******/
|
|
8625
8951
|
/******/ // Return the exports of the module
|
|
8626
8952
|
/******/ return module.exports;
|
|
@@ -8974,6 +9300,7 @@ let syntaxHighlighter;
|
|
|
8974
9300
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8975
9301
|
let canonicalLanguage = lang => '';
|
|
8976
9302
|
if (typeof window !== 'undefined') {
|
|
9303
|
+
// @ts-expect-error this library does not have any types defined
|
|
8977
9304
|
Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 3966, 23)).then(module => {
|
|
8978
9305
|
syntaxHighlighter = module.default;
|
|
8979
9306
|
canonicalLanguage = module.canonical;
|
|
@@ -9017,13 +9344,15 @@ const Code = (props) => {
|
|
|
9017
9344
|
};
|
|
9018
9345
|
/* harmony default export */ const components_Code = (Code);
|
|
9019
9346
|
|
|
9020
|
-
// EXTERNAL MODULE:
|
|
9021
|
-
var
|
|
9347
|
+
// EXTERNAL MODULE: ./node_modules/@readme/syntax-highlighter/dist-utils/index.js
|
|
9348
|
+
var dist_utils = __webpack_require__(7900);
|
|
9349
|
+
var dist_utils_default = /*#__PURE__*/__webpack_require__.n(dist_utils);
|
|
9022
9350
|
;// ./components/CodeTabs/index.tsx
|
|
9023
9351
|
|
|
9024
9352
|
|
|
9025
9353
|
|
|
9026
9354
|
let mermaid;
|
|
9355
|
+
const { uppercase } = (dist_utils_default());
|
|
9027
9356
|
const CodeTabs = (props) => {
|
|
9028
9357
|
const { children } = props;
|
|
9029
9358
|
const theme = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.useContext)(Theme);
|
|
@@ -9061,7 +9390,7 @@ const CodeTabs = (props) => {
|
|
|
9061
9390
|
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "CodeTabs-toolbar" }, (Array.isArray(children) ? children : [children]).map((pre, i) => {
|
|
9062
9391
|
const { meta, lang } = pre.props.children.props;
|
|
9063
9392
|
/* istanbul ignore next */
|
|
9064
|
-
return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("button", { key: i, onClick: e => handleClick(e, i), type: "button", value: lang }, meta || `${!lang ? 'Text' :
|
|
9393
|
+
return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("button", { key: i, onClick: e => handleClick(e, i), type: "button", value: lang }, meta || `${!lang ? 'Text' : uppercase(lang)}`));
|
|
9065
9394
|
})),
|
|
9066
9395
|
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "CodeTabs-inner" }, children)));
|
|
9067
9396
|
};
|
|
@@ -82659,59 +82988,16 @@ const lib_s = create_h_createH(node_modules_property_information_svg, 'g', svg_c
|
|
|
82659
82988
|
|
|
82660
82989
|
|
|
82661
82990
|
|
|
82662
|
-
|
|
82663
|
-
|
|
82664
|
-
|
|
82665
|
-
|
|
82666
|
-
const { type, name, tagName, data, properties } = node;
|
|
82667
|
-
if (type === 'mdxJsxFlowElement' && name === 'Callout') {
|
|
82668
|
-
return true;
|
|
82669
|
-
}
|
|
82670
|
-
if (type !== 'element')
|
|
82671
|
-
return false;
|
|
82672
|
-
if (tagName === 'Callout')
|
|
82673
|
-
return true;
|
|
82674
|
-
if (typeof data === 'object' && data && 'hName' in data) {
|
|
82675
|
-
const { hName } = data;
|
|
82676
|
-
if (hName === 'Callout')
|
|
82677
|
-
return true;
|
|
82678
|
-
}
|
|
82679
|
-
if (tagName !== 'blockquote')
|
|
82680
|
-
return false;
|
|
82681
|
-
if (!properties || typeof properties !== 'object')
|
|
82682
|
-
return false;
|
|
82683
|
-
const { className } = properties;
|
|
82684
|
-
if (!className)
|
|
82685
|
-
return false;
|
|
82686
|
-
if (Array.isArray(className)) {
|
|
82687
|
-
return className.some(cls => typeof cls === 'string' && cls.startsWith('callout'));
|
|
82688
|
-
}
|
|
82689
|
-
if (typeof className === 'string') {
|
|
82690
|
-
return className.includes('callout');
|
|
82691
|
-
}
|
|
82692
|
-
return false;
|
|
82693
|
-
};
|
|
82991
|
+
/*
|
|
82992
|
+
* A rehype plugin to generate a flat list of top-level headings or jsx flow
|
|
82993
|
+
* elements.
|
|
82994
|
+
*/
|
|
82694
82995
|
const rehypeToc = ({ components = {} }) => {
|
|
82695
82996
|
return (tree) => {
|
|
82696
82997
|
if (hasNamedExport(tree, 'toc'))
|
|
82697
82998
|
return;
|
|
82698
|
-
const headings = []
|
|
82699
|
-
|
|
82700
|
-
if (isCalloutNode(node)) {
|
|
82701
|
-
return SKIP;
|
|
82702
|
-
}
|
|
82703
|
-
const insideCallout = parent ? isCalloutNode(parent) : false;
|
|
82704
|
-
if (insideCallout) {
|
|
82705
|
-
return undefined;
|
|
82706
|
-
}
|
|
82707
|
-
if (node.type === 'element' && ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(node.tagName)) {
|
|
82708
|
-
headings.push(node);
|
|
82709
|
-
}
|
|
82710
|
-
if (node.type === 'mdxJsxFlowElement' && node.name && node.name in components) {
|
|
82711
|
-
headings.push(node);
|
|
82712
|
-
}
|
|
82713
|
-
return undefined;
|
|
82714
|
-
});
|
|
82999
|
+
const headings = tree.children.filter(child => (child.type === 'element' && ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(child.tagName)) ||
|
|
83000
|
+
(child.type === 'mdxJsxFlowElement' && child.name in components));
|
|
82715
83001
|
tree.children.unshift({
|
|
82716
83002
|
type: 'mdxjsEsm',
|
|
82717
83003
|
data: {
|
|
@@ -82743,6 +83029,10 @@ const rehypeToc = ({ components = {} }) => {
|
|
|
82743
83029
|
};
|
|
82744
83030
|
const MAX_DEPTH = 2;
|
|
82745
83031
|
const getDepth = (el) => parseInt(el.tagName?.match(/^h(\d)/)[1], 10);
|
|
83032
|
+
/*
|
|
83033
|
+
* `tocToHast` consumes the list generated by `rehypeToc` and produces a hast
|
|
83034
|
+
* of nested lists to be rendered as a table of contents.
|
|
83035
|
+
*/
|
|
82746
83036
|
const tocToHast = (headings = []) => {
|
|
82747
83037
|
const min = Math.min(...headings.map(getDepth));
|
|
82748
83038
|
const ast = hastscript_lib_h('ul');
|
|
@@ -82766,17 +83056,19 @@ const tocToHast = (headings = []) => {
|
|
|
82766
83056
|
});
|
|
82767
83057
|
return ast;
|
|
82768
83058
|
};
|
|
83059
|
+
/*
|
|
83060
|
+
* `tocHastToMdx` is a utility for combining `TocList`s of a root document and
|
|
83061
|
+
* any child components it may have. Once combined it will generate a markdown
|
|
83062
|
+
* doc representing a table of contents.
|
|
83063
|
+
*/
|
|
82769
83064
|
const tocHastToMdx = (toc, components) => {
|
|
82770
|
-
|
|
82771
|
-
|
|
82772
|
-
|
|
82773
|
-
|
|
83065
|
+
if (typeof toc === 'undefined')
|
|
83066
|
+
return '';
|
|
83067
|
+
const injected = toc.flatMap(node => {
|
|
83068
|
+
return node.type === 'mdxJsxFlowElement' && node.name in components ? components[node.name] || [] : node;
|
|
82774
83069
|
});
|
|
82775
|
-
const tocHast = tocToHast(
|
|
82776
|
-
|
|
82777
|
-
// to cast it to Root. But I think there's something wrong with our
|
|
82778
|
-
// RootContentMap type.
|
|
82779
|
-
return lib_mdx(tocHast, { hast: true });
|
|
83070
|
+
const tocHast = tocToHast(injected);
|
|
83071
|
+
return lib_mdx({ type: 'root', children: [tocHast] }, { hast: true });
|
|
82780
83072
|
};
|
|
82781
83073
|
|
|
82782
83074
|
;// ./lib/compile.ts
|