@likec4/core 1.48.0 → 1.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/THIRD-PARTY-LICENSES.md +1012 -0
- package/dist/_chunks/Builder.view-element.mjs +2 -3284
- package/dist/_chunks/LikeC4Model.d.mts +21 -25
- package/dist/_chunks/RichText.mjs +1 -148
- package/dist/_chunks/_types.d.mts +1 -5
- package/dist/_chunks/_types2.d.mts +2 -4
- package/dist/_chunks/assignTagColors.mjs +1 -24
- package/dist/_chunks/calcDriftsFromSnapshot.mjs +1 -379
- package/dist/_chunks/guards.d.mts +2026 -0
- package/dist/_chunks/guards.mjs +4 -0
- package/dist/_chunks/index.d.mts +255 -136
- package/dist/_chunks/libs/@mantine/colors-generator.mjs +2 -3403
- package/dist/_chunks/libs/@radix-ui/colors.mjs +1 -0
- package/dist/_chunks/libs/@ungap/structured-clone.mjs +1 -213
- package/dist/_chunks/libs/bail.mjs +1 -14
- package/dist/_chunks/libs/ccount.mjs +1 -25
- package/dist/_chunks/libs/character-entities-html4.mjs +1 -263
- package/dist/_chunks/libs/character-entities-legacy.mjs +1 -117
- package/dist/_chunks/libs/character-entities.mjs +2 -2136
- package/dist/_chunks/libs/comma-separated-tokens.mjs +1 -18
- package/dist/_chunks/libs/decode-named-character-reference.mjs +1 -21
- package/dist/_chunks/libs/defu.mjs +1 -42
- package/dist/_chunks/libs/devlop.mjs +1 -5
- package/dist/_chunks/libs/escape-string-regexp.mjs +1 -8
- package/dist/_chunks/libs/extend.mjs +1 -77
- package/dist/_chunks/libs/graphology-dag.mjs +1 -703
- package/dist/_chunks/libs/graphology.mjs +1 -4565
- package/dist/_chunks/libs/hast-util-sanitize.mjs +1 -863
- package/dist/_chunks/libs/hast-util-to-html.mjs +9 -2696
- package/dist/_chunks/libs/is-plain-obj.mjs +1 -9
- package/dist/_chunks/libs/longest-streak.mjs +1 -30
- package/dist/_chunks/libs/markdown-table.mjs +2 -290
- package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +1 -653
- package/dist/_chunks/libs/mdast-util-from-markdown.mjs +3 -8522
- package/dist/_chunks/libs/mdast-util-gfm.mjs +15 -2393
- package/dist/_chunks/libs/mdast-util-to-hast.mjs +11 -1803
- package/dist/_chunks/libs/micromark-extension-gfm.mjs +1 -2243
- package/dist/_chunks/libs/mnemonist.d.mts +1 -91
- package/dist/_chunks/libs/mnemonist.mjs +1 -1978
- package/dist/_chunks/libs/natural-compare-lite.mjs +9 -42
- package/dist/_chunks/libs/ohash.mjs +1 -0
- package/dist/_chunks/libs/rehype-sanitize.mjs +1 -29
- package/dist/_chunks/libs/rehype-stringify.mjs +1 -34
- package/dist/_chunks/libs/remark-gfm.mjs +1 -36
- package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +3 -100
- package/dist/_chunks/libs/remark-parse.mjs +1 -39
- package/dist/_chunks/libs/remark-rehype.mjs +1 -171
- package/dist/_chunks/libs/remeda.mjs +1 -702
- package/dist/_chunks/libs/trough.mjs +1 -158
- package/dist/_chunks/libs/unified.mjs +1 -2212
- package/dist/_chunks/rolldown-runtime.mjs +1 -42
- package/dist/_chunks/{index3.d.mts → theme.d.mts} +15 -13
- package/dist/_chunks/{index7.d.mts → to-text.d.mts} +165 -29
- package/dist/_chunks/to-text.mjs +1 -0
- package/dist/_chunks/vector.d.mts +198 -0
- package/dist/_chunks/vector.mjs +1 -0
- package/dist/builder/index.d.mts +2 -8
- package/dist/builder/index.mjs +1 -662
- package/dist/compute-view/index.d.mts +86 -15
- package/dist/compute-view/index.mjs +2 -262
- package/dist/geometry/index.d.mts +2 -2
- package/dist/geometry/index.mjs +1 -3
- package/dist/index.d.mts +9 -13
- package/dist/index.mjs +1 -27
- package/dist/model/index.d.mts +4 -14
- package/dist/model/index.mjs +1 -11
- package/dist/styles/index.d.mts +2 -8
- package/dist/styles/index.mjs +1 -30
- package/dist/types/index.d.mts +3 -9
- package/dist/types/index.mjs +1 -15
- package/dist/utils/graphology/index.d.mts +1 -1
- package/dist/utils/graphology/index.mjs +1 -3
- package/dist/utils/index.d.mts +4 -11
- package/dist/utils/index.mjs +1 -17
- package/package.json +13 -12
- package/dist/_chunks/LikeC4Styles.mjs +0 -691
- package/dist/_chunks/RichText.d.mts +0 -84
- package/dist/_chunks/_aux.d.mts +0 -289
- package/dist/_chunks/_aux.mjs +0 -18
- package/dist/_chunks/connection.mjs +0 -0
- package/dist/_chunks/const.d.mts +0 -43
- package/dist/_chunks/const.mjs +0 -33
- package/dist/_chunks/expression-model.d.mts +0 -192
- package/dist/_chunks/expression-model.mjs +0 -103
- package/dist/_chunks/expression.d.mts +0 -347
- package/dist/_chunks/expression.mjs +0 -107
- package/dist/_chunks/find.d.mts +0 -82
- package/dist/_chunks/find.mjs +0 -646
- package/dist/_chunks/find2.d.mts +0 -78
- package/dist/_chunks/find2.mjs +0 -287
- package/dist/_chunks/fqnRef.d.mts +0 -58
- package/dist/_chunks/fqnRef.mjs +0 -41
- package/dist/_chunks/geometry.mjs +0 -335
- package/dist/_chunks/index2.d.mts +0 -937
- package/dist/_chunks/index4.d.mts +0 -62
- package/dist/_chunks/index5.d.mts +0 -42
- package/dist/_chunks/index6.d.mts +0 -43
- package/dist/_chunks/index8.d.mts +0 -144
- package/dist/_chunks/invariant.mjs +0 -18
- package/dist/_chunks/iterable.mjs +0 -146
- package/dist/_chunks/libs/graphology-types.d.mts +0 -601
- package/dist/_chunks/libs/graphology.d.mts +0 -6
- package/dist/_chunks/mnemonist.d.mts +0 -1
- package/dist/_chunks/mnemonist.mjs +0 -0
- package/dist/_chunks/model.mjs +0 -1898
- package/dist/_chunks/model2.mjs +0 -0
- package/dist/_chunks/relationships-view.mjs +0 -132
- package/dist/_chunks/scalar.d.mts +0 -109
- package/dist/_chunks/scalar.mjs +0 -84
- package/dist/_chunks/utils.mjs +0 -483
- package/dist/compute-view/relationships-view/index.d.mts +0 -16
- package/dist/compute-view/relationships-view/index.mjs +0 -7
- package/dist/model/connection/deployment/index.d.mts +0 -12
- package/dist/model/connection/deployment/index.mjs +0 -9
- package/dist/model/connection/index.d.mts +0 -14
- package/dist/model/connection/index.mjs +0 -10
- package/dist/model/connection/model/index.d.mts +0 -12
- package/dist/model/connection/model/index.mjs +0 -8
- package/dist/types/RichText.d.mts +0 -3
- package/dist/types/RichText.mjs +0 -7
- package/dist/types/_aux.d.mts +0 -3
- package/dist/types/_aux.mjs +0 -3
- package/dist/types/expression-model.d.mts +0 -6
- package/dist/types/expression-model.mjs +0 -7
- package/dist/types/expression.d.mts +0 -5
- package/dist/types/expression.mjs +0 -7
- package/dist/types/fqnRef.d.mts +0 -4
- package/dist/types/fqnRef.mjs +0 -7
- package/dist/types/scalar.d.mts +0 -2
- package/dist/types/scalar.mjs +0 -7
- package/dist/utils/iterable/index.d.mts +0 -9
- package/dist/utils/iterable/index.mjs +0 -3
- package/dist/utils/mnemonist.d.mts +0 -2
- package/dist/utils/mnemonist.mjs +0 -12
|
@@ -1,2393 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const inConstruct = "phrasing";
|
|
17
|
-
/** @type {Array<ConstructName>} */
|
|
18
|
-
const notInConstruct = [
|
|
19
|
-
"autolink",
|
|
20
|
-
"link",
|
|
21
|
-
"image",
|
|
22
|
-
"label"
|
|
23
|
-
];
|
|
24
|
-
/**
|
|
25
|
-
* Create an extension for `mdast-util-from-markdown` to enable GFM autolink
|
|
26
|
-
* literals in markdown.
|
|
27
|
-
*
|
|
28
|
-
* @returns {FromMarkdownExtension}
|
|
29
|
-
* Extension for `mdast-util-to-markdown` to enable GFM autolink literals.
|
|
30
|
-
*/
|
|
31
|
-
function gfmAutolinkLiteralFromMarkdown() {
|
|
32
|
-
return {
|
|
33
|
-
transforms: [transformGfmAutolinkLiterals],
|
|
34
|
-
enter: {
|
|
35
|
-
literalAutolink: enterLiteralAutolink,
|
|
36
|
-
literalAutolinkEmail: enterLiteralAutolinkValue,
|
|
37
|
-
literalAutolinkHttp: enterLiteralAutolinkValue,
|
|
38
|
-
literalAutolinkWww: enterLiteralAutolinkValue
|
|
39
|
-
},
|
|
40
|
-
exit: {
|
|
41
|
-
literalAutolink: exitLiteralAutolink,
|
|
42
|
-
literalAutolinkEmail: exitLiteralAutolinkEmail,
|
|
43
|
-
literalAutolinkHttp: exitLiteralAutolinkHttp,
|
|
44
|
-
literalAutolinkWww: exitLiteralAutolinkWww
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Create an extension for `mdast-util-to-markdown` to enable GFM autolink
|
|
50
|
-
* literals in markdown.
|
|
51
|
-
*
|
|
52
|
-
* @returns {ToMarkdownExtension}
|
|
53
|
-
* Extension for `mdast-util-to-markdown` to enable GFM autolink literals.
|
|
54
|
-
*/
|
|
55
|
-
function gfmAutolinkLiteralToMarkdown() {
|
|
56
|
-
return { unsafe: [
|
|
57
|
-
{
|
|
58
|
-
character: "@",
|
|
59
|
-
before: "[+\\-.\\w]",
|
|
60
|
-
after: "[\\-.\\w]",
|
|
61
|
-
inConstruct,
|
|
62
|
-
notInConstruct
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
character: ".",
|
|
66
|
-
before: "[Ww]",
|
|
67
|
-
after: "[\\-.\\w]",
|
|
68
|
-
inConstruct,
|
|
69
|
-
notInConstruct
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
character: ":",
|
|
73
|
-
before: "[ps]",
|
|
74
|
-
after: "\\/",
|
|
75
|
-
inConstruct,
|
|
76
|
-
notInConstruct
|
|
77
|
-
}
|
|
78
|
-
] };
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* @this {CompileContext}
|
|
82
|
-
* @type {FromMarkdownHandle}
|
|
83
|
-
*/
|
|
84
|
-
function enterLiteralAutolink(token) {
|
|
85
|
-
this.enter({
|
|
86
|
-
type: "link",
|
|
87
|
-
title: null,
|
|
88
|
-
url: "",
|
|
89
|
-
children: []
|
|
90
|
-
}, token);
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* @this {CompileContext}
|
|
94
|
-
* @type {FromMarkdownHandle}
|
|
95
|
-
*/
|
|
96
|
-
function enterLiteralAutolinkValue(token) {
|
|
97
|
-
this.config.enter.autolinkProtocol.call(this, token);
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* @this {CompileContext}
|
|
101
|
-
* @type {FromMarkdownHandle}
|
|
102
|
-
*/
|
|
103
|
-
function exitLiteralAutolinkHttp(token) {
|
|
104
|
-
this.config.exit.autolinkProtocol.call(this, token);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* @this {CompileContext}
|
|
108
|
-
* @type {FromMarkdownHandle}
|
|
109
|
-
*/
|
|
110
|
-
function exitLiteralAutolinkWww(token) {
|
|
111
|
-
this.config.exit.data.call(this, token);
|
|
112
|
-
const node = this.stack[this.stack.length - 1];
|
|
113
|
-
/* @__PURE__ */ ok(node.type === "link");
|
|
114
|
-
node.url = "http://" + this.sliceSerialize(token);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* @this {CompileContext}
|
|
118
|
-
* @type {FromMarkdownHandle}
|
|
119
|
-
*/
|
|
120
|
-
function exitLiteralAutolinkEmail(token) {
|
|
121
|
-
this.config.exit.autolinkEmail.call(this, token);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* @this {CompileContext}
|
|
125
|
-
* @type {FromMarkdownHandle}
|
|
126
|
-
*/
|
|
127
|
-
function exitLiteralAutolink(token) {
|
|
128
|
-
this.exit(token);
|
|
129
|
-
}
|
|
130
|
-
/** @type {FromMarkdownTransform} */
|
|
131
|
-
function transformGfmAutolinkLiterals(tree) {
|
|
132
|
-
findAndReplace(tree, [[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi, findUrl], [/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu, findEmail]], { ignore: ["link", "linkReference"] });
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* @type {ReplaceFunction}
|
|
136
|
-
* @param {string} _
|
|
137
|
-
* @param {string} protocol
|
|
138
|
-
* @param {string} domain
|
|
139
|
-
* @param {string} path
|
|
140
|
-
* @param {RegExpMatchObject} match
|
|
141
|
-
* @returns {Array<PhrasingContent> | Link | false}
|
|
142
|
-
*/
|
|
143
|
-
function findUrl(_, protocol, domain, path, match) {
|
|
144
|
-
let prefix = "";
|
|
145
|
-
if (!previous(match)) return false;
|
|
146
|
-
if (/^w/i.test(protocol)) {
|
|
147
|
-
domain = protocol + domain;
|
|
148
|
-
protocol = "";
|
|
149
|
-
prefix = "http://";
|
|
150
|
-
}
|
|
151
|
-
if (!isCorrectDomain(domain)) return false;
|
|
152
|
-
const parts = splitUrl(domain + path);
|
|
153
|
-
if (!parts[0]) return false;
|
|
154
|
-
/** @type {Link} */
|
|
155
|
-
const result = {
|
|
156
|
-
type: "link",
|
|
157
|
-
title: null,
|
|
158
|
-
url: prefix + protocol + parts[0],
|
|
159
|
-
children: [{
|
|
160
|
-
type: "text",
|
|
161
|
-
value: protocol + parts[0]
|
|
162
|
-
}]
|
|
163
|
-
};
|
|
164
|
-
if (parts[1]) return [result, {
|
|
165
|
-
type: "text",
|
|
166
|
-
value: parts[1]
|
|
167
|
-
}];
|
|
168
|
-
return result;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* @type {ReplaceFunction}
|
|
172
|
-
* @param {string} _
|
|
173
|
-
* @param {string} atext
|
|
174
|
-
* @param {string} label
|
|
175
|
-
* @param {RegExpMatchObject} match
|
|
176
|
-
* @returns {Link | false}
|
|
177
|
-
*/
|
|
178
|
-
function findEmail(_, atext, label, match) {
|
|
179
|
-
if (!previous(match, true) || /[-\d_]$/.test(label)) return false;
|
|
180
|
-
return {
|
|
181
|
-
type: "link",
|
|
182
|
-
title: null,
|
|
183
|
-
url: "mailto:" + atext + "@" + label,
|
|
184
|
-
children: [{
|
|
185
|
-
type: "text",
|
|
186
|
-
value: atext + "@" + label
|
|
187
|
-
}]
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* @param {string} domain
|
|
192
|
-
* @returns {boolean}
|
|
193
|
-
*/
|
|
194
|
-
function isCorrectDomain(domain) {
|
|
195
|
-
const parts = domain.split(".");
|
|
196
|
-
if (parts.length < 2 || parts[parts.length - 1] && (/_/.test(parts[parts.length - 1]) || !/[a-zA-Z\d]/.test(parts[parts.length - 1])) || parts[parts.length - 2] && (/_/.test(parts[parts.length - 2]) || !/[a-zA-Z\d]/.test(parts[parts.length - 2]))) return false;
|
|
197
|
-
return true;
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* @param {string} url
|
|
201
|
-
* @returns {[string, string | undefined]}
|
|
202
|
-
*/
|
|
203
|
-
function splitUrl(url) {
|
|
204
|
-
const trailExec = /[!"&'),.:;<>?\]}]+$/.exec(url);
|
|
205
|
-
if (!trailExec) return [url, void 0];
|
|
206
|
-
url = url.slice(0, trailExec.index);
|
|
207
|
-
let trail = trailExec[0];
|
|
208
|
-
let closingParenIndex = trail.indexOf(")");
|
|
209
|
-
const openingParens = ccount(url, "(");
|
|
210
|
-
let closingParens = ccount(url, ")");
|
|
211
|
-
while (closingParenIndex !== -1 && openingParens > closingParens) {
|
|
212
|
-
url += trail.slice(0, closingParenIndex + 1);
|
|
213
|
-
trail = trail.slice(closingParenIndex + 1);
|
|
214
|
-
closingParenIndex = trail.indexOf(")");
|
|
215
|
-
closingParens++;
|
|
216
|
-
}
|
|
217
|
-
return [url, trail];
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* @param {RegExpMatchObject} match
|
|
221
|
-
* @param {boolean | null | undefined} [email=false]
|
|
222
|
-
* @returns {boolean}
|
|
223
|
-
*/
|
|
224
|
-
function previous(match, email) {
|
|
225
|
-
const code = match.input.charCodeAt(match.index - 1);
|
|
226
|
-
return (match.index === 0 || unicodeWhitespace(code) || unicodePunctuation(code)) && (!email || code !== 47);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
//#endregion
|
|
230
|
-
//#region ../../node_modules/.pnpm/mdast-util-gfm-footnote@2.1.0/node_modules/mdast-util-gfm-footnote/lib/index.js
|
|
231
|
-
/**
|
|
232
|
-
* @import {
|
|
233
|
-
* CompileContext,
|
|
234
|
-
* Extension as FromMarkdownExtension,
|
|
235
|
-
* Handle as FromMarkdownHandle
|
|
236
|
-
* } from 'mdast-util-from-markdown'
|
|
237
|
-
* @import {ToMarkdownOptions} from 'mdast-util-gfm-footnote'
|
|
238
|
-
* @import {
|
|
239
|
-
* Handle as ToMarkdownHandle,
|
|
240
|
-
* Map,
|
|
241
|
-
* Options as ToMarkdownExtension
|
|
242
|
-
* } from 'mdast-util-to-markdown'
|
|
243
|
-
* @import {FootnoteDefinition, FootnoteReference} from 'mdast'
|
|
244
|
-
*/
|
|
245
|
-
footnoteReference.peek = footnoteReferencePeek;
|
|
246
|
-
/**
|
|
247
|
-
* @this {CompileContext}
|
|
248
|
-
* @type {FromMarkdownHandle}
|
|
249
|
-
*/
|
|
250
|
-
function enterFootnoteCallString() {
|
|
251
|
-
this.buffer();
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* @this {CompileContext}
|
|
255
|
-
* @type {FromMarkdownHandle}
|
|
256
|
-
*/
|
|
257
|
-
function enterFootnoteCall(token) {
|
|
258
|
-
this.enter({
|
|
259
|
-
type: "footnoteReference",
|
|
260
|
-
identifier: "",
|
|
261
|
-
label: ""
|
|
262
|
-
}, token);
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* @this {CompileContext}
|
|
266
|
-
* @type {FromMarkdownHandle}
|
|
267
|
-
*/
|
|
268
|
-
function enterFootnoteDefinitionLabelString() {
|
|
269
|
-
this.buffer();
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* @this {CompileContext}
|
|
273
|
-
* @type {FromMarkdownHandle}
|
|
274
|
-
*/
|
|
275
|
-
function enterFootnoteDefinition(token) {
|
|
276
|
-
this.enter({
|
|
277
|
-
type: "footnoteDefinition",
|
|
278
|
-
identifier: "",
|
|
279
|
-
label: "",
|
|
280
|
-
children: []
|
|
281
|
-
}, token);
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* @this {CompileContext}
|
|
285
|
-
* @type {FromMarkdownHandle}
|
|
286
|
-
*/
|
|
287
|
-
function exitFootnoteCallString(token) {
|
|
288
|
-
const label = this.resume();
|
|
289
|
-
const node = this.stack[this.stack.length - 1];
|
|
290
|
-
/* @__PURE__ */ ok(node.type === "footnoteReference");
|
|
291
|
-
node.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase();
|
|
292
|
-
node.label = label;
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* @this {CompileContext}
|
|
296
|
-
* @type {FromMarkdownHandle}
|
|
297
|
-
*/
|
|
298
|
-
function exitFootnoteCall(token) {
|
|
299
|
-
this.exit(token);
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* @this {CompileContext}
|
|
303
|
-
* @type {FromMarkdownHandle}
|
|
304
|
-
*/
|
|
305
|
-
function exitFootnoteDefinitionLabelString(token) {
|
|
306
|
-
const label = this.resume();
|
|
307
|
-
const node = this.stack[this.stack.length - 1];
|
|
308
|
-
/* @__PURE__ */ ok(node.type === "footnoteDefinition");
|
|
309
|
-
node.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase();
|
|
310
|
-
node.label = label;
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* @this {CompileContext}
|
|
314
|
-
* @type {FromMarkdownHandle}
|
|
315
|
-
*/
|
|
316
|
-
function exitFootnoteDefinition(token) {
|
|
317
|
-
this.exit(token);
|
|
318
|
-
}
|
|
319
|
-
/** @type {ToMarkdownHandle} */
|
|
320
|
-
function footnoteReferencePeek() {
|
|
321
|
-
return "[";
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* @type {ToMarkdownHandle}
|
|
325
|
-
* @param {FootnoteReference} node
|
|
326
|
-
*/
|
|
327
|
-
function footnoteReference(node, _, state, info) {
|
|
328
|
-
const tracker = state.createTracker(info);
|
|
329
|
-
let value = tracker.move("[^");
|
|
330
|
-
const exit = state.enter("footnoteReference");
|
|
331
|
-
const subexit = state.enter("reference");
|
|
332
|
-
value += tracker.move(state.safe(state.associationId(node), {
|
|
333
|
-
after: "]",
|
|
334
|
-
before: value
|
|
335
|
-
}));
|
|
336
|
-
subexit();
|
|
337
|
-
exit();
|
|
338
|
-
value += tracker.move("]");
|
|
339
|
-
return value;
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Create an extension for `mdast-util-from-markdown` to enable GFM footnotes
|
|
343
|
-
* in markdown.
|
|
344
|
-
*
|
|
345
|
-
* @returns {FromMarkdownExtension}
|
|
346
|
-
* Extension for `mdast-util-from-markdown`.
|
|
347
|
-
*/
|
|
348
|
-
function gfmFootnoteFromMarkdown() {
|
|
349
|
-
return {
|
|
350
|
-
enter: {
|
|
351
|
-
gfmFootnoteCallString: enterFootnoteCallString,
|
|
352
|
-
gfmFootnoteCall: enterFootnoteCall,
|
|
353
|
-
gfmFootnoteDefinitionLabelString: enterFootnoteDefinitionLabelString,
|
|
354
|
-
gfmFootnoteDefinition: enterFootnoteDefinition
|
|
355
|
-
},
|
|
356
|
-
exit: {
|
|
357
|
-
gfmFootnoteCallString: exitFootnoteCallString,
|
|
358
|
-
gfmFootnoteCall: exitFootnoteCall,
|
|
359
|
-
gfmFootnoteDefinitionLabelString: exitFootnoteDefinitionLabelString,
|
|
360
|
-
gfmFootnoteDefinition: exitFootnoteDefinition
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* Create an extension for `mdast-util-to-markdown` to enable GFM footnotes
|
|
366
|
-
* in markdown.
|
|
367
|
-
*
|
|
368
|
-
* @param {ToMarkdownOptions | null | undefined} [options]
|
|
369
|
-
* Configuration (optional).
|
|
370
|
-
* @returns {ToMarkdownExtension}
|
|
371
|
-
* Extension for `mdast-util-to-markdown`.
|
|
372
|
-
*/
|
|
373
|
-
function gfmFootnoteToMarkdown(options) {
|
|
374
|
-
let firstLineBlank = false;
|
|
375
|
-
if (options && options.firstLineBlank) firstLineBlank = true;
|
|
376
|
-
return {
|
|
377
|
-
handlers: {
|
|
378
|
-
footnoteDefinition,
|
|
379
|
-
footnoteReference
|
|
380
|
-
},
|
|
381
|
-
unsafe: [{
|
|
382
|
-
character: "[",
|
|
383
|
-
inConstruct: [
|
|
384
|
-
"label",
|
|
385
|
-
"phrasing",
|
|
386
|
-
"reference"
|
|
387
|
-
]
|
|
388
|
-
}]
|
|
389
|
-
};
|
|
390
|
-
/**
|
|
391
|
-
* @type {ToMarkdownHandle}
|
|
392
|
-
* @param {FootnoteDefinition} node
|
|
393
|
-
*/
|
|
394
|
-
function footnoteDefinition(node, _, state, info) {
|
|
395
|
-
const tracker = state.createTracker(info);
|
|
396
|
-
let value = tracker.move("[^");
|
|
397
|
-
const exit = state.enter("footnoteDefinition");
|
|
398
|
-
const subexit = state.enter("label");
|
|
399
|
-
value += tracker.move(state.safe(state.associationId(node), {
|
|
400
|
-
before: value,
|
|
401
|
-
after: "]"
|
|
402
|
-
}));
|
|
403
|
-
subexit();
|
|
404
|
-
value += tracker.move("]:");
|
|
405
|
-
if (node.children && node.children.length > 0) {
|
|
406
|
-
tracker.shift(4);
|
|
407
|
-
value += tracker.move((firstLineBlank ? "\n" : " ") + state.indentLines(state.containerFlow(node, tracker.current()), firstLineBlank ? mapAll : mapExceptFirst));
|
|
408
|
-
}
|
|
409
|
-
exit();
|
|
410
|
-
return value;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
/** @type {Map} */
|
|
414
|
-
function mapExceptFirst(line, index, blank) {
|
|
415
|
-
return index === 0 ? line : mapAll(line, index, blank);
|
|
416
|
-
}
|
|
417
|
-
/** @type {Map} */
|
|
418
|
-
function mapAll(line, index, blank) {
|
|
419
|
-
return (blank ? "" : " ") + line;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
//#endregion
|
|
423
|
-
//#region ../../node_modules/.pnpm/mdast-util-gfm-strikethrough@2.0.0/node_modules/mdast-util-gfm-strikethrough/lib/index.js
|
|
424
|
-
/**
|
|
425
|
-
* @typedef {import('mdast').Delete} Delete
|
|
426
|
-
*
|
|
427
|
-
* @typedef {import('mdast-util-from-markdown').CompileContext} CompileContext
|
|
428
|
-
* @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension
|
|
429
|
-
* @typedef {import('mdast-util-from-markdown').Handle} FromMarkdownHandle
|
|
430
|
-
*
|
|
431
|
-
* @typedef {import('mdast-util-to-markdown').ConstructName} ConstructName
|
|
432
|
-
* @typedef {import('mdast-util-to-markdown').Handle} ToMarkdownHandle
|
|
433
|
-
* @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension
|
|
434
|
-
*/
|
|
435
|
-
/**
|
|
436
|
-
* List of constructs that occur in phrasing (paragraphs, headings), but cannot
|
|
437
|
-
* contain strikethrough.
|
|
438
|
-
* So they sort of cancel each other out.
|
|
439
|
-
* Note: could use a better name.
|
|
440
|
-
*
|
|
441
|
-
* Note: keep in sync with: <https://github.com/syntax-tree/mdast-util-to-markdown/blob/8ce8dbf/lib/unsafe.js#L14>
|
|
442
|
-
*
|
|
443
|
-
* @type {Array<ConstructName>}
|
|
444
|
-
*/
|
|
445
|
-
const constructsWithoutStrikethrough = [
|
|
446
|
-
"autolink",
|
|
447
|
-
"destinationLiteral",
|
|
448
|
-
"destinationRaw",
|
|
449
|
-
"reference",
|
|
450
|
-
"titleQuote",
|
|
451
|
-
"titleApostrophe"
|
|
452
|
-
];
|
|
453
|
-
handleDelete.peek = peekDelete;
|
|
454
|
-
/**
|
|
455
|
-
* Create an extension for `mdast-util-from-markdown` to enable GFM
|
|
456
|
-
* strikethrough in markdown.
|
|
457
|
-
*
|
|
458
|
-
* @returns {FromMarkdownExtension}
|
|
459
|
-
* Extension for `mdast-util-from-markdown` to enable GFM strikethrough.
|
|
460
|
-
*/
|
|
461
|
-
function gfmStrikethroughFromMarkdown() {
|
|
462
|
-
return {
|
|
463
|
-
canContainEols: ["delete"],
|
|
464
|
-
enter: { strikethrough: enterStrikethrough },
|
|
465
|
-
exit: { strikethrough: exitStrikethrough }
|
|
466
|
-
};
|
|
467
|
-
}
|
|
468
|
-
/**
|
|
469
|
-
* Create an extension for `mdast-util-to-markdown` to enable GFM
|
|
470
|
-
* strikethrough in markdown.
|
|
471
|
-
*
|
|
472
|
-
* @returns {ToMarkdownExtension}
|
|
473
|
-
* Extension for `mdast-util-to-markdown` to enable GFM strikethrough.
|
|
474
|
-
*/
|
|
475
|
-
function gfmStrikethroughToMarkdown() {
|
|
476
|
-
return {
|
|
477
|
-
unsafe: [{
|
|
478
|
-
character: "~",
|
|
479
|
-
inConstruct: "phrasing",
|
|
480
|
-
notInConstruct: constructsWithoutStrikethrough
|
|
481
|
-
}],
|
|
482
|
-
handlers: { delete: handleDelete }
|
|
483
|
-
};
|
|
484
|
-
}
|
|
485
|
-
/**
|
|
486
|
-
* @this {CompileContext}
|
|
487
|
-
* @type {FromMarkdownHandle}
|
|
488
|
-
*/
|
|
489
|
-
function enterStrikethrough(token) {
|
|
490
|
-
this.enter({
|
|
491
|
-
type: "delete",
|
|
492
|
-
children: []
|
|
493
|
-
}, token);
|
|
494
|
-
}
|
|
495
|
-
/**
|
|
496
|
-
* @this {CompileContext}
|
|
497
|
-
* @type {FromMarkdownHandle}
|
|
498
|
-
*/
|
|
499
|
-
function exitStrikethrough(token) {
|
|
500
|
-
this.exit(token);
|
|
501
|
-
}
|
|
502
|
-
/**
|
|
503
|
-
* @type {ToMarkdownHandle}
|
|
504
|
-
* @param {Delete} node
|
|
505
|
-
*/
|
|
506
|
-
function handleDelete(node, _, state, info) {
|
|
507
|
-
const tracker = state.createTracker(info);
|
|
508
|
-
const exit = state.enter("strikethrough");
|
|
509
|
-
let value = tracker.move("~~");
|
|
510
|
-
value += state.containerPhrasing(node, {
|
|
511
|
-
...tracker.current(),
|
|
512
|
-
before: value,
|
|
513
|
-
after: "~"
|
|
514
|
-
});
|
|
515
|
-
value += tracker.move("~~");
|
|
516
|
-
exit();
|
|
517
|
-
return value;
|
|
518
|
-
}
|
|
519
|
-
/** @type {ToMarkdownHandle} */
|
|
520
|
-
function peekDelete() {
|
|
521
|
-
return "~";
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
//#endregion
|
|
525
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/handle/blockquote.js
|
|
526
|
-
/**
|
|
527
|
-
* @import {Blockquote, Parents} from 'mdast'
|
|
528
|
-
* @import {Info, Map, State} from 'mdast-util-to-markdown'
|
|
529
|
-
*/
|
|
530
|
-
/**
|
|
531
|
-
* @param {Blockquote} node
|
|
532
|
-
* @param {Parents | undefined} _
|
|
533
|
-
* @param {State} state
|
|
534
|
-
* @param {Info} info
|
|
535
|
-
* @returns {string}
|
|
536
|
-
*/
|
|
537
|
-
function blockquote(node, _, state, info) {
|
|
538
|
-
const exit = state.enter("blockquote");
|
|
539
|
-
const tracker = state.createTracker(info);
|
|
540
|
-
tracker.move("> ");
|
|
541
|
-
tracker.shift(2);
|
|
542
|
-
const value = state.indentLines(state.containerFlow(node, tracker.current()), map$1);
|
|
543
|
-
exit();
|
|
544
|
-
return value;
|
|
545
|
-
}
|
|
546
|
-
/** @type {Map} */
|
|
547
|
-
function map$1(line, _, blank) {
|
|
548
|
-
return ">" + (blank ? "" : " ") + line;
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
//#endregion
|
|
552
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/util/pattern-in-scope.js
|
|
553
|
-
/**
|
|
554
|
-
* @import {ConstructName, Unsafe} from 'mdast-util-to-markdown'
|
|
555
|
-
*/
|
|
556
|
-
/**
|
|
557
|
-
* @param {Array<ConstructName>} stack
|
|
558
|
-
* @param {Unsafe} pattern
|
|
559
|
-
* @returns {boolean}
|
|
560
|
-
*/
|
|
561
|
-
function patternInScope(stack, pattern) {
|
|
562
|
-
return listInScope(stack, pattern.inConstruct, true) && !listInScope(stack, pattern.notInConstruct, false);
|
|
563
|
-
}
|
|
564
|
-
/**
|
|
565
|
-
* @param {Array<ConstructName>} stack
|
|
566
|
-
* @param {Unsafe['inConstruct']} list
|
|
567
|
-
* @param {boolean} none
|
|
568
|
-
* @returns {boolean}
|
|
569
|
-
*/
|
|
570
|
-
function listInScope(stack, list, none) {
|
|
571
|
-
if (typeof list === "string") list = [list];
|
|
572
|
-
if (!list || list.length === 0) return none;
|
|
573
|
-
let index = -1;
|
|
574
|
-
while (++index < list.length) if (stack.includes(list[index])) return true;
|
|
575
|
-
return false;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
//#endregion
|
|
579
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/handle/break.js
|
|
580
|
-
/**
|
|
581
|
-
* @import {Break, Parents} from 'mdast'
|
|
582
|
-
* @import {Info, State} from 'mdast-util-to-markdown'
|
|
583
|
-
*/
|
|
584
|
-
/**
|
|
585
|
-
* @param {Break} _
|
|
586
|
-
* @param {Parents | undefined} _1
|
|
587
|
-
* @param {State} state
|
|
588
|
-
* @param {Info} info
|
|
589
|
-
* @returns {string}
|
|
590
|
-
*/
|
|
591
|
-
function hardBreak(_, _1, state, info) {
|
|
592
|
-
let index = -1;
|
|
593
|
-
while (++index < state.unsafe.length) if (state.unsafe[index].character === "\n" && patternInScope(state.stack, state.unsafe[index])) return /[ \t]/.test(info.before) ? "" : " ";
|
|
594
|
-
return "\\\n";
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
//#endregion
|
|
598
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/util/format-code-as-indented.js
|
|
599
|
-
/**
|
|
600
|
-
* @import {State} from 'mdast-util-to-markdown'
|
|
601
|
-
* @import {Code} from 'mdast'
|
|
602
|
-
*/
|
|
603
|
-
/**
|
|
604
|
-
* @param {Code} node
|
|
605
|
-
* @param {State} state
|
|
606
|
-
* @returns {boolean}
|
|
607
|
-
*/
|
|
608
|
-
function formatCodeAsIndented(node, state) {
|
|
609
|
-
return Boolean(state.options.fences === false && node.value && !node.lang && /[^ \r\n]/.test(node.value) && !/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(node.value));
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
//#endregion
|
|
613
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/util/check-fence.js
|
|
614
|
-
/**
|
|
615
|
-
* @import {Options, State} from 'mdast-util-to-markdown'
|
|
616
|
-
*/
|
|
617
|
-
/**
|
|
618
|
-
* @param {State} state
|
|
619
|
-
* @returns {Exclude<Options['fence'], null | undefined>}
|
|
620
|
-
*/
|
|
621
|
-
function checkFence(state) {
|
|
622
|
-
const marker = state.options.fence || "`";
|
|
623
|
-
if (marker !== "`" && marker !== "~") throw new Error("Cannot serialize code with `" + marker + "` for `options.fence`, expected `` ` `` or `~`");
|
|
624
|
-
return marker;
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
//#endregion
|
|
628
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/handle/code.js
|
|
629
|
-
/**
|
|
630
|
-
* @import {Info, Map, State} from 'mdast-util-to-markdown'
|
|
631
|
-
* @import {Code, Parents} from 'mdast'
|
|
632
|
-
*/
|
|
633
|
-
/**
|
|
634
|
-
* @param {Code} node
|
|
635
|
-
* @param {Parents | undefined} _
|
|
636
|
-
* @param {State} state
|
|
637
|
-
* @param {Info} info
|
|
638
|
-
* @returns {string}
|
|
639
|
-
*/
|
|
640
|
-
function code(node, _, state, info) {
|
|
641
|
-
const marker = checkFence(state);
|
|
642
|
-
const raw = node.value || "";
|
|
643
|
-
const suffix = marker === "`" ? "GraveAccent" : "Tilde";
|
|
644
|
-
if (formatCodeAsIndented(node, state)) {
|
|
645
|
-
const exit = state.enter("codeIndented");
|
|
646
|
-
const value = state.indentLines(raw, map);
|
|
647
|
-
exit();
|
|
648
|
-
return value;
|
|
649
|
-
}
|
|
650
|
-
const tracker = state.createTracker(info);
|
|
651
|
-
const sequence = marker.repeat(Math.max(longestStreak(raw, marker) + 1, 3));
|
|
652
|
-
const exit = state.enter("codeFenced");
|
|
653
|
-
let value = tracker.move(sequence);
|
|
654
|
-
if (node.lang) {
|
|
655
|
-
const subexit = state.enter(`codeFencedLang${suffix}`);
|
|
656
|
-
value += tracker.move(state.safe(node.lang, {
|
|
657
|
-
before: value,
|
|
658
|
-
after: " ",
|
|
659
|
-
encode: ["`"],
|
|
660
|
-
...tracker.current()
|
|
661
|
-
}));
|
|
662
|
-
subexit();
|
|
663
|
-
}
|
|
664
|
-
if (node.lang && node.meta) {
|
|
665
|
-
const subexit = state.enter(`codeFencedMeta${suffix}`);
|
|
666
|
-
value += tracker.move(" ");
|
|
667
|
-
value += tracker.move(state.safe(node.meta, {
|
|
668
|
-
before: value,
|
|
669
|
-
after: "\n",
|
|
670
|
-
encode: ["`"],
|
|
671
|
-
...tracker.current()
|
|
672
|
-
}));
|
|
673
|
-
subexit();
|
|
674
|
-
}
|
|
675
|
-
value += tracker.move("\n");
|
|
676
|
-
if (raw) value += tracker.move(raw + "\n");
|
|
677
|
-
value += tracker.move(sequence);
|
|
678
|
-
exit();
|
|
679
|
-
return value;
|
|
680
|
-
}
|
|
681
|
-
/** @type {Map} */
|
|
682
|
-
function map(line, _, blank) {
|
|
683
|
-
return (blank ? "" : " ") + line;
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
//#endregion
|
|
687
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/util/check-quote.js
|
|
688
|
-
/**
|
|
689
|
-
* @import {Options, State} from 'mdast-util-to-markdown'
|
|
690
|
-
*/
|
|
691
|
-
/**
|
|
692
|
-
* @param {State} state
|
|
693
|
-
* @returns {Exclude<Options['quote'], null | undefined>}
|
|
694
|
-
*/
|
|
695
|
-
function checkQuote(state) {
|
|
696
|
-
const marker = state.options.quote || "\"";
|
|
697
|
-
if (marker !== "\"" && marker !== "'") throw new Error("Cannot serialize title with `" + marker + "` for `options.quote`, expected `\"`, or `'`");
|
|
698
|
-
return marker;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
//#endregion
|
|
702
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/handle/definition.js
|
|
703
|
-
/**
|
|
704
|
-
* @import {Info, State} from 'mdast-util-to-markdown'
|
|
705
|
-
* @import {Definition, Parents} from 'mdast'
|
|
706
|
-
*/
|
|
707
|
-
/**
|
|
708
|
-
* @param {Definition} node
|
|
709
|
-
* @param {Parents | undefined} _
|
|
710
|
-
* @param {State} state
|
|
711
|
-
* @param {Info} info
|
|
712
|
-
* @returns {string}
|
|
713
|
-
*/
|
|
714
|
-
function definition(node, _, state, info) {
|
|
715
|
-
const quote = checkQuote(state);
|
|
716
|
-
const suffix = quote === "\"" ? "Quote" : "Apostrophe";
|
|
717
|
-
const exit = state.enter("definition");
|
|
718
|
-
let subexit = state.enter("label");
|
|
719
|
-
const tracker = state.createTracker(info);
|
|
720
|
-
let value = tracker.move("[");
|
|
721
|
-
value += tracker.move(state.safe(state.associationId(node), {
|
|
722
|
-
before: value,
|
|
723
|
-
after: "]",
|
|
724
|
-
...tracker.current()
|
|
725
|
-
}));
|
|
726
|
-
value += tracker.move("]: ");
|
|
727
|
-
subexit();
|
|
728
|
-
if (!node.url || /[\0- \u007F]/.test(node.url)) {
|
|
729
|
-
subexit = state.enter("destinationLiteral");
|
|
730
|
-
value += tracker.move("<");
|
|
731
|
-
value += tracker.move(state.safe(node.url, {
|
|
732
|
-
before: value,
|
|
733
|
-
after: ">",
|
|
734
|
-
...tracker.current()
|
|
735
|
-
}));
|
|
736
|
-
value += tracker.move(">");
|
|
737
|
-
} else {
|
|
738
|
-
subexit = state.enter("destinationRaw");
|
|
739
|
-
value += tracker.move(state.safe(node.url, {
|
|
740
|
-
before: value,
|
|
741
|
-
after: node.title ? " " : "\n",
|
|
742
|
-
...tracker.current()
|
|
743
|
-
}));
|
|
744
|
-
}
|
|
745
|
-
subexit();
|
|
746
|
-
if (node.title) {
|
|
747
|
-
subexit = state.enter(`title${suffix}`);
|
|
748
|
-
value += tracker.move(" " + quote);
|
|
749
|
-
value += tracker.move(state.safe(node.title, {
|
|
750
|
-
before: value,
|
|
751
|
-
after: quote,
|
|
752
|
-
...tracker.current()
|
|
753
|
-
}));
|
|
754
|
-
value += tracker.move(quote);
|
|
755
|
-
subexit();
|
|
756
|
-
}
|
|
757
|
-
exit();
|
|
758
|
-
return value;
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
//#endregion
|
|
762
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/util/check-emphasis.js
|
|
763
|
-
/**
|
|
764
|
-
* @import {Options, State} from 'mdast-util-to-markdown'
|
|
765
|
-
*/
|
|
766
|
-
/**
|
|
767
|
-
* @param {State} state
|
|
768
|
-
* @returns {Exclude<Options['emphasis'], null | undefined>}
|
|
769
|
-
*/
|
|
770
|
-
function checkEmphasis(state) {
|
|
771
|
-
const marker = state.options.emphasis || "*";
|
|
772
|
-
if (marker !== "*" && marker !== "_") throw new Error("Cannot serialize emphasis with `" + marker + "` for `options.emphasis`, expected `*`, or `_`");
|
|
773
|
-
return marker;
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
//#endregion
|
|
777
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/util/encode-character-reference.js
|
|
778
|
-
/**
|
|
779
|
-
* Encode a code point as a character reference.
|
|
780
|
-
*
|
|
781
|
-
* @param {number} code
|
|
782
|
-
* Code point to encode.
|
|
783
|
-
* @returns {string}
|
|
784
|
-
* Encoded character reference.
|
|
785
|
-
*/
|
|
786
|
-
function encodeCharacterReference(code) {
|
|
787
|
-
return "&#x" + code.toString(16).toUpperCase() + ";";
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
//#endregion
|
|
791
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/util/encode-info.js
|
|
792
|
-
/**
|
|
793
|
-
* @import {EncodeSides} from '../types.js'
|
|
794
|
-
*/
|
|
795
|
-
/**
|
|
796
|
-
* Check whether to encode (as a character reference) the characters
|
|
797
|
-
* surrounding an attention run.
|
|
798
|
-
*
|
|
799
|
-
* Which characters are around an attention run influence whether it works or
|
|
800
|
-
* not.
|
|
801
|
-
*
|
|
802
|
-
* See <https://github.com/orgs/syntax-tree/discussions/60> for more info.
|
|
803
|
-
* See this markdown in a particular renderer to see what works:
|
|
804
|
-
*
|
|
805
|
-
* ```markdown
|
|
806
|
-
* | | A (letter inside) | B (punctuation inside) | C (whitespace inside) | D (nothing inside) |
|
|
807
|
-
* | ----------------------- | ----------------- | ---------------------- | --------------------- | ------------------ |
|
|
808
|
-
* | 1 (letter outside) | x*y*z | x*.*z | x* *z | x**z |
|
|
809
|
-
* | 2 (punctuation outside) | .*y*. | .*.*. | .* *. | .**. |
|
|
810
|
-
* | 3 (whitespace outside) | x *y* z | x *.* z | x * * z | x ** z |
|
|
811
|
-
* | 4 (nothing outside) | *x* | *.* | * * | ** |
|
|
812
|
-
* ```
|
|
813
|
-
*
|
|
814
|
-
* @param {number} outside
|
|
815
|
-
* Code point on the outer side of the run.
|
|
816
|
-
* @param {number} inside
|
|
817
|
-
* Code point on the inner side of the run.
|
|
818
|
-
* @param {'*' | '_'} marker
|
|
819
|
-
* Marker of the run.
|
|
820
|
-
* Underscores are handled more strictly (they form less often) than
|
|
821
|
-
* asterisks.
|
|
822
|
-
* @returns {EncodeSides}
|
|
823
|
-
* Whether to encode characters.
|
|
824
|
-
*/
|
|
825
|
-
function encodeInfo(outside, inside, marker) {
|
|
826
|
-
const outsideKind = classifyCharacter(outside);
|
|
827
|
-
const insideKind = classifyCharacter(inside);
|
|
828
|
-
if (outsideKind === void 0) return insideKind === void 0 ? marker === "_" ? {
|
|
829
|
-
inside: true,
|
|
830
|
-
outside: true
|
|
831
|
-
} : {
|
|
832
|
-
inside: false,
|
|
833
|
-
outside: false
|
|
834
|
-
} : insideKind === 1 ? {
|
|
835
|
-
inside: true,
|
|
836
|
-
outside: true
|
|
837
|
-
} : {
|
|
838
|
-
inside: false,
|
|
839
|
-
outside: true
|
|
840
|
-
};
|
|
841
|
-
if (outsideKind === 1) return insideKind === void 0 ? {
|
|
842
|
-
inside: false,
|
|
843
|
-
outside: false
|
|
844
|
-
} : insideKind === 1 ? {
|
|
845
|
-
inside: true,
|
|
846
|
-
outside: true
|
|
847
|
-
} : {
|
|
848
|
-
inside: false,
|
|
849
|
-
outside: false
|
|
850
|
-
};
|
|
851
|
-
return insideKind === void 0 ? {
|
|
852
|
-
inside: false,
|
|
853
|
-
outside: false
|
|
854
|
-
} : insideKind === 1 ? {
|
|
855
|
-
inside: true,
|
|
856
|
-
outside: false
|
|
857
|
-
} : {
|
|
858
|
-
inside: false,
|
|
859
|
-
outside: false
|
|
860
|
-
};
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
//#endregion
|
|
864
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/handle/emphasis.js
|
|
865
|
-
/**
|
|
866
|
-
* @import {Info, State} from 'mdast-util-to-markdown'
|
|
867
|
-
* @import {Emphasis, Parents} from 'mdast'
|
|
868
|
-
*/
|
|
869
|
-
emphasis.peek = emphasisPeek;
|
|
870
|
-
/**
|
|
871
|
-
* @param {Emphasis} node
|
|
872
|
-
* @param {Parents | undefined} _
|
|
873
|
-
* @param {State} state
|
|
874
|
-
* @param {Info} info
|
|
875
|
-
* @returns {string}
|
|
876
|
-
*/
|
|
877
|
-
function emphasis(node, _, state, info) {
|
|
878
|
-
const marker = checkEmphasis(state);
|
|
879
|
-
const exit = state.enter("emphasis");
|
|
880
|
-
const tracker = state.createTracker(info);
|
|
881
|
-
const before = tracker.move(marker);
|
|
882
|
-
let between = tracker.move(state.containerPhrasing(node, {
|
|
883
|
-
after: marker,
|
|
884
|
-
before,
|
|
885
|
-
...tracker.current()
|
|
886
|
-
}));
|
|
887
|
-
const betweenHead = between.charCodeAt(0);
|
|
888
|
-
const open = encodeInfo(info.before.charCodeAt(info.before.length - 1), betweenHead, marker);
|
|
889
|
-
if (open.inside) between = encodeCharacterReference(betweenHead) + between.slice(1);
|
|
890
|
-
const betweenTail = between.charCodeAt(between.length - 1);
|
|
891
|
-
const close = encodeInfo(info.after.charCodeAt(0), betweenTail, marker);
|
|
892
|
-
if (close.inside) between = between.slice(0, -1) + encodeCharacterReference(betweenTail);
|
|
893
|
-
const after = tracker.move(marker);
|
|
894
|
-
exit();
|
|
895
|
-
state.attentionEncodeSurroundingInfo = {
|
|
896
|
-
after: close.outside,
|
|
897
|
-
before: open.outside
|
|
898
|
-
};
|
|
899
|
-
return before + between + after;
|
|
900
|
-
}
|
|
901
|
-
/**
|
|
902
|
-
* @param {Emphasis} _
|
|
903
|
-
* @param {Parents | undefined} _1
|
|
904
|
-
* @param {State} state
|
|
905
|
-
* @returns {string}
|
|
906
|
-
*/
|
|
907
|
-
function emphasisPeek(_, _1, state) {
|
|
908
|
-
return state.options.emphasis || "*";
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
//#endregion
|
|
912
|
-
//#region ../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/lib/index.js
|
|
913
|
-
/**
|
|
914
|
-
* @typedef {import('unist').Node} UnistNode
|
|
915
|
-
* @typedef {import('unist').Parent} UnistParent
|
|
916
|
-
* @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult
|
|
917
|
-
*/
|
|
918
|
-
/**
|
|
919
|
-
* @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test
|
|
920
|
-
* Test from `unist-util-is`.
|
|
921
|
-
*
|
|
922
|
-
* Note: we have remove and add `undefined`, because otherwise when generating
|
|
923
|
-
* automatic `.d.ts` files, TS tries to flatten paths from a local perspective,
|
|
924
|
-
* which doesn’t work when publishing on npm.
|
|
925
|
-
*/
|
|
926
|
-
/**
|
|
927
|
-
* @typedef {(
|
|
928
|
-
* Fn extends (value: any) => value is infer Thing
|
|
929
|
-
* ? Thing
|
|
930
|
-
* : Fallback
|
|
931
|
-
* )} Predicate
|
|
932
|
-
* Get the value of a type guard `Fn`.
|
|
933
|
-
* @template Fn
|
|
934
|
-
* Value; typically function that is a type guard (such as `(x): x is Y`).
|
|
935
|
-
* @template Fallback
|
|
936
|
-
* Value to yield if `Fn` is not a type guard.
|
|
937
|
-
*/
|
|
938
|
-
/**
|
|
939
|
-
* @typedef {(
|
|
940
|
-
* Check extends null | undefined // No test.
|
|
941
|
-
* ? Value
|
|
942
|
-
* : Value extends {type: Check} // String (type) test.
|
|
943
|
-
* ? Value
|
|
944
|
-
* : Value extends Check // Partial test.
|
|
945
|
-
* ? Value
|
|
946
|
-
* : Check extends Function // Function test.
|
|
947
|
-
* ? Predicate<Check, Value> extends Value
|
|
948
|
-
* ? Predicate<Check, Value>
|
|
949
|
-
* : never
|
|
950
|
-
* : never // Some other test?
|
|
951
|
-
* )} MatchesOne
|
|
952
|
-
* Check whether a node matches a primitive check in the type system.
|
|
953
|
-
* @template Value
|
|
954
|
-
* Value; typically unist `Node`.
|
|
955
|
-
* @template Check
|
|
956
|
-
* Value; typically `unist-util-is`-compatible test, but not arrays.
|
|
957
|
-
*/
|
|
958
|
-
/**
|
|
959
|
-
* @typedef {(
|
|
960
|
-
* Check extends Array<any>
|
|
961
|
-
* ? MatchesOne<Value, Check[keyof Check]>
|
|
962
|
-
* : MatchesOne<Value, Check>
|
|
963
|
-
* )} Matches
|
|
964
|
-
* Check whether a node matches a check in the type system.
|
|
965
|
-
* @template Value
|
|
966
|
-
* Value; typically unist `Node`.
|
|
967
|
-
* @template Check
|
|
968
|
-
* Value; typically `unist-util-is`-compatible test.
|
|
969
|
-
*/
|
|
970
|
-
/**
|
|
971
|
-
* @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint
|
|
972
|
-
* Number; capped reasonably.
|
|
973
|
-
*/
|
|
974
|
-
/**
|
|
975
|
-
* @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment
|
|
976
|
-
* Increment a number in the type system.
|
|
977
|
-
* @template {Uint} [I=0]
|
|
978
|
-
* Index.
|
|
979
|
-
*/
|
|
980
|
-
/**
|
|
981
|
-
* @typedef {(
|
|
982
|
-
* Node extends UnistParent
|
|
983
|
-
* ? Node extends {children: Array<infer Children>}
|
|
984
|
-
* ? Child extends Children ? Node : never
|
|
985
|
-
* : never
|
|
986
|
-
* : never
|
|
987
|
-
* )} InternalParent
|
|
988
|
-
* Collect nodes that can be parents of `Child`.
|
|
989
|
-
* @template {UnistNode} Node
|
|
990
|
-
* All node types in a tree.
|
|
991
|
-
* @template {UnistNode} Child
|
|
992
|
-
* Node to search for.
|
|
993
|
-
*/
|
|
994
|
-
/**
|
|
995
|
-
* @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent
|
|
996
|
-
* Collect nodes in `Tree` that can be parents of `Child`.
|
|
997
|
-
* @template {UnistNode} Tree
|
|
998
|
-
* All node types in a tree.
|
|
999
|
-
* @template {UnistNode} Child
|
|
1000
|
-
* Node to search for.
|
|
1001
|
-
*/
|
|
1002
|
-
/**
|
|
1003
|
-
* @typedef {(
|
|
1004
|
-
* Depth extends Max
|
|
1005
|
-
* ? never
|
|
1006
|
-
* :
|
|
1007
|
-
* | InternalParent<Node, Child>
|
|
1008
|
-
* | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>>
|
|
1009
|
-
* )} InternalAncestor
|
|
1010
|
-
* Collect nodes in `Tree` that can be ancestors of `Child`.
|
|
1011
|
-
* @template {UnistNode} Node
|
|
1012
|
-
* All node types in a tree.
|
|
1013
|
-
* @template {UnistNode} Child
|
|
1014
|
-
* Node to search for.
|
|
1015
|
-
* @template {Uint} [Max=10]
|
|
1016
|
-
* Max; searches up to this depth.
|
|
1017
|
-
* @template {Uint} [Depth=0]
|
|
1018
|
-
* Current depth.
|
|
1019
|
-
*/
|
|
1020
|
-
/**
|
|
1021
|
-
* @typedef {(
|
|
1022
|
-
* Tree extends UnistParent
|
|
1023
|
-
* ? Depth extends Max
|
|
1024
|
-
* ? Tree
|
|
1025
|
-
* : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>
|
|
1026
|
-
* : Tree
|
|
1027
|
-
* )} InclusiveDescendant
|
|
1028
|
-
* Collect all (inclusive) descendants of `Tree`.
|
|
1029
|
-
*
|
|
1030
|
-
* > 👉 **Note**: for performance reasons, this seems to be the fastest way to
|
|
1031
|
-
* > recurse without actually running into an infinite loop, which the
|
|
1032
|
-
* > previous version did.
|
|
1033
|
-
* >
|
|
1034
|
-
* > Practically, a max of `2` is typically enough assuming a `Root` is
|
|
1035
|
-
* > passed, but it doesn’t improve performance.
|
|
1036
|
-
* > It gets higher with `List > ListItem > Table > TableRow > TableCell`.
|
|
1037
|
-
* > Using up to `10` doesn’t hurt or help either.
|
|
1038
|
-
* @template {UnistNode} Tree
|
|
1039
|
-
* Tree type.
|
|
1040
|
-
* @template {Uint} [Max=10]
|
|
1041
|
-
* Max; searches up to this depth.
|
|
1042
|
-
* @template {Uint} [Depth=0]
|
|
1043
|
-
* Current depth.
|
|
1044
|
-
*/
|
|
1045
|
-
/**
|
|
1046
|
-
* @callback Visitor
|
|
1047
|
-
* Handle a node (matching `test`, if given).
|
|
1048
|
-
*
|
|
1049
|
-
* Visitors are free to transform `node`.
|
|
1050
|
-
* They can also transform `parent`.
|
|
1051
|
-
*
|
|
1052
|
-
* Replacing `node` itself, if `SKIP` is not returned, still causes its
|
|
1053
|
-
* descendants to be walked (which is a bug).
|
|
1054
|
-
*
|
|
1055
|
-
* When adding or removing previous siblings of `node` (or next siblings, in
|
|
1056
|
-
* case of reverse), the `Visitor` should return a new `Index` to specify the
|
|
1057
|
-
* sibling to traverse after `node` is traversed.
|
|
1058
|
-
* Adding or removing next siblings of `node` (or previous siblings, in case
|
|
1059
|
-
* of reverse) is handled as expected without needing to return a new `Index`.
|
|
1060
|
-
*
|
|
1061
|
-
* Removing the children property of `parent` still results in them being
|
|
1062
|
-
* traversed.
|
|
1063
|
-
* @param {Visited} node
|
|
1064
|
-
* Found node.
|
|
1065
|
-
* @param {Visited extends UnistNode ? number | undefined : never} index
|
|
1066
|
-
* Index of `node` in `parent`.
|
|
1067
|
-
* @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent
|
|
1068
|
-
* Parent of `node`.
|
|
1069
|
-
* @returns {VisitorResult}
|
|
1070
|
-
* What to do next.
|
|
1071
|
-
*
|
|
1072
|
-
* An `Index` is treated as a tuple of `[CONTINUE, Index]`.
|
|
1073
|
-
* An `Action` is treated as a tuple of `[Action]`.
|
|
1074
|
-
*
|
|
1075
|
-
* Passing a tuple back only makes sense if the `Action` is `SKIP`.
|
|
1076
|
-
* When the `Action` is `EXIT`, that action can be returned.
|
|
1077
|
-
* When the `Action` is `CONTINUE`, `Index` can be returned.
|
|
1078
|
-
* @template {UnistNode} [Visited=UnistNode]
|
|
1079
|
-
* Visited node type.
|
|
1080
|
-
* @template {UnistParent} [Ancestor=UnistParent]
|
|
1081
|
-
* Ancestor type.
|
|
1082
|
-
*/
|
|
1083
|
-
/**
|
|
1084
|
-
* @typedef {Visitor<Visited, Parent<Ancestor, Visited>>} BuildVisitorFromMatch
|
|
1085
|
-
* Build a typed `Visitor` function from a node and all possible parents.
|
|
1086
|
-
*
|
|
1087
|
-
* It will infer which values are passed as `node` and which as `parent`.
|
|
1088
|
-
* @template {UnistNode} Visited
|
|
1089
|
-
* Node type.
|
|
1090
|
-
* @template {UnistParent} Ancestor
|
|
1091
|
-
* Parent type.
|
|
1092
|
-
*/
|
|
1093
|
-
/**
|
|
1094
|
-
* @typedef {(
|
|
1095
|
-
* BuildVisitorFromMatch<
|
|
1096
|
-
* Matches<Descendant, Check>,
|
|
1097
|
-
* Extract<Descendant, UnistParent>
|
|
1098
|
-
* >
|
|
1099
|
-
* )} BuildVisitorFromDescendants
|
|
1100
|
-
* Build a typed `Visitor` function from a list of descendants and a test.
|
|
1101
|
-
*
|
|
1102
|
-
* It will infer which values are passed as `node` and which as `parent`.
|
|
1103
|
-
* @template {UnistNode} Descendant
|
|
1104
|
-
* Node type.
|
|
1105
|
-
* @template {Test} Check
|
|
1106
|
-
* Test type.
|
|
1107
|
-
*/
|
|
1108
|
-
/**
|
|
1109
|
-
* @typedef {(
|
|
1110
|
-
* BuildVisitorFromDescendants<
|
|
1111
|
-
* InclusiveDescendant<Tree>,
|
|
1112
|
-
* Check
|
|
1113
|
-
* >
|
|
1114
|
-
* )} BuildVisitor
|
|
1115
|
-
* Build a typed `Visitor` function from a tree and a test.
|
|
1116
|
-
*
|
|
1117
|
-
* It will infer which values are passed as `node` and which as `parent`.
|
|
1118
|
-
* @template {UnistNode} [Tree=UnistNode]
|
|
1119
|
-
* Node type.
|
|
1120
|
-
* @template {Test} [Check=Test]
|
|
1121
|
-
* Test type.
|
|
1122
|
-
*/
|
|
1123
|
-
/**
|
|
1124
|
-
* Visit nodes.
|
|
1125
|
-
*
|
|
1126
|
-
* This algorithm performs *depth-first* *tree traversal* in *preorder*
|
|
1127
|
-
* (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).
|
|
1128
|
-
*
|
|
1129
|
-
* You can choose for which nodes `visitor` is called by passing a `test`.
|
|
1130
|
-
* For complex tests, you should test yourself in `visitor`, as it will be
|
|
1131
|
-
* faster and will have improved type information.
|
|
1132
|
-
*
|
|
1133
|
-
* Walking the tree is an intensive task.
|
|
1134
|
-
* Make use of the return values of the visitor when possible.
|
|
1135
|
-
* Instead of walking a tree multiple times, walk it once, use `unist-util-is`
|
|
1136
|
-
* to check if a node matches, and then perform different operations.
|
|
1137
|
-
*
|
|
1138
|
-
* You can change the tree.
|
|
1139
|
-
* See `Visitor` for more info.
|
|
1140
|
-
*
|
|
1141
|
-
* @overload
|
|
1142
|
-
* @param {Tree} tree
|
|
1143
|
-
* @param {Check} check
|
|
1144
|
-
* @param {BuildVisitor<Tree, Check>} visitor
|
|
1145
|
-
* @param {boolean | null | undefined} [reverse]
|
|
1146
|
-
* @returns {undefined}
|
|
1147
|
-
*
|
|
1148
|
-
* @overload
|
|
1149
|
-
* @param {Tree} tree
|
|
1150
|
-
* @param {BuildVisitor<Tree>} visitor
|
|
1151
|
-
* @param {boolean | null | undefined} [reverse]
|
|
1152
|
-
* @returns {undefined}
|
|
1153
|
-
*
|
|
1154
|
-
* @param {UnistNode} tree
|
|
1155
|
-
* Tree to traverse.
|
|
1156
|
-
* @param {Visitor | Test} testOrVisitor
|
|
1157
|
-
* `unist-util-is`-compatible test (optional, omit to pass a visitor).
|
|
1158
|
-
* @param {Visitor | boolean | null | undefined} [visitorOrReverse]
|
|
1159
|
-
* Handle each node (when test is omitted, pass `reverse`).
|
|
1160
|
-
* @param {boolean | null | undefined} [maybeReverse=false]
|
|
1161
|
-
* Traverse in reverse preorder (NRL) instead of the default preorder (NLR).
|
|
1162
|
-
* @returns {undefined}
|
|
1163
|
-
* Nothing.
|
|
1164
|
-
*
|
|
1165
|
-
* @template {UnistNode} Tree
|
|
1166
|
-
* Node type.
|
|
1167
|
-
* @template {Test} Check
|
|
1168
|
-
* `unist-util-is`-compatible test.
|
|
1169
|
-
*/
|
|
1170
|
-
function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
|
|
1171
|
-
/** @type {boolean | null | undefined} */
|
|
1172
|
-
let reverse;
|
|
1173
|
-
/** @type {Test} */
|
|
1174
|
-
let test;
|
|
1175
|
-
/** @type {Visitor} */
|
|
1176
|
-
let visitor;
|
|
1177
|
-
if (typeof testOrVisitor === "function" && typeof visitorOrReverse !== "function") {
|
|
1178
|
-
test = void 0;
|
|
1179
|
-
visitor = testOrVisitor;
|
|
1180
|
-
reverse = visitorOrReverse;
|
|
1181
|
-
} else {
|
|
1182
|
-
test = testOrVisitor;
|
|
1183
|
-
visitor = visitorOrReverse;
|
|
1184
|
-
reverse = maybeReverse;
|
|
1185
|
-
}
|
|
1186
|
-
visitParents(tree, test, overload, reverse);
|
|
1187
|
-
/**
|
|
1188
|
-
* @param {UnistNode} node
|
|
1189
|
-
* @param {Array<UnistParent>} parents
|
|
1190
|
-
*/
|
|
1191
|
-
function overload(node, parents) {
|
|
1192
|
-
const parent = parents[parents.length - 1];
|
|
1193
|
-
const index = parent ? parent.children.indexOf(node) : void 0;
|
|
1194
|
-
return visitor(node, index, parent);
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
//#endregion
|
|
1199
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.js
|
|
1200
|
-
/**
|
|
1201
|
-
* @import {State} from 'mdast-util-to-markdown'
|
|
1202
|
-
* @import {Heading} from 'mdast'
|
|
1203
|
-
*/
|
|
1204
|
-
/**
|
|
1205
|
-
* @param {Heading} node
|
|
1206
|
-
* @param {State} state
|
|
1207
|
-
* @returns {boolean}
|
|
1208
|
-
*/
|
|
1209
|
-
function formatHeadingAsSetext(node, state) {
|
|
1210
|
-
let literalWithBreak = false;
|
|
1211
|
-
visit(node, function(node) {
|
|
1212
|
-
if ("value" in node && /\r?\n|\r/.test(node.value) || node.type === "break") {
|
|
1213
|
-
literalWithBreak = true;
|
|
1214
|
-
return EXIT;
|
|
1215
|
-
}
|
|
1216
|
-
});
|
|
1217
|
-
return Boolean((!node.depth || node.depth < 3) && toString(node) && (state.options.setext || literalWithBreak));
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
//#endregion
|
|
1221
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/handle/heading.js
|
|
1222
|
-
/**
|
|
1223
|
-
* @import {Info, State} from 'mdast-util-to-markdown'
|
|
1224
|
-
* @import {Heading, Parents} from 'mdast'
|
|
1225
|
-
*/
|
|
1226
|
-
/**
|
|
1227
|
-
* @param {Heading} node
|
|
1228
|
-
* @param {Parents | undefined} _
|
|
1229
|
-
* @param {State} state
|
|
1230
|
-
* @param {Info} info
|
|
1231
|
-
* @returns {string}
|
|
1232
|
-
*/
|
|
1233
|
-
function heading(node, _, state, info) {
|
|
1234
|
-
const rank = Math.max(Math.min(6, node.depth || 1), 1);
|
|
1235
|
-
const tracker = state.createTracker(info);
|
|
1236
|
-
if (formatHeadingAsSetext(node, state)) {
|
|
1237
|
-
const exit = state.enter("headingSetext");
|
|
1238
|
-
const subexit = state.enter("phrasing");
|
|
1239
|
-
const value = state.containerPhrasing(node, {
|
|
1240
|
-
...tracker.current(),
|
|
1241
|
-
before: "\n",
|
|
1242
|
-
after: "\n"
|
|
1243
|
-
});
|
|
1244
|
-
subexit();
|
|
1245
|
-
exit();
|
|
1246
|
-
return value + "\n" + (rank === 1 ? "=" : "-").repeat(value.length - (Math.max(value.lastIndexOf("\r"), value.lastIndexOf("\n")) + 1));
|
|
1247
|
-
}
|
|
1248
|
-
const sequence = "#".repeat(rank);
|
|
1249
|
-
const exit = state.enter("headingAtx");
|
|
1250
|
-
const subexit = state.enter("phrasing");
|
|
1251
|
-
tracker.move(sequence + " ");
|
|
1252
|
-
let value = state.containerPhrasing(node, {
|
|
1253
|
-
before: "# ",
|
|
1254
|
-
after: "\n",
|
|
1255
|
-
...tracker.current()
|
|
1256
|
-
});
|
|
1257
|
-
if (/^[\t ]/.test(value)) value = encodeCharacterReference(value.charCodeAt(0)) + value.slice(1);
|
|
1258
|
-
value = value ? sequence + " " + value : sequence;
|
|
1259
|
-
if (state.options.closeAtx) value += " " + sequence;
|
|
1260
|
-
subexit();
|
|
1261
|
-
exit();
|
|
1262
|
-
return value;
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1265
|
-
//#endregion
|
|
1266
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/handle/html.js
|
|
1267
|
-
/**
|
|
1268
|
-
* @import {Html} from 'mdast'
|
|
1269
|
-
*/
|
|
1270
|
-
html.peek = htmlPeek;
|
|
1271
|
-
/**
|
|
1272
|
-
* @param {Html} node
|
|
1273
|
-
* @returns {string}
|
|
1274
|
-
*/
|
|
1275
|
-
function html(node) {
|
|
1276
|
-
return node.value || "";
|
|
1277
|
-
}
|
|
1278
|
-
/**
|
|
1279
|
-
* @returns {string}
|
|
1280
|
-
*/
|
|
1281
|
-
function htmlPeek() {
|
|
1282
|
-
return "<";
|
|
1283
|
-
}
|
|
1284
|
-
|
|
1285
|
-
//#endregion
|
|
1286
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/handle/image.js
|
|
1287
|
-
/**
|
|
1288
|
-
* @import {Info, State} from 'mdast-util-to-markdown'
|
|
1289
|
-
* @import {Image, Parents} from 'mdast'
|
|
1290
|
-
*/
|
|
1291
|
-
image.peek = imagePeek;
|
|
1292
|
-
/**
|
|
1293
|
-
* @param {Image} node
|
|
1294
|
-
* @param {Parents | undefined} _
|
|
1295
|
-
* @param {State} state
|
|
1296
|
-
* @param {Info} info
|
|
1297
|
-
* @returns {string}
|
|
1298
|
-
*/
|
|
1299
|
-
function image(node, _, state, info) {
|
|
1300
|
-
const quote = checkQuote(state);
|
|
1301
|
-
const suffix = quote === "\"" ? "Quote" : "Apostrophe";
|
|
1302
|
-
const exit = state.enter("image");
|
|
1303
|
-
let subexit = state.enter("label");
|
|
1304
|
-
const tracker = state.createTracker(info);
|
|
1305
|
-
let value = tracker.move("![");
|
|
1306
|
-
value += tracker.move(state.safe(node.alt, {
|
|
1307
|
-
before: value,
|
|
1308
|
-
after: "]",
|
|
1309
|
-
...tracker.current()
|
|
1310
|
-
}));
|
|
1311
|
-
value += tracker.move("](");
|
|
1312
|
-
subexit();
|
|
1313
|
-
if (!node.url && node.title || /[\0- \u007F]/.test(node.url)) {
|
|
1314
|
-
subexit = state.enter("destinationLiteral");
|
|
1315
|
-
value += tracker.move("<");
|
|
1316
|
-
value += tracker.move(state.safe(node.url, {
|
|
1317
|
-
before: value,
|
|
1318
|
-
after: ">",
|
|
1319
|
-
...tracker.current()
|
|
1320
|
-
}));
|
|
1321
|
-
value += tracker.move(">");
|
|
1322
|
-
} else {
|
|
1323
|
-
subexit = state.enter("destinationRaw");
|
|
1324
|
-
value += tracker.move(state.safe(node.url, {
|
|
1325
|
-
before: value,
|
|
1326
|
-
after: node.title ? " " : ")",
|
|
1327
|
-
...tracker.current()
|
|
1328
|
-
}));
|
|
1329
|
-
}
|
|
1330
|
-
subexit();
|
|
1331
|
-
if (node.title) {
|
|
1332
|
-
subexit = state.enter(`title${suffix}`);
|
|
1333
|
-
value += tracker.move(" " + quote);
|
|
1334
|
-
value += tracker.move(state.safe(node.title, {
|
|
1335
|
-
before: value,
|
|
1336
|
-
after: quote,
|
|
1337
|
-
...tracker.current()
|
|
1338
|
-
}));
|
|
1339
|
-
value += tracker.move(quote);
|
|
1340
|
-
subexit();
|
|
1341
|
-
}
|
|
1342
|
-
value += tracker.move(")");
|
|
1343
|
-
exit();
|
|
1344
|
-
return value;
|
|
1345
|
-
}
|
|
1346
|
-
/**
|
|
1347
|
-
* @returns {string}
|
|
1348
|
-
*/
|
|
1349
|
-
function imagePeek() {
|
|
1350
|
-
return "!";
|
|
1351
|
-
}
|
|
1352
|
-
|
|
1353
|
-
//#endregion
|
|
1354
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/handle/image-reference.js
|
|
1355
|
-
/**
|
|
1356
|
-
* @import {Info, State} from 'mdast-util-to-markdown'
|
|
1357
|
-
* @import {ImageReference, Parents} from 'mdast'
|
|
1358
|
-
*/
|
|
1359
|
-
imageReference.peek = imageReferencePeek;
|
|
1360
|
-
/**
|
|
1361
|
-
* @param {ImageReference} node
|
|
1362
|
-
* @param {Parents | undefined} _
|
|
1363
|
-
* @param {State} state
|
|
1364
|
-
* @param {Info} info
|
|
1365
|
-
* @returns {string}
|
|
1366
|
-
*/
|
|
1367
|
-
function imageReference(node, _, state, info) {
|
|
1368
|
-
const type = node.referenceType;
|
|
1369
|
-
const exit = state.enter("imageReference");
|
|
1370
|
-
let subexit = state.enter("label");
|
|
1371
|
-
const tracker = state.createTracker(info);
|
|
1372
|
-
let value = tracker.move("![");
|
|
1373
|
-
const alt = state.safe(node.alt, {
|
|
1374
|
-
before: value,
|
|
1375
|
-
after: "]",
|
|
1376
|
-
...tracker.current()
|
|
1377
|
-
});
|
|
1378
|
-
value += tracker.move(alt + "][");
|
|
1379
|
-
subexit();
|
|
1380
|
-
const stack = state.stack;
|
|
1381
|
-
state.stack = [];
|
|
1382
|
-
subexit = state.enter("reference");
|
|
1383
|
-
const reference = state.safe(state.associationId(node), {
|
|
1384
|
-
before: value,
|
|
1385
|
-
after: "]",
|
|
1386
|
-
...tracker.current()
|
|
1387
|
-
});
|
|
1388
|
-
subexit();
|
|
1389
|
-
state.stack = stack;
|
|
1390
|
-
exit();
|
|
1391
|
-
if (type === "full" || !alt || alt !== reference) value += tracker.move(reference + "]");
|
|
1392
|
-
else if (type === "shortcut") value = value.slice(0, -1);
|
|
1393
|
-
else value += tracker.move("]");
|
|
1394
|
-
return value;
|
|
1395
|
-
}
|
|
1396
|
-
/**
|
|
1397
|
-
* @returns {string}
|
|
1398
|
-
*/
|
|
1399
|
-
function imageReferencePeek() {
|
|
1400
|
-
return "!";
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
//#endregion
|
|
1404
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/handle/inline-code.js
|
|
1405
|
-
/**
|
|
1406
|
-
* @import {State} from 'mdast-util-to-markdown'
|
|
1407
|
-
* @import {InlineCode, Parents} from 'mdast'
|
|
1408
|
-
*/
|
|
1409
|
-
inlineCode.peek = inlineCodePeek;
|
|
1410
|
-
/**
|
|
1411
|
-
* @param {InlineCode} node
|
|
1412
|
-
* @param {Parents | undefined} _
|
|
1413
|
-
* @param {State} state
|
|
1414
|
-
* @returns {string}
|
|
1415
|
-
*/
|
|
1416
|
-
function inlineCode(node, _, state) {
|
|
1417
|
-
let value = node.value || "";
|
|
1418
|
-
let sequence = "`";
|
|
1419
|
-
let index = -1;
|
|
1420
|
-
while (new RegExp("(^|[^`])" + sequence + "([^`]|$)").test(value)) sequence += "`";
|
|
1421
|
-
if (/[^ \r\n]/.test(value) && (/^[ \r\n]/.test(value) && /[ \r\n]$/.test(value) || /^`|`$/.test(value))) value = " " + value + " ";
|
|
1422
|
-
while (++index < state.unsafe.length) {
|
|
1423
|
-
const pattern = state.unsafe[index];
|
|
1424
|
-
const expression = state.compilePattern(pattern);
|
|
1425
|
-
/** @type {RegExpExecArray | null} */
|
|
1426
|
-
let match;
|
|
1427
|
-
if (!pattern.atBreak) continue;
|
|
1428
|
-
while (match = expression.exec(value)) {
|
|
1429
|
-
let position = match.index;
|
|
1430
|
-
if (value.charCodeAt(position) === 10 && value.charCodeAt(position - 1) === 13) position--;
|
|
1431
|
-
value = value.slice(0, position) + " " + value.slice(match.index + 1);
|
|
1432
|
-
}
|
|
1433
|
-
}
|
|
1434
|
-
return sequence + value + sequence;
|
|
1435
|
-
}
|
|
1436
|
-
/**
|
|
1437
|
-
* @returns {string}
|
|
1438
|
-
*/
|
|
1439
|
-
function inlineCodePeek() {
|
|
1440
|
-
return "`";
|
|
1441
|
-
}
|
|
1442
|
-
|
|
1443
|
-
//#endregion
|
|
1444
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/util/format-link-as-autolink.js
|
|
1445
|
-
/**
|
|
1446
|
-
* @import {State} from 'mdast-util-to-markdown'
|
|
1447
|
-
* @import {Link} from 'mdast'
|
|
1448
|
-
*/
|
|
1449
|
-
/**
|
|
1450
|
-
* @param {Link} node
|
|
1451
|
-
* @param {State} state
|
|
1452
|
-
* @returns {boolean}
|
|
1453
|
-
*/
|
|
1454
|
-
function formatLinkAsAutolink(node, state) {
|
|
1455
|
-
const raw = toString(node);
|
|
1456
|
-
return Boolean(!state.options.resourceLink && node.url && !node.title && node.children && node.children.length === 1 && node.children[0].type === "text" && (raw === node.url || "mailto:" + raw === node.url) && /^[a-z][a-z+.-]+:/i.test(node.url) && !/[\0- <>\u007F]/.test(node.url));
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
//#endregion
|
|
1460
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/handle/link.js
|
|
1461
|
-
/**
|
|
1462
|
-
* @import {Info, State} from 'mdast-util-to-markdown'
|
|
1463
|
-
* @import {Link, Parents} from 'mdast'
|
|
1464
|
-
* @import {Exit} from '../types.js'
|
|
1465
|
-
*/
|
|
1466
|
-
link.peek = linkPeek;
|
|
1467
|
-
/**
|
|
1468
|
-
* @param {Link} node
|
|
1469
|
-
* @param {Parents | undefined} _
|
|
1470
|
-
* @param {State} state
|
|
1471
|
-
* @param {Info} info
|
|
1472
|
-
* @returns {string}
|
|
1473
|
-
*/
|
|
1474
|
-
function link(node, _, state, info) {
|
|
1475
|
-
const quote = checkQuote(state);
|
|
1476
|
-
const suffix = quote === "\"" ? "Quote" : "Apostrophe";
|
|
1477
|
-
const tracker = state.createTracker(info);
|
|
1478
|
-
/** @type {Exit} */
|
|
1479
|
-
let exit;
|
|
1480
|
-
/** @type {Exit} */
|
|
1481
|
-
let subexit;
|
|
1482
|
-
if (formatLinkAsAutolink(node, state)) {
|
|
1483
|
-
const stack = state.stack;
|
|
1484
|
-
state.stack = [];
|
|
1485
|
-
exit = state.enter("autolink");
|
|
1486
|
-
let value = tracker.move("<");
|
|
1487
|
-
value += tracker.move(state.containerPhrasing(node, {
|
|
1488
|
-
before: value,
|
|
1489
|
-
after: ">",
|
|
1490
|
-
...tracker.current()
|
|
1491
|
-
}));
|
|
1492
|
-
value += tracker.move(">");
|
|
1493
|
-
exit();
|
|
1494
|
-
state.stack = stack;
|
|
1495
|
-
return value;
|
|
1496
|
-
}
|
|
1497
|
-
exit = state.enter("link");
|
|
1498
|
-
subexit = state.enter("label");
|
|
1499
|
-
let value = tracker.move("[");
|
|
1500
|
-
value += tracker.move(state.containerPhrasing(node, {
|
|
1501
|
-
before: value,
|
|
1502
|
-
after: "](",
|
|
1503
|
-
...tracker.current()
|
|
1504
|
-
}));
|
|
1505
|
-
value += tracker.move("](");
|
|
1506
|
-
subexit();
|
|
1507
|
-
if (!node.url && node.title || /[\0- \u007F]/.test(node.url)) {
|
|
1508
|
-
subexit = state.enter("destinationLiteral");
|
|
1509
|
-
value += tracker.move("<");
|
|
1510
|
-
value += tracker.move(state.safe(node.url, {
|
|
1511
|
-
before: value,
|
|
1512
|
-
after: ">",
|
|
1513
|
-
...tracker.current()
|
|
1514
|
-
}));
|
|
1515
|
-
value += tracker.move(">");
|
|
1516
|
-
} else {
|
|
1517
|
-
subexit = state.enter("destinationRaw");
|
|
1518
|
-
value += tracker.move(state.safe(node.url, {
|
|
1519
|
-
before: value,
|
|
1520
|
-
after: node.title ? " " : ")",
|
|
1521
|
-
...tracker.current()
|
|
1522
|
-
}));
|
|
1523
|
-
}
|
|
1524
|
-
subexit();
|
|
1525
|
-
if (node.title) {
|
|
1526
|
-
subexit = state.enter(`title${suffix}`);
|
|
1527
|
-
value += tracker.move(" " + quote);
|
|
1528
|
-
value += tracker.move(state.safe(node.title, {
|
|
1529
|
-
before: value,
|
|
1530
|
-
after: quote,
|
|
1531
|
-
...tracker.current()
|
|
1532
|
-
}));
|
|
1533
|
-
value += tracker.move(quote);
|
|
1534
|
-
subexit();
|
|
1535
|
-
}
|
|
1536
|
-
value += tracker.move(")");
|
|
1537
|
-
exit();
|
|
1538
|
-
return value;
|
|
1539
|
-
}
|
|
1540
|
-
/**
|
|
1541
|
-
* @param {Link} node
|
|
1542
|
-
* @param {Parents | undefined} _
|
|
1543
|
-
* @param {State} state
|
|
1544
|
-
* @returns {string}
|
|
1545
|
-
*/
|
|
1546
|
-
function linkPeek(node, _, state) {
|
|
1547
|
-
return formatLinkAsAutolink(node, state) ? "<" : "[";
|
|
1548
|
-
}
|
|
1549
|
-
|
|
1550
|
-
//#endregion
|
|
1551
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/handle/link-reference.js
|
|
1552
|
-
/**
|
|
1553
|
-
* @import {Info, State} from 'mdast-util-to-markdown'
|
|
1554
|
-
* @import {LinkReference, Parents} from 'mdast'
|
|
1555
|
-
*/
|
|
1556
|
-
linkReference.peek = linkReferencePeek;
|
|
1557
|
-
/**
|
|
1558
|
-
* @param {LinkReference} node
|
|
1559
|
-
* @param {Parents | undefined} _
|
|
1560
|
-
* @param {State} state
|
|
1561
|
-
* @param {Info} info
|
|
1562
|
-
* @returns {string}
|
|
1563
|
-
*/
|
|
1564
|
-
function linkReference(node, _, state, info) {
|
|
1565
|
-
const type = node.referenceType;
|
|
1566
|
-
const exit = state.enter("linkReference");
|
|
1567
|
-
let subexit = state.enter("label");
|
|
1568
|
-
const tracker = state.createTracker(info);
|
|
1569
|
-
let value = tracker.move("[");
|
|
1570
|
-
const text = state.containerPhrasing(node, {
|
|
1571
|
-
before: value,
|
|
1572
|
-
after: "]",
|
|
1573
|
-
...tracker.current()
|
|
1574
|
-
});
|
|
1575
|
-
value += tracker.move(text + "][");
|
|
1576
|
-
subexit();
|
|
1577
|
-
const stack = state.stack;
|
|
1578
|
-
state.stack = [];
|
|
1579
|
-
subexit = state.enter("reference");
|
|
1580
|
-
const reference = state.safe(state.associationId(node), {
|
|
1581
|
-
before: value,
|
|
1582
|
-
after: "]",
|
|
1583
|
-
...tracker.current()
|
|
1584
|
-
});
|
|
1585
|
-
subexit();
|
|
1586
|
-
state.stack = stack;
|
|
1587
|
-
exit();
|
|
1588
|
-
if (type === "full" || !text || text !== reference) value += tracker.move(reference + "]");
|
|
1589
|
-
else if (type === "shortcut") value = value.slice(0, -1);
|
|
1590
|
-
else value += tracker.move("]");
|
|
1591
|
-
return value;
|
|
1592
|
-
}
|
|
1593
|
-
/**
|
|
1594
|
-
* @returns {string}
|
|
1595
|
-
*/
|
|
1596
|
-
function linkReferencePeek() {
|
|
1597
|
-
return "[";
|
|
1598
|
-
}
|
|
1599
|
-
|
|
1600
|
-
//#endregion
|
|
1601
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/util/check-bullet.js
|
|
1602
|
-
/**
|
|
1603
|
-
* @import {Options, State} from 'mdast-util-to-markdown'
|
|
1604
|
-
*/
|
|
1605
|
-
/**
|
|
1606
|
-
* @param {State} state
|
|
1607
|
-
* @returns {Exclude<Options['bullet'], null | undefined>}
|
|
1608
|
-
*/
|
|
1609
|
-
function checkBullet(state) {
|
|
1610
|
-
const marker = state.options.bullet || "*";
|
|
1611
|
-
if (marker !== "*" && marker !== "+" && marker !== "-") throw new Error("Cannot serialize items with `" + marker + "` for `options.bullet`, expected `*`, `+`, or `-`");
|
|
1612
|
-
return marker;
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
//#endregion
|
|
1616
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/util/check-bullet-other.js
|
|
1617
|
-
/**
|
|
1618
|
-
* @import {Options, State} from 'mdast-util-to-markdown'
|
|
1619
|
-
*/
|
|
1620
|
-
/**
|
|
1621
|
-
* @param {State} state
|
|
1622
|
-
* @returns {Exclude<Options['bullet'], null | undefined>}
|
|
1623
|
-
*/
|
|
1624
|
-
function checkBulletOther(state) {
|
|
1625
|
-
const bullet = checkBullet(state);
|
|
1626
|
-
const bulletOther = state.options.bulletOther;
|
|
1627
|
-
if (!bulletOther) return bullet === "*" ? "-" : "*";
|
|
1628
|
-
if (bulletOther !== "*" && bulletOther !== "+" && bulletOther !== "-") throw new Error("Cannot serialize items with `" + bulletOther + "` for `options.bulletOther`, expected `*`, `+`, or `-`");
|
|
1629
|
-
if (bulletOther === bullet) throw new Error("Expected `bullet` (`" + bullet + "`) and `bulletOther` (`" + bulletOther + "`) to be different");
|
|
1630
|
-
return bulletOther;
|
|
1631
|
-
}
|
|
1632
|
-
|
|
1633
|
-
//#endregion
|
|
1634
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/util/check-bullet-ordered.js
|
|
1635
|
-
/**
|
|
1636
|
-
* @import {Options, State} from 'mdast-util-to-markdown'
|
|
1637
|
-
*/
|
|
1638
|
-
/**
|
|
1639
|
-
* @param {State} state
|
|
1640
|
-
* @returns {Exclude<Options['bulletOrdered'], null | undefined>}
|
|
1641
|
-
*/
|
|
1642
|
-
function checkBulletOrdered(state) {
|
|
1643
|
-
const marker = state.options.bulletOrdered || ".";
|
|
1644
|
-
if (marker !== "." && marker !== ")") throw new Error("Cannot serialize items with `" + marker + "` for `options.bulletOrdered`, expected `.` or `)`");
|
|
1645
|
-
return marker;
|
|
1646
|
-
}
|
|
1647
|
-
|
|
1648
|
-
//#endregion
|
|
1649
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/util/check-rule.js
|
|
1650
|
-
/**
|
|
1651
|
-
* @import {Options, State} from 'mdast-util-to-markdown'
|
|
1652
|
-
*/
|
|
1653
|
-
/**
|
|
1654
|
-
* @param {State} state
|
|
1655
|
-
* @returns {Exclude<Options['rule'], null | undefined>}
|
|
1656
|
-
*/
|
|
1657
|
-
function checkRule(state) {
|
|
1658
|
-
const marker = state.options.rule || "*";
|
|
1659
|
-
if (marker !== "*" && marker !== "-" && marker !== "_") throw new Error("Cannot serialize rules with `" + marker + "` for `options.rule`, expected `*`, `-`, or `_`");
|
|
1660
|
-
return marker;
|
|
1661
|
-
}
|
|
1662
|
-
|
|
1663
|
-
//#endregion
|
|
1664
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/handle/list.js
|
|
1665
|
-
/**
|
|
1666
|
-
* @import {Info, State} from 'mdast-util-to-markdown'
|
|
1667
|
-
* @import {List, Parents} from 'mdast'
|
|
1668
|
-
*/
|
|
1669
|
-
/**
|
|
1670
|
-
* @param {List} node
|
|
1671
|
-
* @param {Parents | undefined} parent
|
|
1672
|
-
* @param {State} state
|
|
1673
|
-
* @param {Info} info
|
|
1674
|
-
* @returns {string}
|
|
1675
|
-
*/
|
|
1676
|
-
function list(node, parent, state, info) {
|
|
1677
|
-
const exit = state.enter("list");
|
|
1678
|
-
const bulletCurrent = state.bulletCurrent;
|
|
1679
|
-
/** @type {string} */
|
|
1680
|
-
let bullet = node.ordered ? checkBulletOrdered(state) : checkBullet(state);
|
|
1681
|
-
/** @type {string} */
|
|
1682
|
-
const bulletOther = node.ordered ? bullet === "." ? ")" : "." : checkBulletOther(state);
|
|
1683
|
-
let useDifferentMarker = parent && state.bulletLastUsed ? bullet === state.bulletLastUsed : false;
|
|
1684
|
-
if (!node.ordered) {
|
|
1685
|
-
const firstListItem = node.children ? node.children[0] : void 0;
|
|
1686
|
-
if ((bullet === "*" || bullet === "-") && firstListItem && (!firstListItem.children || !firstListItem.children[0]) && state.stack[state.stack.length - 1] === "list" && state.stack[state.stack.length - 2] === "listItem" && state.stack[state.stack.length - 3] === "list" && state.stack[state.stack.length - 4] === "listItem" && state.indexStack[state.indexStack.length - 1] === 0 && state.indexStack[state.indexStack.length - 2] === 0 && state.indexStack[state.indexStack.length - 3] === 0) useDifferentMarker = true;
|
|
1687
|
-
if (checkRule(state) === bullet && firstListItem) {
|
|
1688
|
-
let index = -1;
|
|
1689
|
-
while (++index < node.children.length) {
|
|
1690
|
-
const item = node.children[index];
|
|
1691
|
-
if (item && item.type === "listItem" && item.children && item.children[0] && item.children[0].type === "thematicBreak") {
|
|
1692
|
-
useDifferentMarker = true;
|
|
1693
|
-
break;
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1698
|
-
if (useDifferentMarker) bullet = bulletOther;
|
|
1699
|
-
state.bulletCurrent = bullet;
|
|
1700
|
-
const value = state.containerFlow(node, info);
|
|
1701
|
-
state.bulletLastUsed = bullet;
|
|
1702
|
-
state.bulletCurrent = bulletCurrent;
|
|
1703
|
-
exit();
|
|
1704
|
-
return value;
|
|
1705
|
-
}
|
|
1706
|
-
|
|
1707
|
-
//#endregion
|
|
1708
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/util/check-list-item-indent.js
|
|
1709
|
-
/**
|
|
1710
|
-
* @import {Options, State} from 'mdast-util-to-markdown'
|
|
1711
|
-
*/
|
|
1712
|
-
/**
|
|
1713
|
-
* @param {State} state
|
|
1714
|
-
* @returns {Exclude<Options['listItemIndent'], null | undefined>}
|
|
1715
|
-
*/
|
|
1716
|
-
function checkListItemIndent(state) {
|
|
1717
|
-
const style = state.options.listItemIndent || "one";
|
|
1718
|
-
if (style !== "tab" && style !== "one" && style !== "mixed") throw new Error("Cannot serialize items with `" + style + "` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");
|
|
1719
|
-
return style;
|
|
1720
|
-
}
|
|
1721
|
-
|
|
1722
|
-
//#endregion
|
|
1723
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/handle/list-item.js
|
|
1724
|
-
/**
|
|
1725
|
-
* @import {Info, Map, State} from 'mdast-util-to-markdown'
|
|
1726
|
-
* @import {ListItem, Parents} from 'mdast'
|
|
1727
|
-
*/
|
|
1728
|
-
/**
|
|
1729
|
-
* @param {ListItem} node
|
|
1730
|
-
* @param {Parents | undefined} parent
|
|
1731
|
-
* @param {State} state
|
|
1732
|
-
* @param {Info} info
|
|
1733
|
-
* @returns {string}
|
|
1734
|
-
*/
|
|
1735
|
-
function listItem(node, parent, state, info) {
|
|
1736
|
-
const listItemIndent = checkListItemIndent(state);
|
|
1737
|
-
let bullet = state.bulletCurrent || checkBullet(state);
|
|
1738
|
-
if (parent && parent.type === "list" && parent.ordered) bullet = (typeof parent.start === "number" && parent.start > -1 ? parent.start : 1) + (state.options.incrementListMarker === false ? 0 : parent.children.indexOf(node)) + bullet;
|
|
1739
|
-
let size = bullet.length + 1;
|
|
1740
|
-
if (listItemIndent === "tab" || listItemIndent === "mixed" && (parent && parent.type === "list" && parent.spread || node.spread)) size = Math.ceil(size / 4) * 4;
|
|
1741
|
-
const tracker = state.createTracker(info);
|
|
1742
|
-
tracker.move(bullet + " ".repeat(size - bullet.length));
|
|
1743
|
-
tracker.shift(size);
|
|
1744
|
-
const exit = state.enter("listItem");
|
|
1745
|
-
const value = state.indentLines(state.containerFlow(node, tracker.current()), map);
|
|
1746
|
-
exit();
|
|
1747
|
-
return value;
|
|
1748
|
-
/** @type {Map} */
|
|
1749
|
-
function map(line, index, blank) {
|
|
1750
|
-
if (index) return (blank ? "" : " ".repeat(size)) + line;
|
|
1751
|
-
return (blank ? bullet : bullet + " ".repeat(size - bullet.length)) + line;
|
|
1752
|
-
}
|
|
1753
|
-
}
|
|
1754
|
-
|
|
1755
|
-
//#endregion
|
|
1756
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/handle/paragraph.js
|
|
1757
|
-
/**
|
|
1758
|
-
* @import {Info, State} from 'mdast-util-to-markdown'
|
|
1759
|
-
* @import {Paragraph, Parents} from 'mdast'
|
|
1760
|
-
*/
|
|
1761
|
-
/**
|
|
1762
|
-
* @param {Paragraph} node
|
|
1763
|
-
* @param {Parents | undefined} _
|
|
1764
|
-
* @param {State} state
|
|
1765
|
-
* @param {Info} info
|
|
1766
|
-
* @returns {string}
|
|
1767
|
-
*/
|
|
1768
|
-
function paragraph(node, _, state, info) {
|
|
1769
|
-
const exit = state.enter("paragraph");
|
|
1770
|
-
const subexit = state.enter("phrasing");
|
|
1771
|
-
const value = state.containerPhrasing(node, info);
|
|
1772
|
-
subexit();
|
|
1773
|
-
exit();
|
|
1774
|
-
return value;
|
|
1775
|
-
}
|
|
1776
|
-
|
|
1777
|
-
//#endregion
|
|
1778
|
-
//#region ../../node_modules/.pnpm/mdast-util-phrasing@4.1.0/node_modules/mdast-util-phrasing/lib/index.js
|
|
1779
|
-
/**
|
|
1780
|
-
* @typedef {import('mdast').Html} Html
|
|
1781
|
-
* @typedef {import('mdast').PhrasingContent} PhrasingContent
|
|
1782
|
-
*/
|
|
1783
|
-
/**
|
|
1784
|
-
* Check if the given value is *phrasing content*.
|
|
1785
|
-
*
|
|
1786
|
-
* > 👉 **Note**: Excludes `html`, which can be both phrasing or flow.
|
|
1787
|
-
*
|
|
1788
|
-
* @param node
|
|
1789
|
-
* Thing to check, typically `Node`.
|
|
1790
|
-
* @returns
|
|
1791
|
-
* Whether `value` is phrasing content.
|
|
1792
|
-
*/
|
|
1793
|
-
const phrasing = convert([
|
|
1794
|
-
"break",
|
|
1795
|
-
"delete",
|
|
1796
|
-
"emphasis",
|
|
1797
|
-
"footnote",
|
|
1798
|
-
"footnoteReference",
|
|
1799
|
-
"image",
|
|
1800
|
-
"imageReference",
|
|
1801
|
-
"inlineCode",
|
|
1802
|
-
"inlineMath",
|
|
1803
|
-
"link",
|
|
1804
|
-
"linkReference",
|
|
1805
|
-
"mdxJsxTextElement",
|
|
1806
|
-
"mdxTextExpression",
|
|
1807
|
-
"strong",
|
|
1808
|
-
"text",
|
|
1809
|
-
"textDirective"
|
|
1810
|
-
]);
|
|
1811
|
-
|
|
1812
|
-
//#endregion
|
|
1813
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/handle/root.js
|
|
1814
|
-
/**
|
|
1815
|
-
* @import {Info, State} from 'mdast-util-to-markdown'
|
|
1816
|
-
* @import {Parents, Root} from 'mdast'
|
|
1817
|
-
*/
|
|
1818
|
-
/**
|
|
1819
|
-
* @param {Root} node
|
|
1820
|
-
* @param {Parents | undefined} _
|
|
1821
|
-
* @param {State} state
|
|
1822
|
-
* @param {Info} info
|
|
1823
|
-
* @returns {string}
|
|
1824
|
-
*/
|
|
1825
|
-
function root(node, _, state, info) {
|
|
1826
|
-
return (node.children.some(function(d) {
|
|
1827
|
-
return phrasing(d);
|
|
1828
|
-
}) ? state.containerPhrasing : state.containerFlow).call(state, node, info);
|
|
1829
|
-
}
|
|
1830
|
-
|
|
1831
|
-
//#endregion
|
|
1832
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/util/check-strong.js
|
|
1833
|
-
/**
|
|
1834
|
-
* @import {Options, State} from 'mdast-util-to-markdown'
|
|
1835
|
-
*/
|
|
1836
|
-
/**
|
|
1837
|
-
* @param {State} state
|
|
1838
|
-
* @returns {Exclude<Options['strong'], null | undefined>}
|
|
1839
|
-
*/
|
|
1840
|
-
function checkStrong(state) {
|
|
1841
|
-
const marker = state.options.strong || "*";
|
|
1842
|
-
if (marker !== "*" && marker !== "_") throw new Error("Cannot serialize strong with `" + marker + "` for `options.strong`, expected `*`, or `_`");
|
|
1843
|
-
return marker;
|
|
1844
|
-
}
|
|
1845
|
-
|
|
1846
|
-
//#endregion
|
|
1847
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/handle/strong.js
|
|
1848
|
-
/**
|
|
1849
|
-
* @import {Info, State} from 'mdast-util-to-markdown'
|
|
1850
|
-
* @import {Parents, Strong} from 'mdast'
|
|
1851
|
-
*/
|
|
1852
|
-
strong.peek = strongPeek;
|
|
1853
|
-
/**
|
|
1854
|
-
* @param {Strong} node
|
|
1855
|
-
* @param {Parents | undefined} _
|
|
1856
|
-
* @param {State} state
|
|
1857
|
-
* @param {Info} info
|
|
1858
|
-
* @returns {string}
|
|
1859
|
-
*/
|
|
1860
|
-
function strong(node, _, state, info) {
|
|
1861
|
-
const marker = checkStrong(state);
|
|
1862
|
-
const exit = state.enter("strong");
|
|
1863
|
-
const tracker = state.createTracker(info);
|
|
1864
|
-
const before = tracker.move(marker + marker);
|
|
1865
|
-
let between = tracker.move(state.containerPhrasing(node, {
|
|
1866
|
-
after: marker,
|
|
1867
|
-
before,
|
|
1868
|
-
...tracker.current()
|
|
1869
|
-
}));
|
|
1870
|
-
const betweenHead = between.charCodeAt(0);
|
|
1871
|
-
const open = encodeInfo(info.before.charCodeAt(info.before.length - 1), betweenHead, marker);
|
|
1872
|
-
if (open.inside) between = encodeCharacterReference(betweenHead) + between.slice(1);
|
|
1873
|
-
const betweenTail = between.charCodeAt(between.length - 1);
|
|
1874
|
-
const close = encodeInfo(info.after.charCodeAt(0), betweenTail, marker);
|
|
1875
|
-
if (close.inside) between = between.slice(0, -1) + encodeCharacterReference(betweenTail);
|
|
1876
|
-
const after = tracker.move(marker + marker);
|
|
1877
|
-
exit();
|
|
1878
|
-
state.attentionEncodeSurroundingInfo = {
|
|
1879
|
-
after: close.outside,
|
|
1880
|
-
before: open.outside
|
|
1881
|
-
};
|
|
1882
|
-
return before + between + after;
|
|
1883
|
-
}
|
|
1884
|
-
/**
|
|
1885
|
-
* @param {Strong} _
|
|
1886
|
-
* @param {Parents | undefined} _1
|
|
1887
|
-
* @param {State} state
|
|
1888
|
-
* @returns {string}
|
|
1889
|
-
*/
|
|
1890
|
-
function strongPeek(_, _1, state) {
|
|
1891
|
-
return state.options.strong || "*";
|
|
1892
|
-
}
|
|
1893
|
-
|
|
1894
|
-
//#endregion
|
|
1895
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/handle/text.js
|
|
1896
|
-
/**
|
|
1897
|
-
* @import {Info, State} from 'mdast-util-to-markdown'
|
|
1898
|
-
* @import {Parents, Text} from 'mdast'
|
|
1899
|
-
*/
|
|
1900
|
-
/**
|
|
1901
|
-
* @param {Text} node
|
|
1902
|
-
* @param {Parents | undefined} _
|
|
1903
|
-
* @param {State} state
|
|
1904
|
-
* @param {Info} info
|
|
1905
|
-
* @returns {string}
|
|
1906
|
-
*/
|
|
1907
|
-
function text(node, _, state, info) {
|
|
1908
|
-
return state.safe(node.value, info);
|
|
1909
|
-
}
|
|
1910
|
-
|
|
1911
|
-
//#endregion
|
|
1912
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/util/check-rule-repetition.js
|
|
1913
|
-
/**
|
|
1914
|
-
* @import {Options, State} from 'mdast-util-to-markdown'
|
|
1915
|
-
*/
|
|
1916
|
-
/**
|
|
1917
|
-
* @param {State} state
|
|
1918
|
-
* @returns {Exclude<Options['ruleRepetition'], null | undefined>}
|
|
1919
|
-
*/
|
|
1920
|
-
function checkRuleRepetition(state) {
|
|
1921
|
-
const repetition = state.options.ruleRepetition || 3;
|
|
1922
|
-
if (repetition < 3) throw new Error("Cannot serialize rules with repetition `" + repetition + "` for `options.ruleRepetition`, expected `3` or more");
|
|
1923
|
-
return repetition;
|
|
1924
|
-
}
|
|
1925
|
-
|
|
1926
|
-
//#endregion
|
|
1927
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/handle/thematic-break.js
|
|
1928
|
-
/**
|
|
1929
|
-
* @import {State} from 'mdast-util-to-markdown'
|
|
1930
|
-
* @import {Parents, ThematicBreak} from 'mdast'
|
|
1931
|
-
*/
|
|
1932
|
-
/**
|
|
1933
|
-
* @param {ThematicBreak} _
|
|
1934
|
-
* @param {Parents | undefined} _1
|
|
1935
|
-
* @param {State} state
|
|
1936
|
-
* @returns {string}
|
|
1937
|
-
*/
|
|
1938
|
-
function thematicBreak(_, _1, state) {
|
|
1939
|
-
const value = (checkRule(state) + (state.options.ruleSpaces ? " " : "")).repeat(checkRuleRepetition(state));
|
|
1940
|
-
return state.options.ruleSpaces ? value.slice(0, -1) : value;
|
|
1941
|
-
}
|
|
1942
|
-
|
|
1943
|
-
//#endregion
|
|
1944
|
-
//#region ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/handle/index.js
|
|
1945
|
-
/**
|
|
1946
|
-
* Default (CommonMark) handlers.
|
|
1947
|
-
*/
|
|
1948
|
-
const handle = {
|
|
1949
|
-
blockquote,
|
|
1950
|
-
break: hardBreak,
|
|
1951
|
-
code,
|
|
1952
|
-
definition,
|
|
1953
|
-
emphasis,
|
|
1954
|
-
hardBreak,
|
|
1955
|
-
heading,
|
|
1956
|
-
html,
|
|
1957
|
-
image,
|
|
1958
|
-
imageReference,
|
|
1959
|
-
inlineCode,
|
|
1960
|
-
link,
|
|
1961
|
-
linkReference,
|
|
1962
|
-
list,
|
|
1963
|
-
listItem,
|
|
1964
|
-
paragraph,
|
|
1965
|
-
root,
|
|
1966
|
-
strong,
|
|
1967
|
-
text,
|
|
1968
|
-
thematicBreak
|
|
1969
|
-
};
|
|
1970
|
-
|
|
1971
|
-
//#endregion
|
|
1972
|
-
//#region ../../node_modules/.pnpm/mdast-util-gfm-table@2.0.0/node_modules/mdast-util-gfm-table/lib/index.js
|
|
1973
|
-
/**
|
|
1974
|
-
* @typedef {import('mdast').InlineCode} InlineCode
|
|
1975
|
-
* @typedef {import('mdast').Table} Table
|
|
1976
|
-
* @typedef {import('mdast').TableCell} TableCell
|
|
1977
|
-
* @typedef {import('mdast').TableRow} TableRow
|
|
1978
|
-
*
|
|
1979
|
-
* @typedef {import('markdown-table').Options} MarkdownTableOptions
|
|
1980
|
-
*
|
|
1981
|
-
* @typedef {import('mdast-util-from-markdown').CompileContext} CompileContext
|
|
1982
|
-
* @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension
|
|
1983
|
-
* @typedef {import('mdast-util-from-markdown').Handle} FromMarkdownHandle
|
|
1984
|
-
*
|
|
1985
|
-
* @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension
|
|
1986
|
-
* @typedef {import('mdast-util-to-markdown').Handle} ToMarkdownHandle
|
|
1987
|
-
* @typedef {import('mdast-util-to-markdown').State} State
|
|
1988
|
-
* @typedef {import('mdast-util-to-markdown').Info} Info
|
|
1989
|
-
*/
|
|
1990
|
-
/**
|
|
1991
|
-
* @typedef Options
|
|
1992
|
-
* Configuration.
|
|
1993
|
-
* @property {boolean | null | undefined} [tableCellPadding=true]
|
|
1994
|
-
* Whether to add a space of padding between delimiters and cells (default:
|
|
1995
|
-
* `true`).
|
|
1996
|
-
* @property {boolean | null | undefined} [tablePipeAlign=true]
|
|
1997
|
-
* Whether to align the delimiters (default: `true`).
|
|
1998
|
-
* @property {MarkdownTableOptions['stringLength'] | null | undefined} [stringLength]
|
|
1999
|
-
* Function to detect the length of table cell content, used when aligning
|
|
2000
|
-
* the delimiters between cells (optional).
|
|
2001
|
-
*/
|
|
2002
|
-
/**
|
|
2003
|
-
* Create an extension for `mdast-util-from-markdown` to enable GFM tables in
|
|
2004
|
-
* markdown.
|
|
2005
|
-
*
|
|
2006
|
-
* @returns {FromMarkdownExtension}
|
|
2007
|
-
* Extension for `mdast-util-from-markdown` to enable GFM tables.
|
|
2008
|
-
*/
|
|
2009
|
-
function gfmTableFromMarkdown() {
|
|
2010
|
-
return {
|
|
2011
|
-
enter: {
|
|
2012
|
-
table: enterTable,
|
|
2013
|
-
tableData: enterCell,
|
|
2014
|
-
tableHeader: enterCell,
|
|
2015
|
-
tableRow: enterRow
|
|
2016
|
-
},
|
|
2017
|
-
exit: {
|
|
2018
|
-
codeText: exitCodeText,
|
|
2019
|
-
table: exitTable,
|
|
2020
|
-
tableData: exit,
|
|
2021
|
-
tableHeader: exit,
|
|
2022
|
-
tableRow: exit
|
|
2023
|
-
}
|
|
2024
|
-
};
|
|
2025
|
-
}
|
|
2026
|
-
/**
|
|
2027
|
-
* @this {CompileContext}
|
|
2028
|
-
* @type {FromMarkdownHandle}
|
|
2029
|
-
*/
|
|
2030
|
-
function enterTable(token) {
|
|
2031
|
-
const align = token._align;
|
|
2032
|
-
/* @__PURE__ */ ok(align, "expected `_align` on table");
|
|
2033
|
-
this.enter({
|
|
2034
|
-
type: "table",
|
|
2035
|
-
align: align.map(function(d) {
|
|
2036
|
-
return d === "none" ? null : d;
|
|
2037
|
-
}),
|
|
2038
|
-
children: []
|
|
2039
|
-
}, token);
|
|
2040
|
-
this.data.inTable = true;
|
|
2041
|
-
}
|
|
2042
|
-
/**
|
|
2043
|
-
* @this {CompileContext}
|
|
2044
|
-
* @type {FromMarkdownHandle}
|
|
2045
|
-
*/
|
|
2046
|
-
function exitTable(token) {
|
|
2047
|
-
this.exit(token);
|
|
2048
|
-
this.data.inTable = void 0;
|
|
2049
|
-
}
|
|
2050
|
-
/**
|
|
2051
|
-
* @this {CompileContext}
|
|
2052
|
-
* @type {FromMarkdownHandle}
|
|
2053
|
-
*/
|
|
2054
|
-
function enterRow(token) {
|
|
2055
|
-
this.enter({
|
|
2056
|
-
type: "tableRow",
|
|
2057
|
-
children: []
|
|
2058
|
-
}, token);
|
|
2059
|
-
}
|
|
2060
|
-
/**
|
|
2061
|
-
* @this {CompileContext}
|
|
2062
|
-
* @type {FromMarkdownHandle}
|
|
2063
|
-
*/
|
|
2064
|
-
function exit(token) {
|
|
2065
|
-
this.exit(token);
|
|
2066
|
-
}
|
|
2067
|
-
/**
|
|
2068
|
-
* @this {CompileContext}
|
|
2069
|
-
* @type {FromMarkdownHandle}
|
|
2070
|
-
*/
|
|
2071
|
-
function enterCell(token) {
|
|
2072
|
-
this.enter({
|
|
2073
|
-
type: "tableCell",
|
|
2074
|
-
children: []
|
|
2075
|
-
}, token);
|
|
2076
|
-
}
|
|
2077
|
-
/**
|
|
2078
|
-
* @this {CompileContext}
|
|
2079
|
-
* @type {FromMarkdownHandle}
|
|
2080
|
-
*/
|
|
2081
|
-
function exitCodeText(token) {
|
|
2082
|
-
let value = this.resume();
|
|
2083
|
-
if (this.data.inTable) value = value.replace(/\\([\\|])/g, replace);
|
|
2084
|
-
const node = this.stack[this.stack.length - 1];
|
|
2085
|
-
/* @__PURE__ */ ok(node.type === "inlineCode");
|
|
2086
|
-
node.value = value;
|
|
2087
|
-
this.exit(token);
|
|
2088
|
-
}
|
|
2089
|
-
/**
|
|
2090
|
-
* @param {string} $0
|
|
2091
|
-
* @param {string} $1
|
|
2092
|
-
* @returns {string}
|
|
2093
|
-
*/
|
|
2094
|
-
function replace($0, $1) {
|
|
2095
|
-
return $1 === "|" ? $1 : $0;
|
|
2096
|
-
}
|
|
2097
|
-
/**
|
|
2098
|
-
* Create an extension for `mdast-util-to-markdown` to enable GFM tables in
|
|
2099
|
-
* markdown.
|
|
2100
|
-
*
|
|
2101
|
-
* @param {Options | null | undefined} [options]
|
|
2102
|
-
* Configuration.
|
|
2103
|
-
* @returns {ToMarkdownExtension}
|
|
2104
|
-
* Extension for `mdast-util-to-markdown` to enable GFM tables.
|
|
2105
|
-
*/
|
|
2106
|
-
function gfmTableToMarkdown(options) {
|
|
2107
|
-
const settings = options || {};
|
|
2108
|
-
const padding = settings.tableCellPadding;
|
|
2109
|
-
const alignDelimiters = settings.tablePipeAlign;
|
|
2110
|
-
const stringLength = settings.stringLength;
|
|
2111
|
-
const around = padding ? " " : "|";
|
|
2112
|
-
return {
|
|
2113
|
-
unsafe: [
|
|
2114
|
-
{
|
|
2115
|
-
character: "\r",
|
|
2116
|
-
inConstruct: "tableCell"
|
|
2117
|
-
},
|
|
2118
|
-
{
|
|
2119
|
-
character: "\n",
|
|
2120
|
-
inConstruct: "tableCell"
|
|
2121
|
-
},
|
|
2122
|
-
{
|
|
2123
|
-
atBreak: true,
|
|
2124
|
-
character: "|",
|
|
2125
|
-
after: "[ :-]"
|
|
2126
|
-
},
|
|
2127
|
-
{
|
|
2128
|
-
character: "|",
|
|
2129
|
-
inConstruct: "tableCell"
|
|
2130
|
-
},
|
|
2131
|
-
{
|
|
2132
|
-
atBreak: true,
|
|
2133
|
-
character: ":",
|
|
2134
|
-
after: "-"
|
|
2135
|
-
},
|
|
2136
|
-
{
|
|
2137
|
-
atBreak: true,
|
|
2138
|
-
character: "-",
|
|
2139
|
-
after: "[:|-]"
|
|
2140
|
-
}
|
|
2141
|
-
],
|
|
2142
|
-
handlers: {
|
|
2143
|
-
inlineCode: inlineCodeWithTable,
|
|
2144
|
-
table: handleTable,
|
|
2145
|
-
tableCell: handleTableCell,
|
|
2146
|
-
tableRow: handleTableRow
|
|
2147
|
-
}
|
|
2148
|
-
};
|
|
2149
|
-
/**
|
|
2150
|
-
* @type {ToMarkdownHandle}
|
|
2151
|
-
* @param {Table} node
|
|
2152
|
-
*/
|
|
2153
|
-
function handleTable(node, _, state, info) {
|
|
2154
|
-
return serializeData(handleTableAsData(node, state, info), node.align);
|
|
2155
|
-
}
|
|
2156
|
-
/**
|
|
2157
|
-
* This function isn’t really used normally, because we handle rows at the
|
|
2158
|
-
* table level.
|
|
2159
|
-
* But, if someone passes in a table row, this ensures we make somewhat sense.
|
|
2160
|
-
*
|
|
2161
|
-
* @type {ToMarkdownHandle}
|
|
2162
|
-
* @param {TableRow} node
|
|
2163
|
-
*/
|
|
2164
|
-
function handleTableRow(node, _, state, info) {
|
|
2165
|
-
const value = serializeData([handleTableRowAsData(node, state, info)]);
|
|
2166
|
-
return value.slice(0, value.indexOf("\n"));
|
|
2167
|
-
}
|
|
2168
|
-
/**
|
|
2169
|
-
* @type {ToMarkdownHandle}
|
|
2170
|
-
* @param {TableCell} node
|
|
2171
|
-
*/
|
|
2172
|
-
function handleTableCell(node, _, state, info) {
|
|
2173
|
-
const exit = state.enter("tableCell");
|
|
2174
|
-
const subexit = state.enter("phrasing");
|
|
2175
|
-
const value = state.containerPhrasing(node, {
|
|
2176
|
-
...info,
|
|
2177
|
-
before: around,
|
|
2178
|
-
after: around
|
|
2179
|
-
});
|
|
2180
|
-
subexit();
|
|
2181
|
-
exit();
|
|
2182
|
-
return value;
|
|
2183
|
-
}
|
|
2184
|
-
/**
|
|
2185
|
-
* @param {Array<Array<string>>} matrix
|
|
2186
|
-
* @param {Array<string | null | undefined> | null | undefined} [align]
|
|
2187
|
-
*/
|
|
2188
|
-
function serializeData(matrix, align) {
|
|
2189
|
-
return markdownTable(matrix, {
|
|
2190
|
-
align,
|
|
2191
|
-
alignDelimiters,
|
|
2192
|
-
padding,
|
|
2193
|
-
stringLength
|
|
2194
|
-
});
|
|
2195
|
-
}
|
|
2196
|
-
/**
|
|
2197
|
-
* @param {Table} node
|
|
2198
|
-
* @param {State} state
|
|
2199
|
-
* @param {Info} info
|
|
2200
|
-
*/
|
|
2201
|
-
function handleTableAsData(node, state, info) {
|
|
2202
|
-
const children = node.children;
|
|
2203
|
-
let index = -1;
|
|
2204
|
-
/** @type {Array<Array<string>>} */
|
|
2205
|
-
const result = [];
|
|
2206
|
-
const subexit = state.enter("table");
|
|
2207
|
-
while (++index < children.length) result[index] = handleTableRowAsData(children[index], state, info);
|
|
2208
|
-
subexit();
|
|
2209
|
-
return result;
|
|
2210
|
-
}
|
|
2211
|
-
/**
|
|
2212
|
-
* @param {TableRow} node
|
|
2213
|
-
* @param {State} state
|
|
2214
|
-
* @param {Info} info
|
|
2215
|
-
*/
|
|
2216
|
-
function handleTableRowAsData(node, state, info) {
|
|
2217
|
-
const children = node.children;
|
|
2218
|
-
let index = -1;
|
|
2219
|
-
/** @type {Array<string>} */
|
|
2220
|
-
const result = [];
|
|
2221
|
-
const subexit = state.enter("tableRow");
|
|
2222
|
-
while (++index < children.length) result[index] = handleTableCell(children[index], node, state, info);
|
|
2223
|
-
subexit();
|
|
2224
|
-
return result;
|
|
2225
|
-
}
|
|
2226
|
-
/**
|
|
2227
|
-
* @type {ToMarkdownHandle}
|
|
2228
|
-
* @param {InlineCode} node
|
|
2229
|
-
*/
|
|
2230
|
-
function inlineCodeWithTable(node, parent, state) {
|
|
2231
|
-
let value = handle.inlineCode(node, parent, state);
|
|
2232
|
-
if (state.stack.includes("tableCell")) value = value.replace(/\|/g, "\\$&");
|
|
2233
|
-
return value;
|
|
2234
|
-
}
|
|
2235
|
-
}
|
|
2236
|
-
|
|
2237
|
-
//#endregion
|
|
2238
|
-
//#region ../../node_modules/.pnpm/mdast-util-gfm-task-list-item@2.0.0/node_modules/mdast-util-gfm-task-list-item/lib/index.js
|
|
2239
|
-
/**
|
|
2240
|
-
* @typedef {import('mdast').ListItem} ListItem
|
|
2241
|
-
* @typedef {import('mdast').Paragraph} Paragraph
|
|
2242
|
-
* @typedef {import('mdast-util-from-markdown').CompileContext} CompileContext
|
|
2243
|
-
* @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension
|
|
2244
|
-
* @typedef {import('mdast-util-from-markdown').Handle} FromMarkdownHandle
|
|
2245
|
-
* @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension
|
|
2246
|
-
* @typedef {import('mdast-util-to-markdown').Handle} ToMarkdownHandle
|
|
2247
|
-
*/
|
|
2248
|
-
/**
|
|
2249
|
-
* Create an extension for `mdast-util-from-markdown` to enable GFM task
|
|
2250
|
-
* list items in markdown.
|
|
2251
|
-
*
|
|
2252
|
-
* @returns {FromMarkdownExtension}
|
|
2253
|
-
* Extension for `mdast-util-from-markdown` to enable GFM task list items.
|
|
2254
|
-
*/
|
|
2255
|
-
function gfmTaskListItemFromMarkdown() {
|
|
2256
|
-
return { exit: {
|
|
2257
|
-
taskListCheckValueChecked: exitCheck,
|
|
2258
|
-
taskListCheckValueUnchecked: exitCheck,
|
|
2259
|
-
paragraph: exitParagraphWithTaskListItem
|
|
2260
|
-
} };
|
|
2261
|
-
}
|
|
2262
|
-
/**
|
|
2263
|
-
* Create an extension for `mdast-util-to-markdown` to enable GFM task list
|
|
2264
|
-
* items in markdown.
|
|
2265
|
-
*
|
|
2266
|
-
* @returns {ToMarkdownExtension}
|
|
2267
|
-
* Extension for `mdast-util-to-markdown` to enable GFM task list items.
|
|
2268
|
-
*/
|
|
2269
|
-
function gfmTaskListItemToMarkdown() {
|
|
2270
|
-
return {
|
|
2271
|
-
unsafe: [{
|
|
2272
|
-
atBreak: true,
|
|
2273
|
-
character: "-",
|
|
2274
|
-
after: "[:|-]"
|
|
2275
|
-
}],
|
|
2276
|
-
handlers: { listItem: listItemWithTaskListItem }
|
|
2277
|
-
};
|
|
2278
|
-
}
|
|
2279
|
-
/**
|
|
2280
|
-
* @this {CompileContext}
|
|
2281
|
-
* @type {FromMarkdownHandle}
|
|
2282
|
-
*/
|
|
2283
|
-
function exitCheck(token) {
|
|
2284
|
-
const node = this.stack[this.stack.length - 2];
|
|
2285
|
-
/* @__PURE__ */ ok(node.type === "listItem");
|
|
2286
|
-
node.checked = token.type === "taskListCheckValueChecked";
|
|
2287
|
-
}
|
|
2288
|
-
/**
|
|
2289
|
-
* @this {CompileContext}
|
|
2290
|
-
* @type {FromMarkdownHandle}
|
|
2291
|
-
*/
|
|
2292
|
-
function exitParagraphWithTaskListItem(token) {
|
|
2293
|
-
const parent = this.stack[this.stack.length - 2];
|
|
2294
|
-
if (parent && parent.type === "listItem" && typeof parent.checked === "boolean") {
|
|
2295
|
-
const node = this.stack[this.stack.length - 1];
|
|
2296
|
-
/* @__PURE__ */ ok(node.type === "paragraph");
|
|
2297
|
-
const head = node.children[0];
|
|
2298
|
-
if (head && head.type === "text") {
|
|
2299
|
-
const siblings = parent.children;
|
|
2300
|
-
let index = -1;
|
|
2301
|
-
/** @type {Paragraph | undefined} */
|
|
2302
|
-
let firstParaghraph;
|
|
2303
|
-
while (++index < siblings.length) {
|
|
2304
|
-
const sibling = siblings[index];
|
|
2305
|
-
if (sibling.type === "paragraph") {
|
|
2306
|
-
firstParaghraph = sibling;
|
|
2307
|
-
break;
|
|
2308
|
-
}
|
|
2309
|
-
}
|
|
2310
|
-
if (firstParaghraph === node) {
|
|
2311
|
-
head.value = head.value.slice(1);
|
|
2312
|
-
if (head.value.length === 0) node.children.shift();
|
|
2313
|
-
else if (node.position && head.position && typeof head.position.start.offset === "number") {
|
|
2314
|
-
head.position.start.column++;
|
|
2315
|
-
head.position.start.offset++;
|
|
2316
|
-
node.position.start = Object.assign({}, head.position.start);
|
|
2317
|
-
}
|
|
2318
|
-
}
|
|
2319
|
-
}
|
|
2320
|
-
}
|
|
2321
|
-
this.exit(token);
|
|
2322
|
-
}
|
|
2323
|
-
/**
|
|
2324
|
-
* @type {ToMarkdownHandle}
|
|
2325
|
-
* @param {ListItem} node
|
|
2326
|
-
*/
|
|
2327
|
-
function listItemWithTaskListItem(node, parent, state, info) {
|
|
2328
|
-
const head = node.children[0];
|
|
2329
|
-
const checkable = typeof node.checked === "boolean" && head && head.type === "paragraph";
|
|
2330
|
-
const checkbox = "[" + (node.checked ? "x" : " ") + "] ";
|
|
2331
|
-
const tracker = state.createTracker(info);
|
|
2332
|
-
if (checkable) tracker.move(checkbox);
|
|
2333
|
-
let value = handle.listItem(node, parent, state, {
|
|
2334
|
-
...info,
|
|
2335
|
-
...tracker.current()
|
|
2336
|
-
});
|
|
2337
|
-
if (checkable) value = value.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/, check);
|
|
2338
|
-
return value;
|
|
2339
|
-
/**
|
|
2340
|
-
* @param {string} $0
|
|
2341
|
-
* @returns {string}
|
|
2342
|
-
*/
|
|
2343
|
-
function check($0) {
|
|
2344
|
-
return $0 + checkbox;
|
|
2345
|
-
}
|
|
2346
|
-
}
|
|
2347
|
-
|
|
2348
|
-
//#endregion
|
|
2349
|
-
//#region ../../node_modules/.pnpm/mdast-util-gfm@3.1.0/node_modules/mdast-util-gfm/lib/index.js
|
|
2350
|
-
/**
|
|
2351
|
-
* @import {Extension as FromMarkdownExtension} from 'mdast-util-from-markdown'
|
|
2352
|
-
* @import {Options} from 'mdast-util-gfm'
|
|
2353
|
-
* @import {Options as ToMarkdownExtension} from 'mdast-util-to-markdown'
|
|
2354
|
-
*/
|
|
2355
|
-
/**
|
|
2356
|
-
* Create an extension for `mdast-util-from-markdown` to enable GFM (autolink
|
|
2357
|
-
* literals, footnotes, strikethrough, tables, tasklists).
|
|
2358
|
-
*
|
|
2359
|
-
* @returns {Array<FromMarkdownExtension>}
|
|
2360
|
-
* Extension for `mdast-util-from-markdown` to enable GFM (autolink literals,
|
|
2361
|
-
* footnotes, strikethrough, tables, tasklists).
|
|
2362
|
-
*/
|
|
2363
|
-
function gfmFromMarkdown() {
|
|
2364
|
-
return [
|
|
2365
|
-
gfmAutolinkLiteralFromMarkdown(),
|
|
2366
|
-
gfmFootnoteFromMarkdown(),
|
|
2367
|
-
gfmStrikethroughFromMarkdown(),
|
|
2368
|
-
gfmTableFromMarkdown(),
|
|
2369
|
-
gfmTaskListItemFromMarkdown()
|
|
2370
|
-
];
|
|
2371
|
-
}
|
|
2372
|
-
/**
|
|
2373
|
-
* Create an extension for `mdast-util-to-markdown` to enable GFM (autolink
|
|
2374
|
-
* literals, footnotes, strikethrough, tables, tasklists).
|
|
2375
|
-
*
|
|
2376
|
-
* @param {Options | null | undefined} [options]
|
|
2377
|
-
* Configuration (optional).
|
|
2378
|
-
* @returns {ToMarkdownExtension}
|
|
2379
|
-
* Extension for `mdast-util-to-markdown` to enable GFM (autolink literals,
|
|
2380
|
-
* footnotes, strikethrough, tables, tasklists).
|
|
2381
|
-
*/
|
|
2382
|
-
function gfmToMarkdown(options) {
|
|
2383
|
-
return { extensions: [
|
|
2384
|
-
gfmAutolinkLiteralToMarkdown(),
|
|
2385
|
-
gfmFootnoteToMarkdown(options),
|
|
2386
|
-
gfmStrikethroughToMarkdown(),
|
|
2387
|
-
gfmTableToMarkdown(options),
|
|
2388
|
-
gfmTaskListItemToMarkdown()
|
|
2389
|
-
] };
|
|
2390
|
-
}
|
|
2391
|
-
|
|
2392
|
-
//#endregion
|
|
2393
|
-
export { gfmToMarkdown as n, visit as r, gfmFromMarkdown as t };
|
|
1
|
+
import{t as ccount}from"./ccount.mjs";import{t as ok}from"./devlop.mjs";import{_ as unicodePunctuation,c as toString,l as classifyCharacter,u as normalizeIdentifier,v as unicodeWhitespace}from"./mdast-util-from-markdown.mjs";import{i as convert,n as EXIT,r as visitParents,t as findAndReplace}from"./mdast-util-find-and-replace.mjs";import{t as markdownTable}from"./markdown-table.mjs";import{t as longestStreak}from"./longest-streak.mjs";const inConstruct=`phrasing`,notInConstruct=[`autolink`,`link`,`image`,`label`];function gfmAutolinkLiteralFromMarkdown(){return{transforms:[transformGfmAutolinkLiterals],enter:{literalAutolink:enterLiteralAutolink,literalAutolinkEmail:enterLiteralAutolinkValue,literalAutolinkHttp:enterLiteralAutolinkValue,literalAutolinkWww:enterLiteralAutolinkValue},exit:{literalAutolink:exitLiteralAutolink,literalAutolinkEmail:exitLiteralAutolinkEmail,literalAutolinkHttp:exitLiteralAutolinkHttp,literalAutolinkWww:exitLiteralAutolinkWww}}}function gfmAutolinkLiteralToMarkdown(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct,notInConstruct},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct,notInConstruct},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct,notInConstruct}]}}function enterLiteralAutolink(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function enterLiteralAutolinkValue(e){this.config.enter.autolinkProtocol.call(this,e)}function exitLiteralAutolinkHttp(e){this.config.exit.autolinkProtocol.call(this,e)}function exitLiteralAutolinkWww(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function exitLiteralAutolinkEmail(e){this.config.exit.autolinkEmail.call(this,e)}function exitLiteralAutolink(e){this.exit(e)}function transformGfmAutolinkLiterals(e){findAndReplace(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,findUrl],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,findEmail]],{ignore:[`link`,`linkReference`]})}function findUrl(e,t,n,r,i){let a=``;if(!previous(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!isCorrectDomain(n)))return!1;let o=splitUrl(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function findEmail(e,t,n,r){return!previous(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function isCorrectDomain(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function splitUrl(t){let n=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!n)return[t,void 0];t=t.slice(0,n.index);let r=n[0],i=r.indexOf(`)`),a=ccount(t,`(`),o=ccount(t,`)`);for(;i!==-1&&a>o;)t+=r.slice(0,i+1),r=r.slice(i+1),i=r.indexOf(`)`),o++;return[t,r]}function previous(e,t){let r=e.input.charCodeAt(e.index-1);return(e.index===0||unicodeWhitespace(r)||unicodePunctuation(r))&&(!t||r!==47)}footnoteReference.peek=footnoteReferencePeek;function enterFootnoteCallString(){this.buffer()}function enterFootnoteCall(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function enterFootnoteDefinitionLabelString(){this.buffer()}function enterFootnoteDefinition(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function exitFootnoteCallString(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=normalizeIdentifier(this.sliceSerialize(e)).toLowerCase(),n.label=t}function exitFootnoteCall(e){this.exit(e)}function exitFootnoteDefinitionLabelString(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=normalizeIdentifier(this.sliceSerialize(e)).toLowerCase(),n.label=t}function exitFootnoteDefinition(e){this.exit(e)}function footnoteReferencePeek(){return`[`}function footnoteReference(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function gfmFootnoteFromMarkdown(){return{enter:{gfmFootnoteCallString:enterFootnoteCallString,gfmFootnoteCall:enterFootnoteCall,gfmFootnoteDefinitionLabelString:enterFootnoteDefinitionLabelString,gfmFootnoteDefinition:enterFootnoteDefinition},exit:{gfmFootnoteCallString:exitFootnoteCallString,gfmFootnoteCall:exitFootnoteCall,gfmFootnoteDefinitionLabelString:exitFootnoteDefinitionLabelString,gfmFootnoteDefinition:exitFootnoteDefinition}}}function gfmFootnoteToMarkdown(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
2
|
+
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?mapAll:mapExceptFirst))),s(),o}}function mapExceptFirst(e,t,n){return t===0?e:mapAll(e,t,n)}function mapAll(e,t,n){return(n?``:` `)+e}const constructsWithoutStrikethrough=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];handleDelete.peek=peekDelete;function gfmStrikethroughFromMarkdown(){return{canContainEols:[`delete`],enter:{strikethrough:enterStrikethrough},exit:{strikethrough:exitStrikethrough}}}function gfmStrikethroughToMarkdown(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:constructsWithoutStrikethrough}],handlers:{delete:handleDelete}}}function enterStrikethrough(e){this.enter({type:`delete`,children:[]},e)}function exitStrikethrough(e){this.exit(e)}function handleDelete(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function peekDelete(){return`~`}function blockquote(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),map$1);return i(),o}function map$1(e,t,n){return`>`+(n?``:` `)+e}function patternInScope(e,t){return listInScope(e,t.inConstruct,!0)&&!listInScope(e,t.notInConstruct,!1)}function listInScope(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function hardBreak(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
3
|
+
`&&patternInScope(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
|
|
4
|
+
`}function formatCodeAsIndented(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function checkFence(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function code(e,t,n,r){let i=checkFence(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(formatCodeAsIndented(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,map);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(longestStreak(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
|
|
5
|
+
`,encode:["`"],...s.current()})),t()}return u+=s.move(`
|
|
6
|
+
`),a&&(u+=s.move(a+`
|
|
7
|
+
`)),u+=s.move(c),l(),u}function map(e,t,n){return(n?``:` `)+e}function checkQuote(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function definition(e,t,n,r){let i=checkQuote(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
|
|
8
|
+
`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function checkEmphasis(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function encodeCharacterReference(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function encodeInfo(e,t,n){let r=classifyCharacter(e),a=classifyCharacter(t);return r===void 0?a===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}emphasis.peek=emphasisPeek;function emphasis(e,t,n,r){let i=checkEmphasis(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=encodeInfo(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=encodeCharacterReference(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=encodeInfo(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+encodeCharacterReference(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function emphasisPeek(e,t,n){return n.options.emphasis||`*`}function visit(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),visitParents(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}function formatHeadingAsSetext(e,t){let n=!1;return visit(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,EXIT}),!!((!e.depth||e.depth<3)&&toString(e)&&(t.options.setext||n))}function heading(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(formatHeadingAsSetext(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
|
|
9
|
+
`,after:`
|
|
10
|
+
`});return r(),t(),o+`
|
|
11
|
+
`+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
|
|
12
|
+
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
13
|
+
`,...a.current()});return/^[\t ]/.test(l)&&(l=encodeCharacterReference(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}html.peek=htmlPeek;function html(e){return e.value||``}function htmlPeek(){return`<`}image.peek=imagePeek;function image(e,t,n,r){let i=checkQuote(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function imagePeek(){return`!`}imageReference.peek=imageReferencePeek;function imageReference(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function imageReferencePeek(){return`!`}inlineCode.peek=inlineCodePeek;function inlineCode(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function inlineCodePeek(){return"`"}function formatLinkAsAutolink(e,t){let n=toString(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}link.peek=linkPeek;function link(e,t,n,r){let i=checkQuote(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(formatLinkAsAutolink(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function linkPeek(e,t,n){return formatLinkAsAutolink(e,n)?`<`:`[`}linkReference.peek=linkReferencePeek;function linkReference(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function linkReferencePeek(){return`[`}function checkBullet(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function checkBulletOther(e){let t=checkBullet(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function checkBulletOrdered(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function checkRule(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function list(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?checkBulletOrdered(n):checkBullet(n),s=e.ordered?o===`.`?`)`:`.`:checkBulletOther(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),checkRule(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function checkListItemIndent(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function listItem(e,t,n,r){let i=checkListItemIndent(n),a=n.bulletCurrent||checkBullet(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function paragraph(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}const phrasing=convert([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function root(e,t,n,r){return(e.children.some(function(e){return phrasing(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function checkStrong(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}strong.peek=strongPeek;function strong(e,t,n,r){let i=checkStrong(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=encodeInfo(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=encodeCharacterReference(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=encodeInfo(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+encodeCharacterReference(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function strongPeek(e,t,n){return n.options.strong||`*`}function text(e,t,n,r){return n.safe(e.value,r)}function checkRuleRepetition(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function thematicBreak(e,t,n){let r=(checkRule(n)+(n.options.ruleSpaces?` `:``)).repeat(checkRuleRepetition(n));return n.options.ruleSpaces?r.slice(0,-1):r}const handle={blockquote,break:hardBreak,code,definition,emphasis,hardBreak,heading,html,image,imageReference,inlineCode,link,linkReference,list,listItem,paragraph,root,strong,text,thematicBreak};function gfmTableFromMarkdown(){return{enter:{table:enterTable,tableData:enterCell,tableHeader:enterCell,tableRow:enterRow},exit:{codeText:exitCodeText,table:exitTable,tableData:exit,tableHeader:exit,tableRow:exit}}}function enterTable(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function exitTable(e){this.exit(e),this.data.inTable=void 0}function enterRow(e){this.enter({type:`tableRow`,children:[]},e)}function exit(e){this.exit(e)}function enterCell(e){this.enter({type:`tableCell`,children:[]},e)}function exitCodeText(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,replace));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function replace(e,t){return t===`|`?t:e}function gfmTableToMarkdown(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
14
|
+
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:p,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([f(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
15
|
+
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return markdownTable(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=f(r[i],t,n);return o(),a}function f(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function p(e,t,n){let r=handle.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function gfmTaskListItemFromMarkdown(){return{exit:{taskListCheckValueChecked:exitCheck,taskListCheckValueUnchecked:exitCheck,paragraph:exitParagraphWithTaskListItem}}}function gfmTaskListItemToMarkdown(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:listItemWithTaskListItem}}}function exitCheck(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function exitParagraphWithTaskListItem(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function listItemWithTaskListItem(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=handle.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function gfmFromMarkdown(){return[gfmAutolinkLiteralFromMarkdown(),gfmFootnoteFromMarkdown(),gfmStrikethroughFromMarkdown(),gfmTableFromMarkdown(),gfmTaskListItemFromMarkdown()]}function gfmToMarkdown(e){return{extensions:[gfmAutolinkLiteralToMarkdown(),gfmFootnoteToMarkdown(e),gfmStrikethroughToMarkdown(),gfmTableToMarkdown(e),gfmTaskListItemToMarkdown()]}}export{gfmToMarkdown as n,visit as r,gfmFromMarkdown as t};
|