@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/dist/main.node.js CHANGED
@@ -1,10 +1,329 @@
1
1
  /******/ (() => { // webpackBootstrap
2
2
  /******/ var __webpack_modules__ = ({
3
3
 
4
- /***/ 3368:
5
- /***/ ((module) => {
4
+ /***/ 9762:
5
+ /***/ ((__unused_webpack_module, exports) => {
6
+
7
+ "use strict";
8
+
9
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
10
+ const modeAliases = {
11
+ aspx: 'asp',
12
+ bash: 'shell',
13
+ 'c++': 'cplusplus',
14
+ 'c#': 'csharp',
15
+ clj: 'clojure',
16
+ cljc: 'clojure',
17
+ cljx: 'clojure',
18
+ coffeescript: 'javascript',
19
+ cpp: 'cplusplus',
20
+ cql: 'sql',
21
+ cs: 'csharp',
22
+ docker: 'dockerfile',
23
+ ecmascript: 'javascript',
24
+ erl: 'erlang',
25
+ gql: 'graphql',
26
+ gradle: 'groovy',
27
+ handlebars: 'html',
28
+ hbs: 'html',
29
+ jl: 'julia',
30
+ jruby: 'ruby',
31
+ js: 'javascript',
32
+ kt: 'kotlin',
33
+ less: 'css',
34
+ macruby: 'ruby',
35
+ md: 'markdown',
36
+ ml: 'ocaml',
37
+ mssql: 'sql',
38
+ mysql: 'sql',
39
+ node: 'javascript',
40
+ 'obj-c': 'objectivec',
41
+ 'obj-c++': 'objectivecplusplus',
42
+ 'objc++': 'objectivecplusplus',
43
+ objc: 'objectivec',
44
+ objcpp: 'objectivecplusplus',
45
+ objectivecpp: 'objectivecplusplus',
46
+ pgsql: 'sql',
47
+ pl: 'perl',
48
+ plsql: 'sql',
49
+ postgres: 'sql',
50
+ postgresql: 'sql',
51
+ ps1: 'powershell',
52
+ py: 'python',
53
+ rake: 'ruby',
54
+ rb: 'ruby',
55
+ rbx: 'ruby',
56
+ rs: 'rust',
57
+ sass: 'css',
58
+ scss: 'css',
59
+ sh: 'shell',
60
+ solidity: 'sol',
61
+ sqlite: 'sql',
62
+ styl: 'css',
63
+ stylus: 'css',
64
+ xhtml: 'html',
65
+ yml: 'yaml',
66
+ zsh: 'shell',
67
+ };
68
+ const canonical = (language) => {
69
+ if (language in modeAliases)
70
+ return modeAliases[language];
71
+ return language;
72
+ };
73
+ exports["default"] = canonical;
74
+
75
+
76
+ /***/ }),
77
+
78
+ /***/ 7900:
79
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
80
+
81
+ "use strict";
82
+
83
+ var __importDefault = (this && this.__importDefault) || function (mod) {
84
+ return (mod && mod.__esModule) ? mod : { "default": mod };
85
+ };
86
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
87
+ const canonical_1 = __importDefault(__webpack_require__(9762));
88
+ const modes_1 = __webpack_require__(1412);
89
+ const uppercase_1 = __importDefault(__webpack_require__(8892));
90
+ exports["default"] = { uppercase: uppercase_1.default, canonical: canonical_1.default, modes: modes_1.modes, getMode: modes_1.getMode };
91
+
92
+
93
+ /***/ }),
94
+
95
+ /***/ 1412:
96
+ /***/ ((__unused_webpack_module, exports) => {
97
+
98
+ "use strict";
99
+
100
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
101
+ exports.modes = void 0;
102
+ exports.getMode = getMode;
103
+ // This is a mapping of languages that we support, but aren't directly loading the mode extension
104
+ // Within `/src/codeMirror/index.jsx` and /src/codeEditor.index.jsx
105
+ //
106
+ // This list also includes a number of language aliases, as because of the way we're using
107
+ // `CodeMirror.runMode` we can't take advantage of its known aliases in the mode extensions that
108
+ // we're loading.
109
+ //
110
+ // There are 2 types of lookup, single and array. e.g. `html` needs to be rendered using
111
+ // `htmlmixed`, but `java`, needs to be rendered using the `clike` mode.
112
+ //
113
+ exports.modes = {
114
+ asp: 'clike',
115
+ aspx: 'clike',
116
+ bash: 'shell',
117
+ c: 'clike',
118
+ 'c#': ['clike', 'text/x-csharp'],
119
+ 'c++': ['clike', 'text/x-c++src'],
120
+ clj: 'clojure',
121
+ cljc: 'clojure',
122
+ cljx: 'clojure',
123
+ coffeescript: 'javascript',
124
+ cplusplus: ['clike', 'text/x-c++src'],
125
+ cpp: ['clike', 'text/x-c++src'],
126
+ cql: ['sql', 'text/x-cassandra'],
127
+ cs: ['clike', 'text/x-csharp'],
128
+ csharp: ['clike', 'text/x-csharp'],
129
+ curl: 'shell',
130
+ d: 'd',
131
+ diff: 'diff',
132
+ ecmascript: 'javascript',
133
+ erl: 'erlang',
134
+ go: ['go', 'text/x-go'],
135
+ gradle: 'groovy',
136
+ gql: 'graphql',
137
+ handlebars: 'htmlmixed',
138
+ hbs: 'htmlmixed',
139
+ html: 'htmlmixed',
140
+ java: ['clike', 'text/x-java'],
141
+ jl: 'julia',
142
+ js: 'javascript',
143
+ jsx: 'jsx',
144
+ json: ['javascript', 'application/ld+json'],
145
+ jruby: 'ruby',
146
+ kotlin: ['clike', 'text/x-kotlin'],
147
+ kt: ['clike', 'text/x-kotlin'],
148
+ less: 'css',
149
+ liquid: 'htmlmixed',
150
+ lua: 'lua',
151
+ node: 'javascript',
152
+ macruby: 'ruby',
153
+ markdown: 'gfm',
154
+ ml: ['mllike', 'text/x-ocaml'],
155
+ mssql: ['sql', 'text/x-mssql'],
156
+ mysql: ['sql', 'text/x-mysql'],
157
+ objc: ['clike', 'text/x-objectivec'],
158
+ 'objc++': ['clike', 'text/x-objectivec++'],
159
+ objcpp: ['clike', 'text/x-objectivec++'],
160
+ objectivec: ['clike', 'text/x-objectivec'],
161
+ objectivecpp: ['clike', 'text/x-objectivec++'],
162
+ objectivecplusplus: ['clike', 'text/x-objectivec++'],
163
+ ocaml: ['mllike', 'text/x-ocaml'],
164
+ php: ['php', 'text/x-php'],
165
+ pgsql: ['sql', 'text/x-pgsql'],
166
+ pl: 'perl',
167
+ plsql: ['sql', 'text/x-plsql'],
168
+ postgres: ['sql', 'text/x-pgsql'],
169
+ postgresql: ['sql', 'text/x-pgsql'],
170
+ ps1: 'powershell',
171
+ py: 'python',
172
+ r: 'r',
173
+ rake: 'ruby',
174
+ rb: 'ruby',
175
+ rbx: 'ruby',
176
+ rs: 'rust',
177
+ sass: 'css',
178
+ scala: ['clike', 'text/x-scala'],
179
+ scss: 'css',
180
+ sh: 'shell',
181
+ sol: 'solidity',
182
+ solidity: 'solidity',
183
+ sql: ['sql', 'text/x-sql'],
184
+ sqlite: ['sql', 'text/x-sqlite'],
185
+ styl: 'css',
186
+ stylus: 'css',
187
+ text: ['null', 'text/plain'],
188
+ ts: ['javascript', 'text/typescript'],
189
+ typescript: ['javascript', 'text/typescript'],
190
+ xhtml: 'htmlmixed',
191
+ yml: 'yaml',
192
+ zsh: 'shell',
193
+ };
194
+ function getMode(lang) {
195
+ let mode = lang;
196
+ if (mode in exports.modes) {
197
+ mode = exports.modes[mode];
198
+ if (Array.isArray(mode)) {
199
+ [, mode] = mode;
200
+ }
201
+ }
202
+ return mode;
203
+ }
204
+
205
+
206
+ /***/ }),
207
+
208
+ /***/ 8892:
209
+ /***/ ((__unused_webpack_module, exports) => {
210
+
211
+ "use strict";
212
+
213
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
214
+ exports["default"] = uppercase;
215
+ const codeTypes = {
216
+ asp: 'ASP.NET',
217
+ aspx: 'ASP.NET',
218
+ bash: 'Bash',
219
+ c: 'C',
220
+ 'c#': 'C#',
221
+ 'c++': 'C++',
222
+ coffeescript: 'CoffeeScript',
223
+ clj: 'Clojure',
224
+ cljc: 'Clojure',
225
+ cljx: 'Clojure',
226
+ clojure: 'Clojure',
227
+ cplusplus: 'C++',
228
+ cpp: 'C++',
229
+ cql: 'Cassandra',
230
+ cs: 'C#',
231
+ csharp: 'C#',
232
+ css: 'CSS',
233
+ curl: 'cURL',
234
+ d: 'D',
235
+ dart: 'Dart',
236
+ diff: 'Diff',
237
+ dockerfile: 'Dockerfile',
238
+ ecmascript: 'ECMAScript',
239
+ erl: 'Erlang',
240
+ erlang: 'Erlang',
241
+ go: 'Go',
242
+ gql: 'GraphQL',
243
+ gradle: 'Gradle',
244
+ graphql: 'GraphQL',
245
+ groovy: 'Groovy',
246
+ handlebars: 'Handlebars',
247
+ hbs: 'Handlebars',
248
+ haml: 'HAML',
249
+ haxe: 'Haxe',
250
+ html: 'HTML',
251
+ http: 'HTTP',
252
+ java: 'Java',
253
+ javascript: 'JavaScript',
254
+ jinja2: 'Jinja2',
255
+ jl: 'Julia',
256
+ jruby: 'JRuby',
257
+ js: 'JavaScript',
258
+ json: 'JSON',
259
+ jsx: 'JSX',
260
+ julia: 'Julia',
261
+ kotlin: 'Kotlin',
262
+ kt: 'Kotlin',
263
+ less: 'LESS',
264
+ liquid: 'Liquid',
265
+ lua: 'Lua',
266
+ macruby: 'MacRuby',
267
+ markdown: 'Markdown',
268
+ md: 'Markdown',
269
+ mermaid: 'Mermaid', // syntax highlighting not supported yet
270
+ ml: 'OCaml',
271
+ mssql: 'SQL Server',
272
+ mysql: 'MySQL',
273
+ node: 'Node',
274
+ objc: 'Objective-C',
275
+ 'objc++': 'Objective-C++',
276
+ objcpp: 'Objective-C++',
277
+ objectivec: 'Objective-C',
278
+ objectivecpp: 'Objective-C++',
279
+ objectivecplusplus: 'Objective-C++',
280
+ ocaml: 'OCaml',
281
+ perl: 'Perl',
282
+ php: 'PHP',
283
+ pl: 'Perl',
284
+ pgsql: 'PL/pgSQL',
285
+ plsql: 'PL/SQL',
286
+ postgres: 'PostgreSQL',
287
+ postgresql: 'PostgreSQL',
288
+ powershell: 'PowerShell',
289
+ ps1: 'PowerShell',
290
+ python: 'Python',
291
+ py: 'Python',
292
+ r: 'R',
293
+ rake: 'Rake',
294
+ rb: 'Ruby',
295
+ rbx: 'Rubinius',
296
+ rs: 'Rust',
297
+ ruby: 'Ruby',
298
+ rust: 'Rust',
299
+ sass: 'Sass',
300
+ scala: 'Scala',
301
+ scss: 'SCSS',
302
+ sh: 'Shell',
303
+ shell: 'Shell',
304
+ smarty: 'Smarty',
305
+ solidity: 'Solidity',
306
+ sql: 'SQL',
307
+ sqlite: 'SQLite',
308
+ stylus: 'Stylus',
309
+ styl: 'Stylus',
310
+ swift: 'Swift',
311
+ text: 'Text',
312
+ toml: 'TOML',
313
+ twig: 'Twig',
314
+ typescript: 'TypeScript',
315
+ xhtml: 'XHTML',
316
+ xml: 'XML',
317
+ yaml: 'YAML',
318
+ yml: 'YAML',
319
+ zsh: 'Zsh',
320
+ };
321
+ function uppercase(language) {
322
+ if (language in codeTypes)
323
+ return codeTypes[language];
324
+ return language;
325
+ }
6
326
 
7
- (()=>{var e={226:e=>{var l={aspx:"asp",bash:"shell","c++":"cplusplus","c#":"csharp",clj:"clojure",cljc:"clojure",cljx:"clojure",coffeescript:"javascript",cpp:"cplusplus",cql:"sql",cs:"csharp",docker:"dockerfile",ecmascript:"javascript",erl:"erlang",gql:"graphql",gradle:"groovy",handlebars:"html",hbs:"html",jl:"julia",jruby:"ruby",js:"javascript",kt:"kotlin",less:"css",macruby:"ruby",md:"markdown",ml:"ocaml",mssql:"sql",mysql:"sql",node:"javascript","obj-c":"objectivec","obj-c++":"objectivecplusplus","objc++":"objectivecplusplus",objc:"objectivec",objcpp:"objectivecplusplus",objectivecpp:"objectivecplusplus",pgsql:"sql",pl:"perl",plsql:"sql",postgres:"sql",postgresql:"sql",ps1:"powershell",py:"python",rake:"ruby",rb:"ruby",rbx:"ruby",rs:"rust",sass:"css",scss:"css",sh:"shell",solidity:"sol",sqlite:"sql",styl:"css",stylus:"css",xhtml:"html",yml:"yaml",zsh:"shell"};e.exports=function(e){return e in l?l[e]:e}},548:e=>{var l={asp:"ASP.NET",aspx:"ASP.NET",bash:"Bash",c:"C","c#":"C#","c++":"C++",coffeescript:"CoffeeScript",clj:"Clojure",cljc:"Clojure",cljx:"Clojure",clojure:"Clojure",cplusplus:"C++",cpp:"C++",cql:"Cassandra",cs:"C#",csharp:"C#",css:"CSS",curl:"cURL",d:"D",dart:"Dart",diff:"Diff",dockerfile:"Dockerfile",ecmascript:"ECMAScript",erl:"Erlang",erlang:"Erlang",go:"Go",gql:"GraphQL",gradle:"Gradle",graphql:"GraphQL",groovy:"Groovy",handlebars:"Handlebars",hbs:"Handlebars",haml:"HAML",haxe:"Haxe",html:"HTML",http:"HTTP",java:"Java",javascript:"JavaScript",jinja2:"Jinja2",jl:"Julia",jruby:"JRuby",js:"JavaScript",json:"JSON",jsx:"JSX",julia:"Julia",kotlin:"Kotlin",kt:"Kotlin",less:"LESS",liquid:"Liquid",lua:"Lua",macruby:"MacRuby",markdown:"Markdown",md:"Markdown",mermaid:"Mermaid",ml:"OCaml",mssql:"SQL Server",mysql:"MySQL",node:"Node",objc:"Objective-C","objc++":"Objective-C++",objcpp:"Objective-C++",objectivec:"Objective-C",objectivecpp:"Objective-C++",objectivecplusplus:"Objective-C++",ocaml:"OCaml",perl:"Perl",php:"PHP",pl:"Perl",pgsql:"PL/pgSQL",plsql:"PL/SQL",postgres:"PostgreSQL",postgresql:"PostgreSQL",powershell:"PowerShell",ps1:"PowerShell",python:"Python",py:"Python",r:"R",rake:"Rake",rb:"Ruby",rbx:"Rubinius",rs:"Rust",ruby:"Ruby",rust:"Rust",sass:"Sass",scala:"Scala",scss:"SCSS",sh:"Shell",shell:"Shell",smarty:"Smarty",solidity:"Solidity",sql:"SQL",sqlite:"SQLite",stylus:"Stylus",styl:"Stylus",swift:"Swift",text:"Text",toml:"TOML",twig:"Twig",typescript:"TypeScript",xhtml:"XHTML",xml:"XML",yaml:"YAML",yml:"YAML",zsh:"Zsh"};e.exports=function(e){return e in l?l[e]:e}},980:e=>{function l(e,l){return function(e){if(Array.isArray(e))return e}(e)||function(e,l){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var s,r,c,a,o=[],i=!0,p=!1;try{if(c=(t=t.call(e)).next,0===l){if(Object(t)!==t)return;i=!1}else for(;!(i=(s=c.call(t)).done)&&(o.push(s.value),o.length!==l);i=!0);}catch(e){p=!0,r=e}finally{try{if(!i&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(p)throw r}}return o}}(e,l)||function(e,l){if(e){if("string"==typeof e)return t(e,l);var s={}.toString.call(e).slice(8,-1);return"Object"===s&&e.constructor&&(s=e.constructor.name),"Map"===s||"Set"===s?Array.from(e):"Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?t(e,l):void 0}}(e,l)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,l){(null==l||l>e.length)&&(l=e.length);for(var t=0,s=Array(l);t<l;t++)s[t]=e[t];return s}var s={asp:"clike",aspx:"clike",bash:"shell",c:"clike","c#":["clike","text/x-csharp"],"c++":["clike","text/x-c++src"],clj:"clojure",cljc:"clojure",cljx:"clojure",coffeescript:"javascript",cplusplus:["clike","text/x-c++src"],cpp:["clike","text/x-c++src"],cql:["sql","text/x-cassandra"],cs:["clike","text/x-csharp"],csharp:["clike","text/x-csharp"],curl:"shell",d:"d",diff:"diff",ecmascript:"javascript",erl:"erlang",go:["go","text/x-go"],gradle:"groovy",gql:"graphql",handlebars:"htmlmixed",hbs:"htmlmixed",html:"htmlmixed",java:["clike","text/x-java"],jl:"julia",js:"javascript",jsx:"jsx",json:["javascript","application/ld+json"],jruby:"ruby",kotlin:["clike","text/x-kotlin"],kt:["clike","text/x-kotlin"],less:"css",liquid:"htmlmixed",lua:"lua",node:"javascript",macruby:"ruby",markdown:"gfm",ml:["mllike","text/x-ocaml"],mssql:["sql","text/x-mssql"],mysql:["sql","text/x-mysql"],objc:["clike","text/x-objectivec"],"objc++":["clike","text/x-objectivec++"],objcpp:["clike","text/x-objectivec++"],objectivec:["clike","text/x-objectivec"],objectivecpp:["clike","text/x-objectivec++"],objectivecplusplus:["clike","text/x-objectivec++"],ocaml:["mllike","text/x-ocaml"],php:["php","text/x-php"],pgsql:["sql","text/x-pgsql"],pl:"perl",plsql:["sql","text/x-plsql"],postgres:["sql","text/x-pgsql"],postgresql:["sql","text/x-pgsql"],ps1:"powershell",py:"python",r:"r",rake:"ruby",rb:"ruby",rbx:"ruby",rs:"rust",sass:"css",scala:["clike","text/x-scala"],scss:"css",sh:"shell",sol:"solidity",solidity:"solidity",sql:["sql","text/x-sql"],sqlite:["sql","text/x-sqlite"],styl:"css",stylus:"css",text:["null","text/plain"],ts:["javascript","text/typescript"],typescript:["javascript","text/typescript"],xhtml:"htmlmixed",yml:"yaml",zsh:"shell"};e.exports={modes:s,getMode:function(e){var t=e;return t in s&&(t=s[t],Array.isArray(t)&&(t=l(t,2)[1])),t}}}},l={};function t(s){var r=l[s];if(void 0!==r)return r.exports;var c=l[s]={exports:{}};return e[s](c,c.exports,t),c.exports}t.n=e=>{var l=e&&e.__esModule?()=>e.default:()=>e;return t.d(l,{a:l}),l},t.d=(e,l)=>{for(var s in l)t.o(l,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:l[s]})},t.o=(e,l)=>Object.prototype.hasOwnProperty.call(e,l),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};(()=>{"use strict";t.r(s),t.d(s,{canonical:()=>l.a,getMode:()=>r.getMode,modes:()=>r.modes,uppercase:()=>a.a});var e=t(226),l=t.n(e),r=t(980),c=t(548),a=t.n(c)})(),module.exports=s})();
8
327
 
9
328
  /***/ }),
10
329
 
@@ -16643,7 +16962,8 @@ let syntaxHighlighter;
16643
16962
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16644
16963
  let canonicalLanguage = lang => '';
16645
16964
  if (typeof window !== 'undefined') {
16646
- Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 3368, 23)).then(module => {
16965
+ // @ts-expect-error this library does not have any types defined
16966
+ __webpack_require__.e(/* import() */ 368).then(__webpack_require__.t.bind(__webpack_require__, 3368, 23)).then(module => {
16647
16967
  syntaxHighlighter = module.default;
16648
16968
  canonicalLanguage = module.canonical;
16649
16969
  });
@@ -16686,13 +17006,15 @@ const Code = (props) => {
16686
17006
  };
16687
17007
  /* harmony default export */ const components_Code = (Code);
16688
17008
 
16689
- // EXTERNAL MODULE: ./node_modules/@readme/syntax-highlighter/dist/index.node.js
16690
- var index_node = __webpack_require__(3368);
17009
+ // EXTERNAL MODULE: ./node_modules/@readme/syntax-highlighter/dist-utils/index.js
17010
+ var dist_utils = __webpack_require__(7900);
17011
+ var dist_utils_default = /*#__PURE__*/__webpack_require__.n(dist_utils);
16691
17012
  ;// ./components/CodeTabs/index.tsx
16692
17013
 
16693
17014
 
16694
17015
 
16695
17016
  let mermaid;
17017
+ const { uppercase } = (dist_utils_default());
16696
17018
  const CodeTabs = (props) => {
16697
17019
  const { children } = props;
16698
17020
  const theme = (0,external_react_.useContext)(Theme);
@@ -16730,7 +17052,7 @@ const CodeTabs = (props) => {
16730
17052
  external_react_default().createElement("div", { className: "CodeTabs-toolbar" }, (Array.isArray(children) ? children : [children]).map((pre, i) => {
16731
17053
  const { meta, lang } = pre.props.children.props;
16732
17054
  /* istanbul ignore next */
16733
- return (external_react_default().createElement("button", { key: i, onClick: e => handleClick(e, i), type: "button", value: lang }, meta || `${!lang ? 'Text' : (0,index_node.uppercase)(lang)}`));
17055
+ return (external_react_default().createElement("button", { key: i, onClick: e => handleClick(e, i), type: "button", value: lang }, meta || `${!lang ? 'Text' : uppercase(lang)}`));
16734
17056
  })),
16735
17057
  external_react_default().createElement("div", { className: "CodeTabs-inner" }, children)));
16736
17058
  };
@@ -102870,59 +103192,16 @@ const lib_s = create_h_createH(node_modules_property_information_svg, 'g', svg_c
102870
103192
 
102871
103193
 
102872
103194
 
102873
-
102874
- const isCalloutNode = (node) => {
102875
- if (!node || typeof node !== 'object')
102876
- return false;
102877
- const { type, name, tagName, data, properties } = node;
102878
- if (type === 'mdxJsxFlowElement' && name === 'Callout') {
102879
- return true;
102880
- }
102881
- if (type !== 'element')
102882
- return false;
102883
- if (tagName === 'Callout')
102884
- return true;
102885
- if (typeof data === 'object' && data && 'hName' in data) {
102886
- const { hName } = data;
102887
- if (hName === 'Callout')
102888
- return true;
102889
- }
102890
- if (tagName !== 'blockquote')
102891
- return false;
102892
- if (!properties || typeof properties !== 'object')
102893
- return false;
102894
- const { className } = properties;
102895
- if (!className)
102896
- return false;
102897
- if (Array.isArray(className)) {
102898
- return className.some(cls => typeof cls === 'string' && cls.startsWith('callout'));
102899
- }
102900
- if (typeof className === 'string') {
102901
- return className.includes('callout');
102902
- }
102903
- return false;
102904
- };
103195
+ /*
103196
+ * A rehype plugin to generate a flat list of top-level headings or jsx flow
103197
+ * elements.
103198
+ */
102905
103199
  const rehypeToc = ({ components = {} }) => {
102906
103200
  return (tree) => {
102907
103201
  if (hasNamedExport(tree, 'toc'))
102908
103202
  return;
102909
- const headings = [];
102910
- visit(tree, (node, _index, parent) => {
102911
- if (isCalloutNode(node)) {
102912
- return SKIP;
102913
- }
102914
- const insideCallout = parent ? isCalloutNode(parent) : false;
102915
- if (insideCallout) {
102916
- return undefined;
102917
- }
102918
- if (node.type === 'element' && ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(node.tagName)) {
102919
- headings.push(node);
102920
- }
102921
- if (node.type === 'mdxJsxFlowElement' && node.name && node.name in components) {
102922
- headings.push(node);
102923
- }
102924
- return undefined;
102925
- });
103203
+ const headings = tree.children.filter(child => (child.type === 'element' && ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(child.tagName)) ||
103204
+ (child.type === 'mdxJsxFlowElement' && child.name in components));
102926
103205
  tree.children.unshift({
102927
103206
  type: 'mdxjsEsm',
102928
103207
  data: {
@@ -102954,6 +103233,10 @@ const rehypeToc = ({ components = {} }) => {
102954
103233
  };
102955
103234
  const MAX_DEPTH = 2;
102956
103235
  const getDepth = (el) => parseInt(el.tagName?.match(/^h(\d)/)[1], 10);
103236
+ /*
103237
+ * `tocToHast` consumes the list generated by `rehypeToc` and produces a hast
103238
+ * of nested lists to be rendered as a table of contents.
103239
+ */
102957
103240
  const tocToHast = (headings = []) => {
102958
103241
  const min = Math.min(...headings.map(getDepth));
102959
103242
  const ast = hastscript_lib_h('ul');
@@ -102977,17 +103260,19 @@ const tocToHast = (headings = []) => {
102977
103260
  });
102978
103261
  return ast;
102979
103262
  };
103263
+ /*
103264
+ * `tocHastToMdx` is a utility for combining `TocList`s of a root document and
103265
+ * any child components it may have. Once combined it will generate a markdown
103266
+ * doc representing a table of contents.
103267
+ */
102980
103268
  const tocHastToMdx = (toc, components) => {
102981
- const tree = { type: 'root', children: toc };
102982
- visit(tree, 'mdxJsxFlowElement', (node, index, parent) => {
102983
- const subToc = components[node.name] || [];
102984
- parent.children.splice(index, 1, ...subToc);
103269
+ if (typeof toc === 'undefined')
103270
+ return '';
103271
+ const injected = toc.flatMap(node => {
103272
+ return node.type === 'mdxJsxFlowElement' && node.name in components ? components[node.name] || [] : node;
102985
103273
  });
102986
- const tocHast = tocToHast(tree.children);
102987
- // @ts-expect-error: tocHast is extending Element, but to please mdx we need
102988
- // to cast it to Root. But I think there's something wrong with our
102989
- // RootContentMap type.
102990
- return lib_mdx(tocHast, { hast: true });
103274
+ const tocHast = tocToHast(injected);
103275
+ return lib_mdx({ type: 'root', children: [tocHast] }, { hast: true });
102991
103276
  };
102992
103277
 
102993
103278
  ;// ./lib/compile.ts