@wirecat/yandex-disk-cli 0.0.0-stage → 0.1.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/CHANGELOG.md +25 -0
- package/LICENSE +204 -0
- package/README.md +243 -2
- package/contracts/wirecat.json +1554 -0
- package/dist/bin/ydisk.d.ts +3 -0
- package/dist/bin/ydisk.d.ts.map +1 -0
- package/dist/bin/ydisk.js +40 -0
- package/dist/bin/ydisk.js.map +1 -0
- package/dist/bundle/all-profiles-4OLZF3RT.js +279 -0
- package/dist/bundle/anthropic-DKB4OJXZ.js +91 -0
- package/dist/bundle/app-server-G4545SSV.js +247 -0
- package/dist/bundle/bun-RXEQKFED.js +169 -0
- package/dist/bundle/bun-sqlite-VHT5LN7U.js +76 -0
- package/dist/bundle/chunk-2BITUXGC.js +12289 -0
- package/dist/bundle/chunk-2CLWDQKA.js +39330 -0
- package/dist/bundle/chunk-2JFDOPKA.js +9575 -0
- package/dist/bundle/chunk-3GVI2MAO.js +106 -0
- package/dist/bundle/chunk-3SZBWBMI.js +131 -0
- package/dist/bundle/chunk-44VSEXW6.js +4054 -0
- package/dist/bundle/chunk-4YPRRQBE.js +95 -0
- package/dist/bundle/chunk-5COYRL5B.js +379 -0
- package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
- package/dist/bundle/chunk-5DM7DIZL.js +1402 -0
- package/dist/bundle/chunk-6R2DVTVZ.js +24 -0
- package/dist/bundle/chunk-762BS35H.js +2787 -0
- package/dist/bundle/chunk-AG64V7AB.js +1233 -0
- package/dist/bundle/chunk-BC5HGIXB.js +334 -0
- package/dist/bundle/chunk-BH7LFEX7.js +36 -0
- package/dist/bundle/chunk-BLNPGY7N.js +53 -0
- package/dist/bundle/chunk-CNIA2LJF.js +372 -0
- package/dist/bundle/chunk-COSXMDC7.js +230 -0
- package/dist/bundle/chunk-D72URWJE.js +532 -0
- package/dist/bundle/chunk-D7FO33KU.js +785 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DJH26PQ3.js +1396 -0
- package/dist/bundle/chunk-DJPT7IUC.js +64567 -0
- package/dist/bundle/chunk-DTMSCZDW.js +209 -0
- package/dist/bundle/chunk-E6LGZ5LX.js +16 -0
- package/dist/bundle/chunk-E6YRIHS5.js +92 -0
- package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
- package/dist/bundle/chunk-F3DDSZTF.js +78 -0
- package/dist/bundle/chunk-F4WWTQNL.js +188 -0
- package/dist/bundle/chunk-FDDAUASC.js +1028 -0
- package/dist/bundle/chunk-FMNPG6N2.js +170 -0
- package/dist/bundle/chunk-FOKJ4POB.js +274 -0
- package/dist/bundle/chunk-G22C7JG6.js +731 -0
- package/dist/bundle/chunk-GA442SYZ.js +161 -0
- package/dist/bundle/chunk-GEBSW7UK.js +6848 -0
- package/dist/bundle/chunk-GGRKWAOK.js +594 -0
- package/dist/bundle/chunk-HHINRNZA.js +788 -0
- package/dist/bundle/chunk-HUZCL33L.js +128 -0
- package/dist/bundle/chunk-IALSIQVT.js +142 -0
- package/dist/bundle/chunk-IOXR2QBX.js +398 -0
- package/dist/bundle/chunk-J5CXR6VX.js +63 -0
- package/dist/bundle/chunk-J5PWSTOX.js +82 -0
- package/dist/bundle/chunk-J7BVAEHR.js +364 -0
- package/dist/bundle/chunk-JH46HMZW.js +1334 -0
- package/dist/bundle/chunk-JOBO7F6W.js +52 -0
- package/dist/bundle/chunk-JXZ5B3L5.js +2333 -0
- package/dist/bundle/chunk-KBIAMDZN.js +66 -0
- package/dist/bundle/chunk-KFVDL2QS.js +146 -0
- package/dist/bundle/chunk-LNHTLSR5.js +288 -0
- package/dist/bundle/chunk-M24RAKMJ.js +58 -0
- package/dist/bundle/chunk-MDQ57Q3H.js +1197 -0
- package/dist/bundle/chunk-MGUEZYFA.js +5546 -0
- package/dist/bundle/chunk-MLXQ4X5L.js +206 -0
- package/dist/bundle/chunk-NQAKARHE.js +54 -0
- package/dist/bundle/chunk-OF7VVUDQ.js +23 -0
- package/dist/bundle/chunk-OQVPE3XK.js +324 -0
- package/dist/bundle/chunk-OR3QG7UR.js +259 -0
- package/dist/bundle/chunk-OUUYVROP.js +76 -0
- package/dist/bundle/chunk-PQBAM64O.js +168 -0
- package/dist/bundle/chunk-PYVIA7WF.js +88 -0
- package/dist/bundle/chunk-Q6HK3PHE.js +72 -0
- package/dist/bundle/chunk-QB3KECV2.js +218 -0
- package/dist/bundle/chunk-QGWXSFYN.js +73 -0
- package/dist/bundle/chunk-RC5QAAAE.js +29 -0
- package/dist/bundle/chunk-RMJ26HLB.js +18 -0
- package/dist/bundle/chunk-S4UUN6LD.js +1410 -0
- package/dist/bundle/chunk-T7ZUDA4C.js +72 -0
- package/dist/bundle/chunk-TRCSMVV5.js +72 -0
- package/dist/bundle/chunk-UD2BQEKA.js +46 -0
- package/dist/bundle/chunk-V4TL55GS.js +1068 -0
- package/dist/bundle/chunk-VJNWN5VU.js +4072 -0
- package/dist/bundle/chunk-VRRNBLMA.js +1227 -0
- package/dist/bundle/chunk-WUCMMNFJ.js +771 -0
- package/dist/bundle/chunk-XDESE3NY.js +44 -0
- package/dist/bundle/chunk-XFLCVHSQ.js +50 -0
- package/dist/bundle/chunk-XQUUANA2.js +24600 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-Z2QEON7B.js +2275 -0
- package/dist/bundle/chunk-ZMJ56GME.js +7 -0
- package/dist/bundle/chunk-ZTSB3D7Q.js +100 -0
- package/dist/bundle/chunk-ZVJWD3FK.js +38 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-YIOYGPJA.js +40 -0
- package/dist/bundle/command-server-entry-MHBQDXS4.js +169 -0
- package/dist/bundle/decode-NUGJIOUW.js +297 -0
- package/dist/bundle/definitions-AILHKEQT.js +2005 -0
- package/dist/bundle/dispatch-5LC4UEGY.js +411 -0
- package/dist/bundle/dist-4I2W6X2I.js +7577 -0
- package/dist/bundle/echarts-MHSH6PGC.js +42501 -0
- package/dist/bundle/embed-ZDXTHHYS.js +38 -0
- package/dist/bundle/embedder-XFEELFUL.js +111 -0
- package/dist/bundle/failure-5S7VPBYK.js +25 -0
- package/dist/bundle/first-run-JHCHT3RJ.js +29 -0
- package/dist/bundle/first-screen-FHGQ6QRV.js +40 -0
- package/dist/bundle/instructions-WKSMBUFX.js +11 -0
- package/dist/bundle/mcp-HS2ZDUVR.js +167 -0
- package/dist/bundle/mdast-util-from-markdown-R66F4HZA.js +1958 -0
- package/dist/bundle/mdast-util-gfm-LN2ELINH.js +2699 -0
- package/dist/bundle/meeting-combined-K4U4NYRZ.js +25 -0
- package/dist/bundle/meeting-model-KCEG6Y5O.js +26 -0
- package/dist/bundle/meeting-semantic-VYGSV3H6.js +22 -0
- package/dist/bundle/micromark-extension-gfm-5X7YT43T.js +1838 -0
- package/dist/bundle/node-CM6NC6UE.js +176 -0
- package/dist/bundle/node-KM3CUABH.js +2340 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-5YDQ3LIJ.js +74 -0
- package/dist/bundle/notes-search-PGO7KM2U.js +62 -0
- package/dist/bundle/oauth-NY4C5UCK.js +20 -0
- package/dist/bundle/open-YNUTA6ZE.js +23 -0
- package/dist/bundle/openai-4CVT5PHH.js +241 -0
- package/dist/bundle/process-2XT3TL27.js +91 -0
- package/dist/bundle/program-FMIVF5T6.js +31904 -0
- package/dist/bundle/prompt-VNWY3H6S.js +17 -0
- package/dist/bundle/recognize-JS4PBPSZ.js +26 -0
- package/dist/bundle/remote-RCLFH4V2.js +32 -0
- package/dist/bundle/rerank-EG6VKYGO.js +52 -0
- package/dist/bundle/schemas-ED2LHKXK.js +645 -0
- package/dist/bundle/serve-AHG25QXB.js +199 -0
- package/dist/bundle/server-5FTB7WM3.js +78 -0
- package/dist/bundle/server-JNZVSAZE.js +209 -0
- package/dist/bundle/sqlite-runtime-XSZOAQPF.js +20 -0
- package/dist/bundle/state-XGVAJFF7.js +36 -0
- package/dist/bundle/store-OHSCWZEV.js +177 -0
- package/dist/bundle/store-PKSPKJXL.js +293 -0
- package/dist/bundle/store-maintenance-command-KAWGBSWK.js +69 -0
- package/dist/bundle/ydisk.js +183 -0
- package/dist/commands/api.d.ts +9 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +59 -0
- package/dist/commands/api.js.map +1 -0
- package/dist/commands/comments.d.ts +3 -0
- package/dist/commands/comments.d.ts.map +1 -0
- package/dist/commands/comments.js +114 -0
- package/dist/commands/comments.js.map +1 -0
- package/dist/commands/files.d.ts +3 -0
- package/dist/commands/files.d.ts.map +1 -0
- package/dist/commands/files.js +272 -0
- package/dist/commands/files.js.map +1 -0
- package/dist/commands/library.d.ts +13 -0
- package/dist/commands/library.d.ts.map +1 -0
- package/dist/commands/library.js +118 -0
- package/dist/commands/library.js.map +1 -0
- package/dist/commands/session.d.ts +3 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +99 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/config.d.ts +18 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +62 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +80 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +77 -0
- package/dist/context.js.map +1 -0
- package/dist/generated/definitions.d.ts +3 -0
- package/dist/generated/definitions.d.ts.map +1 -0
- package/dist/generated/definitions.js +2001 -0
- package/dist/generated/definitions.js.map +1 -0
- package/dist/generated/manifest.d.ts +6 -0
- package/dist/generated/manifest.d.ts.map +1 -0
- package/dist/generated/manifest.js +1473 -0
- package/dist/generated/manifest.js.map +1 -0
- package/dist/generated/schemas.d.ts +127 -0
- package/dist/generated/schemas.d.ts.map +1 -0
- package/dist/generated/schemas.js +545 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/generated/types.d.ts +829 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +5 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/identity.d.ts +10 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +33 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/program.d.ts +6 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +65 -0
- package/dist/program.js.map +1 -0
- package/dist/sample/comments.d.ts +61 -0
- package/dist/sample/comments.d.ts.map +1 -0
- package/dist/sample/comments.js +39 -0
- package/dist/sample/comments.js.map +1 -0
- package/dist/sample/records.d.ts +16 -0
- package/dist/sample/records.d.ts.map +1 -0
- package/dist/sample/records.js +22 -0
- package/dist/sample/records.js.map +1 -0
- package/dist/sample/transport.d.ts +42 -0
- package/dist/sample/transport.d.ts.map +1 -0
- package/dist/sample/transport.js +153 -0
- package/dist/sample/transport.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/wcat.d.ts +3 -0
- package/dist/wcat.d.ts.map +1 -0
- package/dist/wcat.js +4 -0
- package/dist/wcat.js.map +1 -0
- package/dist/yandex/source.d.ts +39 -0
- package/dist/yandex/source.d.ts.map +1 -0
- package/dist/yandex/source.js +189 -0
- package/dist/yandex/source.js.map +1 -0
- package/dist/yandex/transport.d.ts +41 -0
- package/dist/yandex/transport.d.ts.map +1 -0
- package/dist/yandex/transport.js +152 -0
- package/dist/yandex/transport.js.map +1 -0
- package/dist/yandex/writes.d.ts +27 -0
- package/dist/yandex/writes.d.ts.map +1 -0
- package/dist/yandex/writes.js +61 -0
- package/dist/yandex/writes.js.map +1 -0
- package/package.json +88 -4
- package/skills/yandex-disk-cli/SKILL.md +46 -0
- package/skills/yandex-disk-cli/references/api/api-disk-operations-operation-id.md +13 -0
- package/skills/yandex-disk-cli/references/api/api-disk-public-resources.md +50 -0
- package/skills/yandex-disk-cli/references/api/api-disk-resources.md +171 -0
- package/skills/yandex-disk-cli/references/api/api-disk-trash-resources.md +48 -0
- package/skills/yandex-disk-cli/references/api/api-disk.md +13 -0
- package/skills/yandex-disk-cli/references/api.md +17 -0
|
@@ -0,0 +1,2699 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
toString
|
|
5
|
+
} from "./chunk-XFLCVHSQ.js";
|
|
6
|
+
import {
|
|
7
|
+
asciiAlpha,
|
|
8
|
+
asciiAlphanumeric,
|
|
9
|
+
asciiPunctuation,
|
|
10
|
+
classifyCharacter,
|
|
11
|
+
htmlBlockNames,
|
|
12
|
+
htmlRawNames,
|
|
13
|
+
normalizeIdentifier,
|
|
14
|
+
unicodePunctuation,
|
|
15
|
+
unicodeWhitespace
|
|
16
|
+
} from "./chunk-KFVDL2QS.js";
|
|
17
|
+
import {
|
|
18
|
+
__name
|
|
19
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
20
|
+
|
|
21
|
+
// node_modules/.pnpm/ccount@2.0.1/node_modules/ccount/index.js
|
|
22
|
+
function ccount(value, character) {
|
|
23
|
+
const source = String(value);
|
|
24
|
+
if (typeof character !== "string") {
|
|
25
|
+
throw new TypeError("Expected character");
|
|
26
|
+
}
|
|
27
|
+
let count = 0;
|
|
28
|
+
let index = source.indexOf(character);
|
|
29
|
+
while (index !== -1) {
|
|
30
|
+
count++;
|
|
31
|
+
index = source.indexOf(character, index + character.length);
|
|
32
|
+
}
|
|
33
|
+
return count;
|
|
34
|
+
}
|
|
35
|
+
__name(ccount, "ccount");
|
|
36
|
+
|
|
37
|
+
// node_modules/.pnpm/devlop@1.1.0/node_modules/devlop/lib/default.js
|
|
38
|
+
function ok() {
|
|
39
|
+
}
|
|
40
|
+
__name(ok, "ok");
|
|
41
|
+
|
|
42
|
+
// node_modules/.pnpm/escape-string-regexp@5.0.0/node_modules/escape-string-regexp/index.js
|
|
43
|
+
function escapeStringRegexp(string) {
|
|
44
|
+
if (typeof string !== "string") {
|
|
45
|
+
throw new TypeError("Expected a string");
|
|
46
|
+
}
|
|
47
|
+
return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
|
48
|
+
}
|
|
49
|
+
__name(escapeStringRegexp, "escapeStringRegexp");
|
|
50
|
+
|
|
51
|
+
// node_modules/.pnpm/unist-util-is@6.0.1/node_modules/unist-util-is/lib/index.js
|
|
52
|
+
var convert = (
|
|
53
|
+
// Note: overloads in JSDoc can’t yet use different `@template`s.
|
|
54
|
+
/**
|
|
55
|
+
* @type {(
|
|
56
|
+
* (<Condition extends string>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &
|
|
57
|
+
* (<Condition extends Props>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &
|
|
58
|
+
* (<Condition extends TestFunction>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &
|
|
59
|
+
* ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &
|
|
60
|
+
* ((test?: Test) => Check)
|
|
61
|
+
* )}
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* @param {Test} [test]
|
|
65
|
+
* @returns {Check}
|
|
66
|
+
*/
|
|
67
|
+
/* @__PURE__ */ __name((function(test) {
|
|
68
|
+
if (test === null || test === void 0) {
|
|
69
|
+
return ok2;
|
|
70
|
+
}
|
|
71
|
+
if (typeof test === "function") {
|
|
72
|
+
return castFactory(test);
|
|
73
|
+
}
|
|
74
|
+
if (typeof test === "object") {
|
|
75
|
+
return Array.isArray(test) ? anyFactory(test) : (
|
|
76
|
+
// Cast because `ReadonlyArray` goes into the above but `isArray`
|
|
77
|
+
// narrows to `Array`.
|
|
78
|
+
propertiesFactory(
|
|
79
|
+
/** @type {Props} */
|
|
80
|
+
test
|
|
81
|
+
)
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
if (typeof test === "string") {
|
|
85
|
+
return typeFactory(test);
|
|
86
|
+
}
|
|
87
|
+
throw new Error("Expected function, string, or object as test");
|
|
88
|
+
}), "convert")
|
|
89
|
+
);
|
|
90
|
+
function anyFactory(tests) {
|
|
91
|
+
const checks = [];
|
|
92
|
+
let index = -1;
|
|
93
|
+
while (++index < tests.length) {
|
|
94
|
+
checks[index] = convert(tests[index]);
|
|
95
|
+
}
|
|
96
|
+
return castFactory(any);
|
|
97
|
+
function any(...parameters) {
|
|
98
|
+
let index2 = -1;
|
|
99
|
+
while (++index2 < checks.length) {
|
|
100
|
+
if (checks[index2].apply(this, parameters)) return true;
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
__name(any, "any");
|
|
105
|
+
}
|
|
106
|
+
__name(anyFactory, "anyFactory");
|
|
107
|
+
function propertiesFactory(check2) {
|
|
108
|
+
const checkAsRecord = (
|
|
109
|
+
/** @type {Record<string, unknown>} */
|
|
110
|
+
check2
|
|
111
|
+
);
|
|
112
|
+
return castFactory(all);
|
|
113
|
+
function all(node) {
|
|
114
|
+
const nodeAsRecord = (
|
|
115
|
+
/** @type {Record<string, unknown>} */
|
|
116
|
+
/** @type {unknown} */
|
|
117
|
+
node
|
|
118
|
+
);
|
|
119
|
+
let key;
|
|
120
|
+
for (key in check2) {
|
|
121
|
+
if (nodeAsRecord[key] !== checkAsRecord[key]) return false;
|
|
122
|
+
}
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
__name(all, "all");
|
|
126
|
+
}
|
|
127
|
+
__name(propertiesFactory, "propertiesFactory");
|
|
128
|
+
function typeFactory(check2) {
|
|
129
|
+
return castFactory(type);
|
|
130
|
+
function type(node) {
|
|
131
|
+
return node && node.type === check2;
|
|
132
|
+
}
|
|
133
|
+
__name(type, "type");
|
|
134
|
+
}
|
|
135
|
+
__name(typeFactory, "typeFactory");
|
|
136
|
+
function castFactory(testFunction) {
|
|
137
|
+
return check2;
|
|
138
|
+
function check2(value, index, parent) {
|
|
139
|
+
return Boolean(
|
|
140
|
+
looksLikeANode(value) && testFunction.call(
|
|
141
|
+
this,
|
|
142
|
+
value,
|
|
143
|
+
typeof index === "number" ? index : void 0,
|
|
144
|
+
parent || void 0
|
|
145
|
+
)
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
__name(check2, "check");
|
|
149
|
+
}
|
|
150
|
+
__name(castFactory, "castFactory");
|
|
151
|
+
function ok2() {
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
__name(ok2, "ok");
|
|
155
|
+
function looksLikeANode(value) {
|
|
156
|
+
return value !== null && typeof value === "object" && "type" in value;
|
|
157
|
+
}
|
|
158
|
+
__name(looksLikeANode, "looksLikeANode");
|
|
159
|
+
|
|
160
|
+
// node_modules/.pnpm/unist-util-visit-parents@6.1.0/node_modules/unist-util-visit-parents/lib/color.node.js
|
|
161
|
+
function color(d) {
|
|
162
|
+
return "\x1B[33m" + d + "\x1B[39m";
|
|
163
|
+
}
|
|
164
|
+
__name(color, "color");
|
|
165
|
+
|
|
166
|
+
// node_modules/.pnpm/unist-util-visit-parents@6.1.0/node_modules/unist-util-visit-parents/lib/index.js
|
|
167
|
+
var empty = [];
|
|
168
|
+
var CONTINUE = true;
|
|
169
|
+
var EXIT = false;
|
|
170
|
+
var SKIP = "skip";
|
|
171
|
+
function visitParents(tree, testOrEnterOrVisitors, enterOrVisitorsOrReverse, reverse) {
|
|
172
|
+
if (!tree || typeof tree !== "object") {
|
|
173
|
+
throw new Error("Unexpected value `" + tree + "` for `tree`, expected node");
|
|
174
|
+
}
|
|
175
|
+
let preorder = true;
|
|
176
|
+
let check2;
|
|
177
|
+
let visitors;
|
|
178
|
+
let enter;
|
|
179
|
+
let exit2;
|
|
180
|
+
if (typeof enterOrVisitorsOrReverse === "function" || enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === "object") {
|
|
181
|
+
check2 = /** @type {Test} */
|
|
182
|
+
testOrEnterOrVisitors;
|
|
183
|
+
visitors = enterOrVisitorsOrReverse;
|
|
184
|
+
if (reverse) preorder = false;
|
|
185
|
+
} else {
|
|
186
|
+
visitors = /** @type {Visitors | Visitor} */
|
|
187
|
+
testOrEnterOrVisitors;
|
|
188
|
+
if (enterOrVisitorsOrReverse) preorder = false;
|
|
189
|
+
}
|
|
190
|
+
if (typeof visitors === "function") {
|
|
191
|
+
enter = visitors;
|
|
192
|
+
} else if (visitors && typeof visitors === "object") {
|
|
193
|
+
if (visitors.enter === null || visitors.enter === void 0) {
|
|
194
|
+
} else if (typeof visitors.enter === "function") {
|
|
195
|
+
enter = visitors.enter;
|
|
196
|
+
} else {
|
|
197
|
+
throw new Error(
|
|
198
|
+
"Unexpected value `" + visitors.enter + "` for `visitors.enter`, expected optional visitor"
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
if (typeof visitors.exit === "function") {
|
|
202
|
+
exit2 = visitors.exit;
|
|
203
|
+
} else {
|
|
204
|
+
throw new Error(
|
|
205
|
+
"Unexpected value `" + visitors.exit + "` for `visitors.exit`, expected visitor (pass a visitor directly if you only want an enter visitor)"
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
} else {
|
|
209
|
+
throw new Error(
|
|
210
|
+
"Unexpected value `" + visitors + "` for `enter` or `visitors`, expected visitor or object with visitors"
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
const is2 = convert(check2);
|
|
214
|
+
const step = preorder ? 1 : -1;
|
|
215
|
+
factory(tree, void 0, [])();
|
|
216
|
+
function factory(node, index, parents) {
|
|
217
|
+
const value = (
|
|
218
|
+
/** @type {Record<string, unknown>} */
|
|
219
|
+
node && typeof node === "object" ? node : {}
|
|
220
|
+
);
|
|
221
|
+
if (typeof value.type === "string") {
|
|
222
|
+
const name = (
|
|
223
|
+
// `hast`
|
|
224
|
+
typeof value.tagName === "string" ? value.tagName : (
|
|
225
|
+
// `xast`
|
|
226
|
+
typeof value.name === "string" ? value.name : void 0
|
|
227
|
+
)
|
|
228
|
+
);
|
|
229
|
+
Object.defineProperty(visit2, "name", {
|
|
230
|
+
value: "node (" + color(node.type + (name ? "<" + name + ">" : "")) + ")"
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return visit2;
|
|
234
|
+
function visit2() {
|
|
235
|
+
const matches = !check2 || is2(node, index, parents[parents.length - 1] || void 0);
|
|
236
|
+
let result = empty;
|
|
237
|
+
if (enter && matches) {
|
|
238
|
+
result = toResult(enter(node, parents, index));
|
|
239
|
+
if (result[0] === EXIT) {
|
|
240
|
+
return result;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if ("children" in node && node.children) {
|
|
244
|
+
const nodeAsParent = (
|
|
245
|
+
/** @type {UnistParent} */
|
|
246
|
+
node
|
|
247
|
+
);
|
|
248
|
+
if (nodeAsParent.children && result[0] !== SKIP) {
|
|
249
|
+
let offset = (preorder ? -1 : nodeAsParent.children.length) + step;
|
|
250
|
+
const grandparents = [...parents, nodeAsParent];
|
|
251
|
+
while (offset > -1 && offset < nodeAsParent.children.length) {
|
|
252
|
+
const child = nodeAsParent.children[offset];
|
|
253
|
+
const subresult = factory(child, offset, grandparents)();
|
|
254
|
+
if (subresult[0] === EXIT) {
|
|
255
|
+
return subresult;
|
|
256
|
+
}
|
|
257
|
+
offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
if (exit2 && matches) {
|
|
262
|
+
const exitResult = toResult(exit2(node, parents, index));
|
|
263
|
+
if (exitResult[0] === SKIP) {
|
|
264
|
+
throw new Error(
|
|
265
|
+
"Unexpected value `" + exitResult[0] + "` from `exit`, expected `CONTINUE`, `EXIT`, index, or nothing"
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
if (exitResult[0] === EXIT || typeof exitResult[1] === "number") {
|
|
269
|
+
return exitResult;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return result;
|
|
273
|
+
}
|
|
274
|
+
__name(visit2, "visit");
|
|
275
|
+
}
|
|
276
|
+
__name(factory, "factory");
|
|
277
|
+
}
|
|
278
|
+
__name(visitParents, "visitParents");
|
|
279
|
+
function toResult(value) {
|
|
280
|
+
if (Array.isArray(value)) {
|
|
281
|
+
return value;
|
|
282
|
+
}
|
|
283
|
+
if (typeof value === "number") {
|
|
284
|
+
return [CONTINUE, value];
|
|
285
|
+
}
|
|
286
|
+
return value === null || value === void 0 ? empty : [value];
|
|
287
|
+
}
|
|
288
|
+
__name(toResult, "toResult");
|
|
289
|
+
|
|
290
|
+
// node_modules/.pnpm/mdast-util-find-and-replace@3.0.4/node_modules/mdast-util-find-and-replace/lib/index.js
|
|
291
|
+
function findAndReplace(tree, list2, options) {
|
|
292
|
+
const settings = options || {};
|
|
293
|
+
const ignored = convert(settings.ignore || []);
|
|
294
|
+
const pairs = toPairs(list2);
|
|
295
|
+
let pairIndex = -1;
|
|
296
|
+
while (++pairIndex < pairs.length) {
|
|
297
|
+
visitParents(tree, visitor);
|
|
298
|
+
}
|
|
299
|
+
function visitor(node, parents, index) {
|
|
300
|
+
if (node.type === "text" && typeof index === "number") {
|
|
301
|
+
return handler(node, parents, index);
|
|
302
|
+
}
|
|
303
|
+
if (ignored(node, index, parents[parents.length - 1])) return SKIP;
|
|
304
|
+
}
|
|
305
|
+
__name(visitor, "visitor");
|
|
306
|
+
function handler(node, parents, index) {
|
|
307
|
+
const parent = parents[parents.length - 1];
|
|
308
|
+
const find = pairs[pairIndex][0];
|
|
309
|
+
const replace2 = pairs[pairIndex][1];
|
|
310
|
+
let start = 0;
|
|
311
|
+
let change = false;
|
|
312
|
+
let nodes = [];
|
|
313
|
+
find.lastIndex = 0;
|
|
314
|
+
let match = find.exec(node.value);
|
|
315
|
+
while (match) {
|
|
316
|
+
const position = match.index;
|
|
317
|
+
const matchObject = {
|
|
318
|
+
index: match.index,
|
|
319
|
+
input: match.input,
|
|
320
|
+
stack: [...parents, node]
|
|
321
|
+
};
|
|
322
|
+
let value = replace2(...match, matchObject);
|
|
323
|
+
if (typeof value === "string") {
|
|
324
|
+
value = value.length > 0 ? { type: "text", value } : void 0;
|
|
325
|
+
}
|
|
326
|
+
if (value === false) {
|
|
327
|
+
find.lastIndex = position + 1;
|
|
328
|
+
} else {
|
|
329
|
+
if (start !== position) {
|
|
330
|
+
add({ type: "text", value: node.value.slice(start, position) });
|
|
331
|
+
}
|
|
332
|
+
if (Array.isArray(value)) {
|
|
333
|
+
for (const child of value) add(child);
|
|
334
|
+
} else if (value) {
|
|
335
|
+
add(value);
|
|
336
|
+
}
|
|
337
|
+
start = position + match[0].length;
|
|
338
|
+
change = true;
|
|
339
|
+
}
|
|
340
|
+
if (!find.global) {
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
match = find.exec(node.value);
|
|
344
|
+
}
|
|
345
|
+
if (change) {
|
|
346
|
+
if (start < node.value.length) {
|
|
347
|
+
add({ type: "text", value: node.value.slice(start) });
|
|
348
|
+
}
|
|
349
|
+
parent.children.splice(index, 1, ...nodes);
|
|
350
|
+
} else {
|
|
351
|
+
nodes = [node];
|
|
352
|
+
}
|
|
353
|
+
return index + nodes.length;
|
|
354
|
+
function add(child) {
|
|
355
|
+
const previous2 = nodes[nodes.length - 1];
|
|
356
|
+
if (previous2 && previous2.type === "text" && child.type === "text") {
|
|
357
|
+
previous2.value += child.value;
|
|
358
|
+
} else {
|
|
359
|
+
nodes.push(child);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
__name(add, "add");
|
|
363
|
+
}
|
|
364
|
+
__name(handler, "handler");
|
|
365
|
+
}
|
|
366
|
+
__name(findAndReplace, "findAndReplace");
|
|
367
|
+
function toPairs(tupleOrList) {
|
|
368
|
+
if (!Array.isArray(tupleOrList)) {
|
|
369
|
+
throw new TypeError("Expected find and replace tuple or list of tuples");
|
|
370
|
+
}
|
|
371
|
+
const result = [];
|
|
372
|
+
const list2 = !tupleOrList[0] || Array.isArray(tupleOrList[0]) ? (
|
|
373
|
+
/** @type {FindAndReplaceList} */
|
|
374
|
+
tupleOrList
|
|
375
|
+
) : [
|
|
376
|
+
/** @type {FindAndReplaceTuple} */
|
|
377
|
+
tupleOrList
|
|
378
|
+
];
|
|
379
|
+
let index = -1;
|
|
380
|
+
while (++index < list2.length) {
|
|
381
|
+
const tuple = list2[index];
|
|
382
|
+
result.push([toExpression(tuple[0]), toFunction(tuple[1])]);
|
|
383
|
+
}
|
|
384
|
+
return result;
|
|
385
|
+
}
|
|
386
|
+
__name(toPairs, "toPairs");
|
|
387
|
+
function toExpression(find) {
|
|
388
|
+
return typeof find === "string" ? new RegExp(escapeStringRegexp(find), "g") : find;
|
|
389
|
+
}
|
|
390
|
+
__name(toExpression, "toExpression");
|
|
391
|
+
function toFunction(replace2) {
|
|
392
|
+
return typeof replace2 === "function" ? replace2 : function() {
|
|
393
|
+
return replace2;
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
__name(toFunction, "toFunction");
|
|
397
|
+
|
|
398
|
+
// node_modules/.pnpm/mdast-util-gfm-autolink-literal@2.1.0/node_modules/mdast-util-gfm-autolink-literal/lib/index.js
|
|
399
|
+
var inConstruct = "phrasing";
|
|
400
|
+
var notInConstruct = ["autolink", "link", "image", "label"];
|
|
401
|
+
function gfmAutolinkLiteralFromMarkdown() {
|
|
402
|
+
return {
|
|
403
|
+
transforms: [transformGfmAutolinkLiterals],
|
|
404
|
+
enter: {
|
|
405
|
+
literalAutolink: enterLiteralAutolink,
|
|
406
|
+
literalAutolinkEmail: enterLiteralAutolinkValue,
|
|
407
|
+
literalAutolinkHttp: enterLiteralAutolinkValue,
|
|
408
|
+
literalAutolinkWww: enterLiteralAutolinkValue
|
|
409
|
+
},
|
|
410
|
+
exit: {
|
|
411
|
+
literalAutolink: exitLiteralAutolink,
|
|
412
|
+
literalAutolinkEmail: exitLiteralAutolinkEmail,
|
|
413
|
+
literalAutolinkHttp: exitLiteralAutolinkHttp,
|
|
414
|
+
literalAutolinkWww: exitLiteralAutolinkWww
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
__name(gfmAutolinkLiteralFromMarkdown, "gfmAutolinkLiteralFromMarkdown");
|
|
419
|
+
function gfmAutolinkLiteralToMarkdown() {
|
|
420
|
+
return {
|
|
421
|
+
unsafe: [
|
|
422
|
+
{
|
|
423
|
+
character: "@",
|
|
424
|
+
before: "[+\\-.\\w]",
|
|
425
|
+
after: "[\\-.\\w]",
|
|
426
|
+
inConstruct,
|
|
427
|
+
notInConstruct
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
character: ".",
|
|
431
|
+
before: "[Ww]",
|
|
432
|
+
after: "[\\-.\\w]",
|
|
433
|
+
inConstruct,
|
|
434
|
+
notInConstruct
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
character: ":",
|
|
438
|
+
before: "[ps]",
|
|
439
|
+
after: "\\/",
|
|
440
|
+
inConstruct,
|
|
441
|
+
notInConstruct
|
|
442
|
+
}
|
|
443
|
+
]
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
__name(gfmAutolinkLiteralToMarkdown, "gfmAutolinkLiteralToMarkdown");
|
|
447
|
+
function enterLiteralAutolink(token) {
|
|
448
|
+
this.enter(
|
|
449
|
+
{ type: "link", title: null, url: "", children: [], position: void 0 },
|
|
450
|
+
token
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
__name(enterLiteralAutolink, "enterLiteralAutolink");
|
|
454
|
+
function enterLiteralAutolinkValue(token) {
|
|
455
|
+
this.config.enter.autolinkProtocol.call(this, token);
|
|
456
|
+
}
|
|
457
|
+
__name(enterLiteralAutolinkValue, "enterLiteralAutolinkValue");
|
|
458
|
+
function exitLiteralAutolinkHttp(token) {
|
|
459
|
+
this.config.exit.autolinkProtocol.call(this, token);
|
|
460
|
+
}
|
|
461
|
+
__name(exitLiteralAutolinkHttp, "exitLiteralAutolinkHttp");
|
|
462
|
+
function exitLiteralAutolinkWww(token) {
|
|
463
|
+
this.config.exit.data.call(this, token);
|
|
464
|
+
const node = this.stack[this.stack.length - 1];
|
|
465
|
+
ok(node.type === "link");
|
|
466
|
+
node.url = "http://" + this.sliceSerialize(token);
|
|
467
|
+
}
|
|
468
|
+
__name(exitLiteralAutolinkWww, "exitLiteralAutolinkWww");
|
|
469
|
+
function exitLiteralAutolinkEmail(token) {
|
|
470
|
+
this.config.exit.autolinkEmail.call(this, token);
|
|
471
|
+
}
|
|
472
|
+
__name(exitLiteralAutolinkEmail, "exitLiteralAutolinkEmail");
|
|
473
|
+
function exitLiteralAutolink(token) {
|
|
474
|
+
this.exit(token);
|
|
475
|
+
}
|
|
476
|
+
__name(exitLiteralAutolink, "exitLiteralAutolink");
|
|
477
|
+
function transformGfmAutolinkLiterals(tree) {
|
|
478
|
+
findAndReplace(
|
|
479
|
+
tree,
|
|
480
|
+
[
|
|
481
|
+
[
|
|
482
|
+
/(?<![\da-z])(https?:\/\/|www(?=\.))([\w-]*\.[\w\-.]*)([^\t\n\r ]*)/gi,
|
|
483
|
+
findUrl
|
|
484
|
+
],
|
|
485
|
+
[
|
|
486
|
+
/(?<![\w+\-.@])xmpp:([\w+\-.]+)@([\w-]+(?:\.[\w-]+)+)(\/(?:[\w\-/]|\.(?=[\dA-Za-z]))*)?/g,
|
|
487
|
+
findXmpp
|
|
488
|
+
],
|
|
489
|
+
[/(?<![\w+\-.@])mailto:([\w+\-.]+)@([\w-]+(?:\.[\w-]+)+)/g, findMailto],
|
|
490
|
+
[
|
|
491
|
+
/(?<![\w+\-.]|(?:^|[^\d@A-Za-z])(?:mailto|xmpp):)([\w+\-.]+)@([\w-]+(?:\.[\w-]+)+)/g,
|
|
492
|
+
findEmail
|
|
493
|
+
]
|
|
494
|
+
],
|
|
495
|
+
{ ignore: ["link", "linkReference"] }
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
__name(transformGfmAutolinkLiterals, "transformGfmAutolinkLiterals");
|
|
499
|
+
function findUrl(_, protocol, domain, path, match) {
|
|
500
|
+
if (!previous(match)) {
|
|
501
|
+
return false;
|
|
502
|
+
}
|
|
503
|
+
let prefix = "";
|
|
504
|
+
if (/^w/i.test(protocol)) {
|
|
505
|
+
domain = protocol + domain;
|
|
506
|
+
protocol = "";
|
|
507
|
+
prefix = "http://";
|
|
508
|
+
}
|
|
509
|
+
if (unicodePunctuation(domain.charCodeAt(0)) || !isCorrectDomain(domain)) {
|
|
510
|
+
return false;
|
|
511
|
+
}
|
|
512
|
+
const parts = splitUrl(domain + path);
|
|
513
|
+
const result = {
|
|
514
|
+
type: "link",
|
|
515
|
+
title: null,
|
|
516
|
+
url: prefix + protocol + parts[0],
|
|
517
|
+
children: [{ type: "text", value: protocol + parts[0], position: void 0 }],
|
|
518
|
+
position: void 0
|
|
519
|
+
};
|
|
520
|
+
if (parts[1]) {
|
|
521
|
+
return [result, { type: "text", value: parts[1], position: void 0 }];
|
|
522
|
+
}
|
|
523
|
+
return result;
|
|
524
|
+
}
|
|
525
|
+
__name(findUrl, "findUrl");
|
|
526
|
+
function findEmail(_, atext, label) {
|
|
527
|
+
if (/[\d\-_]$/.test(label)) {
|
|
528
|
+
return false;
|
|
529
|
+
}
|
|
530
|
+
return {
|
|
531
|
+
type: "link",
|
|
532
|
+
title: null,
|
|
533
|
+
url: "mailto:" + atext + "@" + label,
|
|
534
|
+
children: [{ type: "text", value: atext + "@" + label, position: void 0 }],
|
|
535
|
+
position: void 0
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
__name(findEmail, "findEmail");
|
|
539
|
+
function findMailto(_, atext, label) {
|
|
540
|
+
if (/[\d\-_]$/.test(label)) {
|
|
541
|
+
return false;
|
|
542
|
+
}
|
|
543
|
+
const value = "mailto:" + atext + "@" + label;
|
|
544
|
+
return {
|
|
545
|
+
type: "link",
|
|
546
|
+
title: null,
|
|
547
|
+
url: value,
|
|
548
|
+
children: [{ type: "text", value, position: void 0 }],
|
|
549
|
+
position: void 0
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
__name(findMailto, "findMailto");
|
|
553
|
+
function findXmpp(matchValue, atext, label, resource, match) {
|
|
554
|
+
if (/[\d\-_]$/.test(label) || resource && (!/[A-Za-z]$/.test(resource) || match.input.charAt(match.index + matchValue.length) === "@")) {
|
|
555
|
+
return false;
|
|
556
|
+
}
|
|
557
|
+
const value = "xmpp:" + atext + "@" + label + (resource || "");
|
|
558
|
+
return {
|
|
559
|
+
type: "link",
|
|
560
|
+
title: null,
|
|
561
|
+
url: value,
|
|
562
|
+
children: [{ type: "text", value, position: void 0 }],
|
|
563
|
+
position: void 0
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
__name(findXmpp, "findXmpp");
|
|
567
|
+
function isCorrectDomain(domain) {
|
|
568
|
+
const parts = domain.split(".");
|
|
569
|
+
if (parts.length < 2 || parts[parts.length - 1] && (/_/.test(parts[parts.length - 1]) || !/[\dA-Za-z]/.test(parts[parts.length - 1])) || parts[parts.length - 2] && (/_/.test(parts[parts.length - 2]) || !/[\dA-Za-z]/.test(parts[parts.length - 2]))) {
|
|
570
|
+
return false;
|
|
571
|
+
}
|
|
572
|
+
return true;
|
|
573
|
+
}
|
|
574
|
+
__name(isCorrectDomain, "isCorrectDomain");
|
|
575
|
+
function splitUrl(url) {
|
|
576
|
+
let index = url.length;
|
|
577
|
+
while (index > 0) {
|
|
578
|
+
const code2 = url.charCodeAt(index - 1);
|
|
579
|
+
if (code2 === 33 || code2 === 34 || code2 === 38 || code2 === 39 || code2 === 41 || code2 === 44 || code2 === 46 || code2 === 58 || code2 === 59 || code2 === 60 || code2 === 62 || code2 === 63 || code2 === 93 || code2 === 125) {
|
|
580
|
+
index--;
|
|
581
|
+
} else {
|
|
582
|
+
break;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
if (index === url.length) {
|
|
586
|
+
return [url, void 0];
|
|
587
|
+
}
|
|
588
|
+
let trail = url.slice(index);
|
|
589
|
+
url = url.slice(0, index);
|
|
590
|
+
let closingParenIndex = trail.indexOf(")");
|
|
591
|
+
const openingParens = ccount(url, "(");
|
|
592
|
+
let closingParens = ccount(url, ")");
|
|
593
|
+
while (closingParenIndex !== -1 && openingParens > closingParens) {
|
|
594
|
+
url += trail.slice(0, closingParenIndex + 1);
|
|
595
|
+
trail = trail.slice(closingParenIndex + 1);
|
|
596
|
+
closingParenIndex = trail.indexOf(")");
|
|
597
|
+
closingParens++;
|
|
598
|
+
}
|
|
599
|
+
return [url, trail];
|
|
600
|
+
}
|
|
601
|
+
__name(splitUrl, "splitUrl");
|
|
602
|
+
function previous(match) {
|
|
603
|
+
const code2 = match.input.charCodeAt(match.index - 1);
|
|
604
|
+
return match.index === 0 || unicodeWhitespace(code2) || unicodePunctuation(code2);
|
|
605
|
+
}
|
|
606
|
+
__name(previous, "previous");
|
|
607
|
+
|
|
608
|
+
// node_modules/.pnpm/mdast-util-gfm-footnote@2.1.0/node_modules/mdast-util-gfm-footnote/lib/index.js
|
|
609
|
+
footnoteReference.peek = footnoteReferencePeek;
|
|
610
|
+
function enterFootnoteCallString() {
|
|
611
|
+
this.buffer();
|
|
612
|
+
}
|
|
613
|
+
__name(enterFootnoteCallString, "enterFootnoteCallString");
|
|
614
|
+
function enterFootnoteCall(token) {
|
|
615
|
+
this.enter({ type: "footnoteReference", identifier: "", label: "" }, token);
|
|
616
|
+
}
|
|
617
|
+
__name(enterFootnoteCall, "enterFootnoteCall");
|
|
618
|
+
function enterFootnoteDefinitionLabelString() {
|
|
619
|
+
this.buffer();
|
|
620
|
+
}
|
|
621
|
+
__name(enterFootnoteDefinitionLabelString, "enterFootnoteDefinitionLabelString");
|
|
622
|
+
function enterFootnoteDefinition(token) {
|
|
623
|
+
this.enter(
|
|
624
|
+
{ type: "footnoteDefinition", identifier: "", label: "", children: [] },
|
|
625
|
+
token
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
__name(enterFootnoteDefinition, "enterFootnoteDefinition");
|
|
629
|
+
function exitFootnoteCallString(token) {
|
|
630
|
+
const label = this.resume();
|
|
631
|
+
const node = this.stack[this.stack.length - 1];
|
|
632
|
+
ok(node.type === "footnoteReference");
|
|
633
|
+
node.identifier = normalizeIdentifier(
|
|
634
|
+
this.sliceSerialize(token)
|
|
635
|
+
).toLowerCase();
|
|
636
|
+
node.label = label;
|
|
637
|
+
}
|
|
638
|
+
__name(exitFootnoteCallString, "exitFootnoteCallString");
|
|
639
|
+
function exitFootnoteCall(token) {
|
|
640
|
+
this.exit(token);
|
|
641
|
+
}
|
|
642
|
+
__name(exitFootnoteCall, "exitFootnoteCall");
|
|
643
|
+
function exitFootnoteDefinitionLabelString(token) {
|
|
644
|
+
const label = this.resume();
|
|
645
|
+
const node = this.stack[this.stack.length - 1];
|
|
646
|
+
ok(node.type === "footnoteDefinition");
|
|
647
|
+
node.identifier = normalizeIdentifier(
|
|
648
|
+
this.sliceSerialize(token)
|
|
649
|
+
).toLowerCase();
|
|
650
|
+
node.label = label;
|
|
651
|
+
}
|
|
652
|
+
__name(exitFootnoteDefinitionLabelString, "exitFootnoteDefinitionLabelString");
|
|
653
|
+
function exitFootnoteDefinition(token) {
|
|
654
|
+
this.exit(token);
|
|
655
|
+
}
|
|
656
|
+
__name(exitFootnoteDefinition, "exitFootnoteDefinition");
|
|
657
|
+
function footnoteReferencePeek() {
|
|
658
|
+
return "[";
|
|
659
|
+
}
|
|
660
|
+
__name(footnoteReferencePeek, "footnoteReferencePeek");
|
|
661
|
+
function footnoteReference(node, _, state, info) {
|
|
662
|
+
const tracker = state.createTracker(info);
|
|
663
|
+
let value = tracker.move("[^");
|
|
664
|
+
const exit2 = state.enter("footnoteReference");
|
|
665
|
+
const subexit = state.enter("reference");
|
|
666
|
+
value += tracker.move(
|
|
667
|
+
state.safe(state.associationId(node), { after: "]", before: value })
|
|
668
|
+
);
|
|
669
|
+
subexit();
|
|
670
|
+
exit2();
|
|
671
|
+
value += tracker.move("]");
|
|
672
|
+
return value;
|
|
673
|
+
}
|
|
674
|
+
__name(footnoteReference, "footnoteReference");
|
|
675
|
+
function gfmFootnoteFromMarkdown() {
|
|
676
|
+
return {
|
|
677
|
+
enter: {
|
|
678
|
+
gfmFootnoteCallString: enterFootnoteCallString,
|
|
679
|
+
gfmFootnoteCall: enterFootnoteCall,
|
|
680
|
+
gfmFootnoteDefinitionLabelString: enterFootnoteDefinitionLabelString,
|
|
681
|
+
gfmFootnoteDefinition: enterFootnoteDefinition
|
|
682
|
+
},
|
|
683
|
+
exit: {
|
|
684
|
+
gfmFootnoteCallString: exitFootnoteCallString,
|
|
685
|
+
gfmFootnoteCall: exitFootnoteCall,
|
|
686
|
+
gfmFootnoteDefinitionLabelString: exitFootnoteDefinitionLabelString,
|
|
687
|
+
gfmFootnoteDefinition: exitFootnoteDefinition
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
__name(gfmFootnoteFromMarkdown, "gfmFootnoteFromMarkdown");
|
|
692
|
+
function gfmFootnoteToMarkdown(options) {
|
|
693
|
+
let firstLineBlank = false;
|
|
694
|
+
if (options && options.firstLineBlank) {
|
|
695
|
+
firstLineBlank = true;
|
|
696
|
+
}
|
|
697
|
+
return {
|
|
698
|
+
handlers: { footnoteDefinition, footnoteReference },
|
|
699
|
+
// This is on by default already.
|
|
700
|
+
unsafe: [{ character: "[", inConstruct: ["label", "phrasing", "reference"] }]
|
|
701
|
+
};
|
|
702
|
+
function footnoteDefinition(node, _, state, info) {
|
|
703
|
+
const tracker = state.createTracker(info);
|
|
704
|
+
let value = tracker.move("[^");
|
|
705
|
+
const exit2 = state.enter("footnoteDefinition");
|
|
706
|
+
const subexit = state.enter("label");
|
|
707
|
+
value += tracker.move(
|
|
708
|
+
state.safe(state.associationId(node), { before: value, after: "]" })
|
|
709
|
+
);
|
|
710
|
+
subexit();
|
|
711
|
+
value += tracker.move("]:");
|
|
712
|
+
if (node.children && node.children.length > 0) {
|
|
713
|
+
tracker.shift(4);
|
|
714
|
+
value += tracker.move(
|
|
715
|
+
(firstLineBlank ? "\n" : " ") + state.indentLines(
|
|
716
|
+
state.containerFlow(node, tracker.current()),
|
|
717
|
+
firstLineBlank ? mapAll : mapExceptFirst
|
|
718
|
+
)
|
|
719
|
+
);
|
|
720
|
+
}
|
|
721
|
+
exit2();
|
|
722
|
+
return value;
|
|
723
|
+
}
|
|
724
|
+
__name(footnoteDefinition, "footnoteDefinition");
|
|
725
|
+
}
|
|
726
|
+
__name(gfmFootnoteToMarkdown, "gfmFootnoteToMarkdown");
|
|
727
|
+
function mapExceptFirst(line, index, blank) {
|
|
728
|
+
return index === 0 ? line : mapAll(line, index, blank);
|
|
729
|
+
}
|
|
730
|
+
__name(mapExceptFirst, "mapExceptFirst");
|
|
731
|
+
function mapAll(line, index, blank) {
|
|
732
|
+
return (blank ? "" : " ") + line;
|
|
733
|
+
}
|
|
734
|
+
__name(mapAll, "mapAll");
|
|
735
|
+
|
|
736
|
+
// node_modules/.pnpm/mdast-util-gfm-strikethrough@2.0.1/node_modules/mdast-util-gfm-strikethrough/lib/index.js
|
|
737
|
+
var constructsWithoutStrikethrough = [
|
|
738
|
+
"autolink",
|
|
739
|
+
"destinationLiteral",
|
|
740
|
+
"destinationRaw",
|
|
741
|
+
"reference",
|
|
742
|
+
"titleQuote",
|
|
743
|
+
"titleApostrophe"
|
|
744
|
+
];
|
|
745
|
+
handleDelete.attention = attentionDelete;
|
|
746
|
+
handleDelete.peek = peekDelete;
|
|
747
|
+
function gfmStrikethroughFromMarkdown() {
|
|
748
|
+
return {
|
|
749
|
+
canContainEols: ["delete"],
|
|
750
|
+
enter: { strikethrough: enterStrikethrough },
|
|
751
|
+
exit: { strikethrough: exitStrikethrough }
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
__name(gfmStrikethroughFromMarkdown, "gfmStrikethroughFromMarkdown");
|
|
755
|
+
function gfmStrikethroughToMarkdown() {
|
|
756
|
+
return {
|
|
757
|
+
handlers: { delete: handleDelete },
|
|
758
|
+
unsafe: [
|
|
759
|
+
{
|
|
760
|
+
character: "~",
|
|
761
|
+
inConstruct: "phrasing",
|
|
762
|
+
notInConstruct: constructsWithoutStrikethrough
|
|
763
|
+
}
|
|
764
|
+
]
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
__name(gfmStrikethroughToMarkdown, "gfmStrikethroughToMarkdown");
|
|
768
|
+
function enterStrikethrough(token) {
|
|
769
|
+
this.enter({ type: "delete", children: [], position: void 0 }, token);
|
|
770
|
+
}
|
|
771
|
+
__name(enterStrikethrough, "enterStrikethrough");
|
|
772
|
+
function exitStrikethrough(token) {
|
|
773
|
+
this.exit(token);
|
|
774
|
+
}
|
|
775
|
+
__name(exitStrikethrough, "exitStrikethrough");
|
|
776
|
+
function handleDelete(node, _, state, info) {
|
|
777
|
+
const tracker = state.createTracker(info);
|
|
778
|
+
const sequence = state.stack.includes("strikethrough") ? "~" : "~~";
|
|
779
|
+
const exit2 = state.enter("strikethrough");
|
|
780
|
+
let value = tracker.move(sequence);
|
|
781
|
+
value += state.containerPhrasing(node, {
|
|
782
|
+
...tracker.current(),
|
|
783
|
+
before: value,
|
|
784
|
+
after: "~"
|
|
785
|
+
});
|
|
786
|
+
value += tracker.move(sequence);
|
|
787
|
+
exit2();
|
|
788
|
+
return value;
|
|
789
|
+
}
|
|
790
|
+
__name(handleDelete, "handleDelete");
|
|
791
|
+
function attentionDelete() {
|
|
792
|
+
return { construct: "strikethrough", markers: ["~"], sizes: [2, 1] };
|
|
793
|
+
}
|
|
794
|
+
__name(attentionDelete, "attentionDelete");
|
|
795
|
+
function peekDelete() {
|
|
796
|
+
return "~";
|
|
797
|
+
}
|
|
798
|
+
__name(peekDelete, "peekDelete");
|
|
799
|
+
|
|
800
|
+
// node_modules/.pnpm/markdown-table@3.1.0/node_modules/markdown-table/index.js
|
|
801
|
+
function defaultStringLength(value) {
|
|
802
|
+
return value.length;
|
|
803
|
+
}
|
|
804
|
+
__name(defaultStringLength, "defaultStringLength");
|
|
805
|
+
function markdownTable(table, options) {
|
|
806
|
+
const settings = options || {};
|
|
807
|
+
const align = (settings.align || []).concat();
|
|
808
|
+
const stringLength = settings.stringLength || defaultStringLength;
|
|
809
|
+
const alignments = [];
|
|
810
|
+
const cellMatrix = [];
|
|
811
|
+
const sizeMatrix = [];
|
|
812
|
+
const longestCellByColumn = [];
|
|
813
|
+
let mostCellsPerRow = 0;
|
|
814
|
+
let rowIndex = -1;
|
|
815
|
+
while (++rowIndex < table.length) {
|
|
816
|
+
const row2 = [];
|
|
817
|
+
const sizes2 = [];
|
|
818
|
+
let columnIndex2 = -1;
|
|
819
|
+
if (table[rowIndex].length > mostCellsPerRow) {
|
|
820
|
+
mostCellsPerRow = table[rowIndex].length;
|
|
821
|
+
}
|
|
822
|
+
while (++columnIndex2 < table[rowIndex].length) {
|
|
823
|
+
const cell = serialize(table[rowIndex][columnIndex2]);
|
|
824
|
+
if (settings.alignDelimiters !== false) {
|
|
825
|
+
const size = stringLength(cell);
|
|
826
|
+
sizes2[columnIndex2] = size;
|
|
827
|
+
if (longestCellByColumn[columnIndex2] === void 0 || size > longestCellByColumn[columnIndex2]) {
|
|
828
|
+
longestCellByColumn[columnIndex2] = size;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
row2.push(cell);
|
|
832
|
+
}
|
|
833
|
+
cellMatrix[rowIndex] = row2;
|
|
834
|
+
sizeMatrix[rowIndex] = sizes2;
|
|
835
|
+
}
|
|
836
|
+
let columnIndex = -1;
|
|
837
|
+
if (typeof align === "object" && "length" in align) {
|
|
838
|
+
while (++columnIndex < mostCellsPerRow) {
|
|
839
|
+
alignments[columnIndex] = toAlignment(align[columnIndex]);
|
|
840
|
+
}
|
|
841
|
+
} else {
|
|
842
|
+
const code2 = toAlignment(align);
|
|
843
|
+
while (++columnIndex < mostCellsPerRow) {
|
|
844
|
+
alignments[columnIndex] = code2;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
columnIndex = -1;
|
|
848
|
+
const row = [];
|
|
849
|
+
const sizes = [];
|
|
850
|
+
while (++columnIndex < mostCellsPerRow) {
|
|
851
|
+
const code2 = alignments[columnIndex];
|
|
852
|
+
let before = "";
|
|
853
|
+
let after = "";
|
|
854
|
+
if (code2 === 99) {
|
|
855
|
+
before = ":";
|
|
856
|
+
after = ":";
|
|
857
|
+
} else if (code2 === 108) {
|
|
858
|
+
before = ":";
|
|
859
|
+
} else if (code2 === 114) {
|
|
860
|
+
after = ":";
|
|
861
|
+
}
|
|
862
|
+
let size = settings.alignDelimiters === false ? 1 : Math.max(
|
|
863
|
+
1,
|
|
864
|
+
longestCellByColumn[columnIndex] - before.length - after.length
|
|
865
|
+
);
|
|
866
|
+
const cell = before + "-".repeat(size) + after;
|
|
867
|
+
if (settings.alignDelimiters !== false) {
|
|
868
|
+
size = before.length + size + after.length;
|
|
869
|
+
if (size > longestCellByColumn[columnIndex]) {
|
|
870
|
+
longestCellByColumn[columnIndex] = size;
|
|
871
|
+
}
|
|
872
|
+
sizes[columnIndex] = size;
|
|
873
|
+
}
|
|
874
|
+
row[columnIndex] = cell;
|
|
875
|
+
}
|
|
876
|
+
cellMatrix.splice(1, 0, row);
|
|
877
|
+
sizeMatrix.splice(1, 0, sizes);
|
|
878
|
+
rowIndex = -1;
|
|
879
|
+
const lines = [];
|
|
880
|
+
while (++rowIndex < cellMatrix.length) {
|
|
881
|
+
const row2 = cellMatrix[rowIndex];
|
|
882
|
+
const sizes2 = sizeMatrix[rowIndex];
|
|
883
|
+
const cellsInRow = settings.fillRows === false ? Math.max(1, cellMatrix[rowIndex === 1 ? 0 : rowIndex].length) : mostCellsPerRow;
|
|
884
|
+
columnIndex = -1;
|
|
885
|
+
const line = [];
|
|
886
|
+
while (++columnIndex < cellsInRow) {
|
|
887
|
+
const cell = row2[columnIndex] || "";
|
|
888
|
+
let before = "";
|
|
889
|
+
let after = "";
|
|
890
|
+
if (settings.alignDelimiters !== false) {
|
|
891
|
+
const size = longestCellByColumn[columnIndex] - (sizes2[columnIndex] || 0);
|
|
892
|
+
const code2 = alignments[columnIndex];
|
|
893
|
+
if (code2 === 114) {
|
|
894
|
+
before = " ".repeat(size);
|
|
895
|
+
} else if (code2 === 99) {
|
|
896
|
+
const half = size / 2;
|
|
897
|
+
if (size % 2) {
|
|
898
|
+
before = " ".repeat(half + 0.5);
|
|
899
|
+
after = " ".repeat(half - 0.5);
|
|
900
|
+
} else {
|
|
901
|
+
before = " ".repeat(half);
|
|
902
|
+
after = before;
|
|
903
|
+
}
|
|
904
|
+
} else {
|
|
905
|
+
after = " ".repeat(size);
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
if (settings.delimiterStart !== false && !columnIndex) {
|
|
909
|
+
line.push("|");
|
|
910
|
+
}
|
|
911
|
+
if (settings.padding !== false && // Don’t add the opening space if we’re not aligning and the cell is
|
|
912
|
+
// empty: there will be a closing space.
|
|
913
|
+
!(settings.alignDelimiters === false && cell === "") && (settings.delimiterStart !== false || columnIndex)) {
|
|
914
|
+
line.push(" ");
|
|
915
|
+
}
|
|
916
|
+
if (settings.alignDelimiters !== false) {
|
|
917
|
+
line.push(before);
|
|
918
|
+
}
|
|
919
|
+
line.push(cell);
|
|
920
|
+
if (settings.alignDelimiters !== false) {
|
|
921
|
+
line.push(after);
|
|
922
|
+
}
|
|
923
|
+
if (settings.padding !== false) {
|
|
924
|
+
line.push(" ");
|
|
925
|
+
}
|
|
926
|
+
if (settings.delimiterEnd !== false || columnIndex !== cellsInRow - 1) {
|
|
927
|
+
line.push("|");
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
lines.push(
|
|
931
|
+
settings.delimiterEnd === false ? line.join("").replace(/ +$/, "") : line.join("")
|
|
932
|
+
);
|
|
933
|
+
}
|
|
934
|
+
return lines.join("\n");
|
|
935
|
+
}
|
|
936
|
+
__name(markdownTable, "markdownTable");
|
|
937
|
+
function serialize(value) {
|
|
938
|
+
return value === null || value === void 0 ? "" : String(value);
|
|
939
|
+
}
|
|
940
|
+
__name(serialize, "serialize");
|
|
941
|
+
function toAlignment(value) {
|
|
942
|
+
const code2 = typeof value === "string" ? value.codePointAt(0) : 0;
|
|
943
|
+
return code2 === 67 || code2 === 99 ? 99 : code2 === 76 || code2 === 108 ? 108 : code2 === 82 || code2 === 114 ? 114 : 0;
|
|
944
|
+
}
|
|
945
|
+
__name(toAlignment, "toAlignment");
|
|
946
|
+
|
|
947
|
+
// node_modules/.pnpm/mdast-util-phrasing@4.1.0/node_modules/mdast-util-phrasing/lib/index.js
|
|
948
|
+
var phrasing = (
|
|
949
|
+
/** @type {(node?: unknown) => node is Exclude<PhrasingContent, Html>} */
|
|
950
|
+
convert([
|
|
951
|
+
"break",
|
|
952
|
+
"delete",
|
|
953
|
+
"emphasis",
|
|
954
|
+
// To do: next major: removed since footnotes were added to GFM.
|
|
955
|
+
"footnote",
|
|
956
|
+
"footnoteReference",
|
|
957
|
+
"image",
|
|
958
|
+
"imageReference",
|
|
959
|
+
"inlineCode",
|
|
960
|
+
// Enabled by `mdast-util-math`:
|
|
961
|
+
"inlineMath",
|
|
962
|
+
"link",
|
|
963
|
+
"linkReference",
|
|
964
|
+
// Enabled by `mdast-util-mdx`:
|
|
965
|
+
"mdxJsxTextElement",
|
|
966
|
+
// Enabled by `mdast-util-mdx`:
|
|
967
|
+
"mdxTextExpression",
|
|
968
|
+
"strong",
|
|
969
|
+
"text",
|
|
970
|
+
// Enabled by `mdast-util-directive`:
|
|
971
|
+
"textDirective"
|
|
972
|
+
])
|
|
973
|
+
);
|
|
974
|
+
|
|
975
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/handle/blockquote.js
|
|
976
|
+
function blockquote(node, _, state, info) {
|
|
977
|
+
const exit2 = state.enter("blockquote");
|
|
978
|
+
const tracker = state.createTracker(info);
|
|
979
|
+
tracker.move("> ");
|
|
980
|
+
tracker.shift(2);
|
|
981
|
+
const value = state.indentLines(
|
|
982
|
+
state.containerFlow(node, tracker.current()),
|
|
983
|
+
map
|
|
984
|
+
);
|
|
985
|
+
exit2();
|
|
986
|
+
return value;
|
|
987
|
+
}
|
|
988
|
+
__name(blockquote, "blockquote");
|
|
989
|
+
function map(line, _, blank) {
|
|
990
|
+
return ">" + (blank ? "" : " ") + line;
|
|
991
|
+
}
|
|
992
|
+
__name(map, "map");
|
|
993
|
+
|
|
994
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/util/pattern-in-scope.js
|
|
995
|
+
function patternInScope(stack, pattern) {
|
|
996
|
+
return listInScope(stack, pattern.inConstruct, true) && !listInScope(stack, pattern.notInConstruct, false);
|
|
997
|
+
}
|
|
998
|
+
__name(patternInScope, "patternInScope");
|
|
999
|
+
function listInScope(stack, list2, none) {
|
|
1000
|
+
if (typeof list2 === "string") {
|
|
1001
|
+
list2 = [list2];
|
|
1002
|
+
}
|
|
1003
|
+
if (!list2 || list2.length === 0) {
|
|
1004
|
+
return none;
|
|
1005
|
+
}
|
|
1006
|
+
let index = -1;
|
|
1007
|
+
while (++index < list2.length) {
|
|
1008
|
+
if (stack.includes(list2[index])) {
|
|
1009
|
+
return true;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
return false;
|
|
1013
|
+
}
|
|
1014
|
+
__name(listInScope, "listInScope");
|
|
1015
|
+
|
|
1016
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/handle/break.js
|
|
1017
|
+
function hardBreak(_, _1, state, info) {
|
|
1018
|
+
let index = -1;
|
|
1019
|
+
while (++index < state.unsafe.length) {
|
|
1020
|
+
const pattern = state.unsafe[index];
|
|
1021
|
+
if (pattern.character === "\n" && !pattern.before && !pattern.after && patternInScope(state.stack, pattern)) {
|
|
1022
|
+
return /[\t ]/.test(info.before) ? "" : " ";
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
return "\\\n";
|
|
1026
|
+
}
|
|
1027
|
+
__name(hardBreak, "hardBreak");
|
|
1028
|
+
|
|
1029
|
+
// node_modules/.pnpm/longest-streak@3.1.0/node_modules/longest-streak/index.js
|
|
1030
|
+
function longestStreak(value, substring) {
|
|
1031
|
+
const source = String(value);
|
|
1032
|
+
let index = source.indexOf(substring);
|
|
1033
|
+
let expected = index;
|
|
1034
|
+
let count = 0;
|
|
1035
|
+
let max = 0;
|
|
1036
|
+
if (typeof substring !== "string") {
|
|
1037
|
+
throw new TypeError("Expected substring");
|
|
1038
|
+
}
|
|
1039
|
+
while (index !== -1) {
|
|
1040
|
+
if (index === expected) {
|
|
1041
|
+
if (++count > max) {
|
|
1042
|
+
max = count;
|
|
1043
|
+
}
|
|
1044
|
+
} else {
|
|
1045
|
+
count = 1;
|
|
1046
|
+
}
|
|
1047
|
+
expected = index + substring.length;
|
|
1048
|
+
index = source.indexOf(substring, expected);
|
|
1049
|
+
}
|
|
1050
|
+
return max;
|
|
1051
|
+
}
|
|
1052
|
+
__name(longestStreak, "longestStreak");
|
|
1053
|
+
|
|
1054
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/util/format-code-as-indented.js
|
|
1055
|
+
function formatCodeAsIndented(node, state) {
|
|
1056
|
+
return Boolean(
|
|
1057
|
+
state.options.fences === false && node.value && // If there’s no info…
|
|
1058
|
+
!node.lang && // And there’s a non-whitespace character…
|
|
1059
|
+
/[^\n\r ]/.test(node.value) && // And the value doesn’t start or end in a blank…
|
|
1060
|
+
!/^[\t ]*(?:[\n\r]|$)|(?:^|[\n\r])[\t ]*$/.test(node.value)
|
|
1061
|
+
);
|
|
1062
|
+
}
|
|
1063
|
+
__name(formatCodeAsIndented, "formatCodeAsIndented");
|
|
1064
|
+
|
|
1065
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/util/check-fence.js
|
|
1066
|
+
function checkFence(state) {
|
|
1067
|
+
const marker = state.options.fence || "`";
|
|
1068
|
+
if (marker !== "`" && marker !== "~") {
|
|
1069
|
+
throw new Error(
|
|
1070
|
+
"Cannot serialize code with `" + marker + "` for `options.fence`, expected `` ` `` or `~`"
|
|
1071
|
+
);
|
|
1072
|
+
}
|
|
1073
|
+
return marker;
|
|
1074
|
+
}
|
|
1075
|
+
__name(checkFence, "checkFence");
|
|
1076
|
+
|
|
1077
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/handle/code.js
|
|
1078
|
+
function code(node, _, state, info) {
|
|
1079
|
+
const marker = checkFence(state);
|
|
1080
|
+
const raw = node.value || "";
|
|
1081
|
+
if (formatCodeAsIndented(node, state)) {
|
|
1082
|
+
const exit3 = state.enter("codeIndented");
|
|
1083
|
+
const value2 = state.indentLines(raw, map2);
|
|
1084
|
+
exit3();
|
|
1085
|
+
return value2;
|
|
1086
|
+
}
|
|
1087
|
+
const tracker = state.createTracker(info);
|
|
1088
|
+
const sequence = marker.repeat(Math.max(longestStreak(raw, marker) + 1, 3));
|
|
1089
|
+
const exit2 = state.enter("codeFenced");
|
|
1090
|
+
const suffix = marker === "`" ? "GraveAccent" : "Tilde";
|
|
1091
|
+
let value = tracker.move(sequence);
|
|
1092
|
+
if (node.lang) {
|
|
1093
|
+
const subexit = state.enter(`codeFencedLang${suffix}`);
|
|
1094
|
+
value += tracker.move(
|
|
1095
|
+
state.safe(node.lang, {
|
|
1096
|
+
before: value,
|
|
1097
|
+
after: " ",
|
|
1098
|
+
encode: ["`"],
|
|
1099
|
+
...tracker.current()
|
|
1100
|
+
})
|
|
1101
|
+
);
|
|
1102
|
+
subexit();
|
|
1103
|
+
}
|
|
1104
|
+
if (node.lang && node.meta) {
|
|
1105
|
+
const subexit = state.enter(`codeFencedMeta${suffix}`);
|
|
1106
|
+
value += tracker.move(" ");
|
|
1107
|
+
value += tracker.move(
|
|
1108
|
+
state.safe(node.meta, {
|
|
1109
|
+
before: value,
|
|
1110
|
+
after: "\n",
|
|
1111
|
+
encode: ["`"],
|
|
1112
|
+
...tracker.current()
|
|
1113
|
+
})
|
|
1114
|
+
);
|
|
1115
|
+
subexit();
|
|
1116
|
+
}
|
|
1117
|
+
value += tracker.move("\n");
|
|
1118
|
+
if (raw) {
|
|
1119
|
+
value += tracker.move(raw + "\n");
|
|
1120
|
+
}
|
|
1121
|
+
value += tracker.move(sequence);
|
|
1122
|
+
exit2();
|
|
1123
|
+
return value;
|
|
1124
|
+
}
|
|
1125
|
+
__name(code, "code");
|
|
1126
|
+
function map2(line, _, blank) {
|
|
1127
|
+
return (blank ? "" : " ") + line;
|
|
1128
|
+
}
|
|
1129
|
+
__name(map2, "map");
|
|
1130
|
+
|
|
1131
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/util/check-quote.js
|
|
1132
|
+
function checkQuote(state) {
|
|
1133
|
+
const marker = state.options.quote || '"';
|
|
1134
|
+
if (marker !== '"' && marker !== "'") {
|
|
1135
|
+
throw new Error(
|
|
1136
|
+
"Cannot serialize title with `" + marker + "` for `options.quote`, expected `\"`, or `'`"
|
|
1137
|
+
);
|
|
1138
|
+
}
|
|
1139
|
+
return marker;
|
|
1140
|
+
}
|
|
1141
|
+
__name(checkQuote, "checkQuote");
|
|
1142
|
+
|
|
1143
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/handle/definition.js
|
|
1144
|
+
function definition(node, _, state, info) {
|
|
1145
|
+
const quote = checkQuote(state);
|
|
1146
|
+
const suffix = quote === '"' ? "Quote" : "Apostrophe";
|
|
1147
|
+
const exit2 = state.enter("definition");
|
|
1148
|
+
let subexit = state.enter("label");
|
|
1149
|
+
const tracker = state.createTracker(info);
|
|
1150
|
+
let value = tracker.move("[");
|
|
1151
|
+
value += tracker.move(
|
|
1152
|
+
state.safe(state.associationId(node), {
|
|
1153
|
+
before: value,
|
|
1154
|
+
after: "]",
|
|
1155
|
+
...tracker.current()
|
|
1156
|
+
})
|
|
1157
|
+
);
|
|
1158
|
+
value += tracker.move("]: ");
|
|
1159
|
+
subexit();
|
|
1160
|
+
if (
|
|
1161
|
+
// If there’s no url, or…
|
|
1162
|
+
!node.url || // If there are control characters or whitespace.
|
|
1163
|
+
/[\0- \u007F]/.test(node.url)
|
|
1164
|
+
) {
|
|
1165
|
+
subexit = state.enter("destinationLiteral");
|
|
1166
|
+
value += tracker.move("<");
|
|
1167
|
+
value += tracker.move(
|
|
1168
|
+
state.safe(node.url, { before: value, after: ">", ...tracker.current() })
|
|
1169
|
+
);
|
|
1170
|
+
value += tracker.move(">");
|
|
1171
|
+
} else {
|
|
1172
|
+
subexit = state.enter("destinationRaw");
|
|
1173
|
+
value += tracker.move(
|
|
1174
|
+
state.safe(node.url, {
|
|
1175
|
+
before: value,
|
|
1176
|
+
after: node.title ? " " : "\n",
|
|
1177
|
+
...tracker.current()
|
|
1178
|
+
})
|
|
1179
|
+
);
|
|
1180
|
+
}
|
|
1181
|
+
subexit();
|
|
1182
|
+
if (node.title) {
|
|
1183
|
+
subexit = state.enter(`title${suffix}`);
|
|
1184
|
+
value += tracker.move(" " + quote);
|
|
1185
|
+
value += tracker.move(
|
|
1186
|
+
state.safe(node.title, {
|
|
1187
|
+
before: value,
|
|
1188
|
+
after: quote,
|
|
1189
|
+
...tracker.current()
|
|
1190
|
+
})
|
|
1191
|
+
);
|
|
1192
|
+
value += tracker.move(quote);
|
|
1193
|
+
subexit();
|
|
1194
|
+
}
|
|
1195
|
+
exit2();
|
|
1196
|
+
return value;
|
|
1197
|
+
}
|
|
1198
|
+
__name(definition, "definition");
|
|
1199
|
+
|
|
1200
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/util/check-emphasis.js
|
|
1201
|
+
function checkEmphasis(state) {
|
|
1202
|
+
const marker = state.options.emphasis || "*";
|
|
1203
|
+
if (marker !== "*" && marker !== "_") {
|
|
1204
|
+
throw new Error(
|
|
1205
|
+
"Cannot serialize emphasis with `" + marker + "` for `options.emphasis`, expected `*`, or `_`"
|
|
1206
|
+
);
|
|
1207
|
+
}
|
|
1208
|
+
return marker;
|
|
1209
|
+
}
|
|
1210
|
+
__name(checkEmphasis, "checkEmphasis");
|
|
1211
|
+
|
|
1212
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/util/character.js
|
|
1213
|
+
function firstCharacter(value) {
|
|
1214
|
+
const code2 = value.codePointAt(0);
|
|
1215
|
+
return code2 === void 0 ? "" : String.fromCodePoint(code2);
|
|
1216
|
+
}
|
|
1217
|
+
__name(firstCharacter, "firstCharacter");
|
|
1218
|
+
function lastCharacter(value) {
|
|
1219
|
+
const code2 = value.codePointAt(value.length - 2);
|
|
1220
|
+
return code2 !== void 0 && code2 > 65535 ? value.slice(-2) : value.slice(-1);
|
|
1221
|
+
}
|
|
1222
|
+
__name(lastCharacter, "lastCharacter");
|
|
1223
|
+
|
|
1224
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/util/encode-character-reference.js
|
|
1225
|
+
function encodeCharacterReference(code2) {
|
|
1226
|
+
return "&#x" + code2.toString(16).toUpperCase() + ";";
|
|
1227
|
+
}
|
|
1228
|
+
__name(encodeCharacterReference, "encodeCharacterReference");
|
|
1229
|
+
|
|
1230
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/util/encode-info.js
|
|
1231
|
+
function encodeInfo(outside, inside, marker) {
|
|
1232
|
+
const outsideKind = classifyCharacter(outside);
|
|
1233
|
+
const insideKind = classifyCharacter(inside);
|
|
1234
|
+
if (outsideKind === void 0) {
|
|
1235
|
+
return insideKind === void 0 ? (
|
|
1236
|
+
// Letter inside:
|
|
1237
|
+
// we have to encode *both* letters for `_` as it is looser.
|
|
1238
|
+
// it already forms for `*` (and GFMs `~`).
|
|
1239
|
+
marker === "_" ? { inside: true, outside: true } : { inside: false, outside: false }
|
|
1240
|
+
) : insideKind === 1 ? (
|
|
1241
|
+
// Whitespace inside: encode both (letter, whitespace).
|
|
1242
|
+
{ inside: true, outside: true }
|
|
1243
|
+
) : (
|
|
1244
|
+
// Punctuation inside: encode outer (letter)
|
|
1245
|
+
{ inside: false, outside: true }
|
|
1246
|
+
);
|
|
1247
|
+
}
|
|
1248
|
+
if (outsideKind === 1) {
|
|
1249
|
+
return insideKind === void 0 ? (
|
|
1250
|
+
// Letter inside: already forms.
|
|
1251
|
+
{ inside: false, outside: false }
|
|
1252
|
+
) : insideKind === 1 ? (
|
|
1253
|
+
// Whitespace inside: encode both (whitespace).
|
|
1254
|
+
{ inside: true, outside: true }
|
|
1255
|
+
) : (
|
|
1256
|
+
// Punctuation inside: already forms.
|
|
1257
|
+
{ inside: false, outside: false }
|
|
1258
|
+
);
|
|
1259
|
+
}
|
|
1260
|
+
return insideKind === void 0 ? (
|
|
1261
|
+
// Letter inside: already forms.
|
|
1262
|
+
{ inside: false, outside: false }
|
|
1263
|
+
) : insideKind === 1 ? (
|
|
1264
|
+
// Whitespace inside: encode inner (whitespace).
|
|
1265
|
+
{ inside: true, outside: false }
|
|
1266
|
+
) : (
|
|
1267
|
+
// Punctuation inside: already forms.
|
|
1268
|
+
{ inside: false, outside: false }
|
|
1269
|
+
);
|
|
1270
|
+
}
|
|
1271
|
+
__name(encodeInfo, "encodeInfo");
|
|
1272
|
+
|
|
1273
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/util/html-kind.js
|
|
1274
|
+
function htmlKind(value) {
|
|
1275
|
+
if (value.charCodeAt(0) !== 60) return;
|
|
1276
|
+
const next = value.charCodeAt(1);
|
|
1277
|
+
if (next === 33) {
|
|
1278
|
+
const code3 = value.charCodeAt(2);
|
|
1279
|
+
if (code3 === 45) return 2;
|
|
1280
|
+
if (code3 === 91) return 5;
|
|
1281
|
+
if (asciiAlpha(code3)) return 4;
|
|
1282
|
+
return;
|
|
1283
|
+
}
|
|
1284
|
+
if (next === 63) return 3;
|
|
1285
|
+
const closing = next === 47;
|
|
1286
|
+
const start = closing ? 2 : 1;
|
|
1287
|
+
let end = start;
|
|
1288
|
+
let code2 = value.charCodeAt(end);
|
|
1289
|
+
if (!asciiAlpha(code2)) return;
|
|
1290
|
+
while (code2 === 45 || asciiAlphanumeric(code2)) {
|
|
1291
|
+
code2 = value.charCodeAt(++end);
|
|
1292
|
+
}
|
|
1293
|
+
const name = value.slice(start, end).toLowerCase();
|
|
1294
|
+
if (!closing && code2 !== 47 && htmlRawNames.includes(name)) {
|
|
1295
|
+
return 1;
|
|
1296
|
+
}
|
|
1297
|
+
return htmlBlockNames.includes(name) ? 6 : 7;
|
|
1298
|
+
}
|
|
1299
|
+
__name(htmlKind, "htmlKind");
|
|
1300
|
+
|
|
1301
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/util/container-phrasing.js
|
|
1302
|
+
var builtins = /* @__PURE__ */ new Map([
|
|
1303
|
+
["*", false],
|
|
1304
|
+
["_", true]
|
|
1305
|
+
]);
|
|
1306
|
+
function candidates(tokens, involved, runOf) {
|
|
1307
|
+
const related = /* @__PURE__ */ new Set();
|
|
1308
|
+
for (const token of tokens) {
|
|
1309
|
+
const siblings = runOf.get(token);
|
|
1310
|
+
if (siblings && token.attention && involved.some((d) => d.attention === token.attention)) {
|
|
1311
|
+
for (const sibling of siblings.tokens) {
|
|
1312
|
+
related.add(sibling.attention);
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
const ordered = [];
|
|
1317
|
+
for (const token of tokens) {
|
|
1318
|
+
if (token.attention && related.delete(token.attention)) {
|
|
1319
|
+
ordered.push(token.attention);
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
ordered.reverse();
|
|
1323
|
+
return ordered;
|
|
1324
|
+
}
|
|
1325
|
+
__name(candidates, "candidates");
|
|
1326
|
+
function check(tokens, before, after) {
|
|
1327
|
+
const runs = [];
|
|
1328
|
+
const wrong = /* @__PURE__ */ new Map();
|
|
1329
|
+
const runOf = /* @__PURE__ */ new Map();
|
|
1330
|
+
let index = 0;
|
|
1331
|
+
while (index < tokens.length) {
|
|
1332
|
+
if (!tokens[index].attention) {
|
|
1333
|
+
index++;
|
|
1334
|
+
continue;
|
|
1335
|
+
}
|
|
1336
|
+
const marker = tokens[index].value.charAt(0);
|
|
1337
|
+
const strict = builtins.get(marker);
|
|
1338
|
+
let end = index + 1;
|
|
1339
|
+
while (end < tokens.length && tokens[end].attention && tokens[end].value.charAt(0) === marker) {
|
|
1340
|
+
end++;
|
|
1341
|
+
}
|
|
1342
|
+
const head = index ? tokens[index - 1].value : before;
|
|
1343
|
+
const previous2 = classifyCharacter(head.charCodeAt(head.length - 1));
|
|
1344
|
+
const next = classifyCharacter(
|
|
1345
|
+
(end < tokens.length ? tokens[end].value : after).charCodeAt(0)
|
|
1346
|
+
);
|
|
1347
|
+
const open = !next || next === 2 && Boolean(previous2);
|
|
1348
|
+
const close = !previous2 || previous2 === 2 && Boolean(next);
|
|
1349
|
+
const run = {
|
|
1350
|
+
tokens: tokens.slice(index, end),
|
|
1351
|
+
markers: [],
|
|
1352
|
+
start: 0,
|
|
1353
|
+
end: 0,
|
|
1354
|
+
// Underscores are strict, they cannot open or close inside words.
|
|
1355
|
+
open: strict ? open && (Boolean(previous2) || !close) : open,
|
|
1356
|
+
close: strict ? close && (Boolean(next) || !open) : close,
|
|
1357
|
+
// All builtins can split runs.
|
|
1358
|
+
split: strict !== void 0
|
|
1359
|
+
};
|
|
1360
|
+
for (const token of run.tokens) {
|
|
1361
|
+
wrong.set(token, [...run.tokens]);
|
|
1362
|
+
runOf.set(token, run);
|
|
1363
|
+
let size = token.value.length;
|
|
1364
|
+
while (size--) run.markers.push(token);
|
|
1365
|
+
}
|
|
1366
|
+
run.end = run.markers.length;
|
|
1367
|
+
runs.push(run);
|
|
1368
|
+
index = end;
|
|
1369
|
+
}
|
|
1370
|
+
pair(runs, wrong);
|
|
1371
|
+
index = -1;
|
|
1372
|
+
while (++index < tokens.length) {
|
|
1373
|
+
const involved = wrong.get(tokens[index]);
|
|
1374
|
+
if (involved) return { attention: candidates(tokens, involved, runOf), index };
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
__name(check, "check");
|
|
1378
|
+
function encode(tokens, start) {
|
|
1379
|
+
const token = tokens[start ? 0 : tokens.length - 1];
|
|
1380
|
+
if (!token || token.attention) return;
|
|
1381
|
+
const character = start ? firstCharacter(token.value) : lastCharacter(token.value);
|
|
1382
|
+
const reference = encodeCharacterReference(
|
|
1383
|
+
/** @type {number} */
|
|
1384
|
+
character.codePointAt(0)
|
|
1385
|
+
);
|
|
1386
|
+
if (start) {
|
|
1387
|
+
token.value = reference + token.value.slice(character.length);
|
|
1388
|
+
} else {
|
|
1389
|
+
let value = token.value.slice(0, token.value.length - character.length);
|
|
1390
|
+
let escapes = 0;
|
|
1391
|
+
while (value.charCodeAt(value.length - 1 - escapes) === 92) {
|
|
1392
|
+
escapes++;
|
|
1393
|
+
}
|
|
1394
|
+
if (escapes % 2) value += "\\";
|
|
1395
|
+
token.value = value + reference;
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
__name(encode, "encode");
|
|
1399
|
+
function improve(items, chosen, mistake, before, after) {
|
|
1400
|
+
for (const attention3 of mistake.attention) {
|
|
1401
|
+
const current = chosen.get(attention3) || attention3.sequences[0];
|
|
1402
|
+
for (const sequence of attention3.sequences) {
|
|
1403
|
+
if (sequence === current) continue;
|
|
1404
|
+
const trial = new Map(chosen);
|
|
1405
|
+
trial.set(attention3, sequence);
|
|
1406
|
+
const tokens = render(items, trial, before, after);
|
|
1407
|
+
const next = check(tokens, before, after);
|
|
1408
|
+
if (!next || next.index > mistake.index) {
|
|
1409
|
+
return { chosen: trial, mistake: next, tokens };
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
__name(improve, "improve");
|
|
1415
|
+
function pair(runs, wrong) {
|
|
1416
|
+
const openersByMarker = /* @__PURE__ */ new Map();
|
|
1417
|
+
for (const closer of runs) {
|
|
1418
|
+
const marker = closer.tokens[0].value.charAt(0);
|
|
1419
|
+
let openers = openersByMarker.get(marker);
|
|
1420
|
+
if (!openers) {
|
|
1421
|
+
openers = [];
|
|
1422
|
+
openersByMarker.set(marker, openers);
|
|
1423
|
+
}
|
|
1424
|
+
let open = closer.close ? openers.length : 0;
|
|
1425
|
+
while (open-- && closer.start < closer.end) {
|
|
1426
|
+
const opener = openers[open];
|
|
1427
|
+
const openerSize = opener.end - opener.start;
|
|
1428
|
+
const closerSize = closer.end - closer.start;
|
|
1429
|
+
if (closer.split ? (
|
|
1430
|
+
// The rule of 3, on the sizes that are left.
|
|
1431
|
+
(opener.close || closer.open) && closerSize % 3 && !((openerSize + closerSize) % 3)
|
|
1432
|
+
) : (
|
|
1433
|
+
// Others pair whole runs of the same size.
|
|
1434
|
+
openerSize !== opener.markers.length || openerSize !== closerSize
|
|
1435
|
+
)) {
|
|
1436
|
+
continue;
|
|
1437
|
+
}
|
|
1438
|
+
const size = closer.split ? openerSize > 1 && closerSize > 1 ? 2 : 1 : closerSize;
|
|
1439
|
+
const opening = opener.markers.slice(opener.end - size, opener.end);
|
|
1440
|
+
const closing = closer.markers.slice(closer.start, closer.start + size);
|
|
1441
|
+
const openToken = opening[0];
|
|
1442
|
+
const closeToken = closing[0];
|
|
1443
|
+
if (
|
|
1444
|
+
// Whole sequences:
|
|
1445
|
+
// the markers of a sequence are next to each other,
|
|
1446
|
+
// so if the first and last marker are of one sequence of that size,
|
|
1447
|
+
// all markers are exactly that sequence.
|
|
1448
|
+
openToken === opening[size - 1] && openToken.value.length === size && closeToken === closing[size - 1] && closeToken.value.length === size && // Of the same attention, so its opening and closing sequence.
|
|
1449
|
+
openToken.attention === closeToken.attention
|
|
1450
|
+
) {
|
|
1451
|
+
wrong.delete(openToken);
|
|
1452
|
+
wrong.delete(closeToken);
|
|
1453
|
+
} else {
|
|
1454
|
+
const involved = [.../* @__PURE__ */ new Set([...opening, ...closing])];
|
|
1455
|
+
for (const token of involved) {
|
|
1456
|
+
const list2 = wrong.get(token);
|
|
1457
|
+
if (list2) list2.push(...involved);
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
opener.end -= size;
|
|
1461
|
+
closer.start += size;
|
|
1462
|
+
if (opener.start === opener.end) openers.splice(open, 1);
|
|
1463
|
+
open = openers.length;
|
|
1464
|
+
}
|
|
1465
|
+
if (closer.open && closer.start < closer.end) openers.push(closer);
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
__name(pair, "pair");
|
|
1469
|
+
function attentionSequences(type, markers, sizes) {
|
|
1470
|
+
if (markers.length === 0) {
|
|
1471
|
+
throw new Error(
|
|
1472
|
+
"Cannot serialize `" + type + "` as attention without markers, expected one or more markers"
|
|
1473
|
+
);
|
|
1474
|
+
}
|
|
1475
|
+
if (sizes.length === 0) {
|
|
1476
|
+
throw new Error(
|
|
1477
|
+
"Cannot serialize `" + type + "` as attention without sizes, expected one or more sizes"
|
|
1478
|
+
);
|
|
1479
|
+
}
|
|
1480
|
+
for (const size of sizes) {
|
|
1481
|
+
if (!Number.isSafeInteger(size) || size < 1) {
|
|
1482
|
+
throw new Error(
|
|
1483
|
+
"Cannot serialize `" + type + "` as attention with `" + size + "` as size, expected positive integer"
|
|
1484
|
+
);
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
const sequences = [];
|
|
1488
|
+
for (const marker of markers) {
|
|
1489
|
+
if (marker.length !== 1) {
|
|
1490
|
+
throw new Error(
|
|
1491
|
+
"Cannot serialize `" + type + "` as attention with `" + marker + "` as marker, expected a single ascii character"
|
|
1492
|
+
);
|
|
1493
|
+
}
|
|
1494
|
+
if (!asciiPunctuation(marker.charCodeAt(0))) {
|
|
1495
|
+
throw new Error(
|
|
1496
|
+
"Cannot serialize `" + type + "` as attention with `" + marker + "` as marker, expected ascii punctuation"
|
|
1497
|
+
);
|
|
1498
|
+
}
|
|
1499
|
+
for (const size of sizes) {
|
|
1500
|
+
sequences.push(marker.repeat(size));
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
return sequences;
|
|
1504
|
+
}
|
|
1505
|
+
__name(attentionSequences, "attentionSequences");
|
|
1506
|
+
function phrasing2(parent, state, info) {
|
|
1507
|
+
const indexStack = state.indexStack;
|
|
1508
|
+
const children = parent.children || [];
|
|
1509
|
+
const results = [];
|
|
1510
|
+
let index = -1;
|
|
1511
|
+
let before = info.before;
|
|
1512
|
+
indexStack.push(-1);
|
|
1513
|
+
let tracker = state.createTracker(info);
|
|
1514
|
+
while (++index < children.length) {
|
|
1515
|
+
const child = children[index];
|
|
1516
|
+
let after;
|
|
1517
|
+
indexStack[indexStack.length - 1] = index;
|
|
1518
|
+
if (index + 1 < children.length) {
|
|
1519
|
+
let handle3 = state.handle.handlers[children[index + 1].type];
|
|
1520
|
+
if (handle3 && handle3.peek) handle3 = handle3.peek;
|
|
1521
|
+
after = handle3 ? firstCharacter(
|
|
1522
|
+
handle3(children[index + 1], parent, state, {
|
|
1523
|
+
before: "",
|
|
1524
|
+
after: "",
|
|
1525
|
+
...tracker.current()
|
|
1526
|
+
})
|
|
1527
|
+
) : "";
|
|
1528
|
+
} else {
|
|
1529
|
+
after = info.after;
|
|
1530
|
+
}
|
|
1531
|
+
const previous2 = results[results.length - 1];
|
|
1532
|
+
if (typeof previous2 === "string" && (before === "\r" || before === "\n") && child.type === "html" && htmlKind(child.value) !== 7) {
|
|
1533
|
+
results[results.length - 1] = previous2.replace(/(\r?\n|\r)$/, " ");
|
|
1534
|
+
before = " ";
|
|
1535
|
+
tracker = state.createTracker(info);
|
|
1536
|
+
tracker.move(serialize2(results, info.before, info.after));
|
|
1537
|
+
}
|
|
1538
|
+
const handle2 = state.handle.handlers[child.type];
|
|
1539
|
+
if (handle2 && handle2.attention) {
|
|
1540
|
+
const item = attentionItem(
|
|
1541
|
+
/** @type {PhrasingParents} */
|
|
1542
|
+
child,
|
|
1543
|
+
handle2.attention,
|
|
1544
|
+
state,
|
|
1545
|
+
tracker
|
|
1546
|
+
);
|
|
1547
|
+
if (!item) continue;
|
|
1548
|
+
results.push(item);
|
|
1549
|
+
before = lastCharacter(item.sequences[0]);
|
|
1550
|
+
} else {
|
|
1551
|
+
const value = state.handle(child, parent, state, {
|
|
1552
|
+
...tracker.current(),
|
|
1553
|
+
after,
|
|
1554
|
+
before
|
|
1555
|
+
});
|
|
1556
|
+
if (!value) continue;
|
|
1557
|
+
tracker.move(value);
|
|
1558
|
+
results.push(value);
|
|
1559
|
+
before = lastCharacter(value);
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
indexStack.pop();
|
|
1563
|
+
return results;
|
|
1564
|
+
}
|
|
1565
|
+
__name(phrasing2, "phrasing");
|
|
1566
|
+
function attentionItem(node, attention3, state, tracker) {
|
|
1567
|
+
const { construct, markers, sizes } = attention3(node, state);
|
|
1568
|
+
const sequences = attentionSequences(node.type, markers, sizes);
|
|
1569
|
+
const sequence = sequences[0];
|
|
1570
|
+
const exit2 = state.enter(construct);
|
|
1571
|
+
const inside = state.createTracker(tracker.current());
|
|
1572
|
+
inside.move(sequence);
|
|
1573
|
+
const children = phrasing2(node, state, {
|
|
1574
|
+
...inside.current(),
|
|
1575
|
+
before: sequence,
|
|
1576
|
+
after: sequence
|
|
1577
|
+
});
|
|
1578
|
+
exit2();
|
|
1579
|
+
if (children.length === 0) return;
|
|
1580
|
+
tracker.move(sequence);
|
|
1581
|
+
tracker.move(serialize2(children, sequence, sequence));
|
|
1582
|
+
tracker.move(sequence);
|
|
1583
|
+
return { children, sequences };
|
|
1584
|
+
}
|
|
1585
|
+
__name(attentionItem, "attentionItem");
|
|
1586
|
+
function fix(items, chosen, before, after) {
|
|
1587
|
+
let tokens = render(items, chosen, before, after);
|
|
1588
|
+
let mistake = check(tokens, before, after);
|
|
1589
|
+
while (mistake) {
|
|
1590
|
+
const next = improve(items, chosen, mistake, before, after);
|
|
1591
|
+
if (!next) return;
|
|
1592
|
+
chosen = next.chosen;
|
|
1593
|
+
tokens = next.tokens;
|
|
1594
|
+
mistake = next.mistake;
|
|
1595
|
+
}
|
|
1596
|
+
return tokens;
|
|
1597
|
+
}
|
|
1598
|
+
__name(fix, "fix");
|
|
1599
|
+
function guess(items, chosen, before, after) {
|
|
1600
|
+
let previous2 = before;
|
|
1601
|
+
let index = -1;
|
|
1602
|
+
while (++index < items.length) {
|
|
1603
|
+
const item = items[index];
|
|
1604
|
+
if (typeof item === "string") {
|
|
1605
|
+
previous2 = "";
|
|
1606
|
+
continue;
|
|
1607
|
+
}
|
|
1608
|
+
const next = index === items.length - 1 ? after : "";
|
|
1609
|
+
const sequence = item.sequences.find(function(value) {
|
|
1610
|
+
const marker = value.charAt(0);
|
|
1611
|
+
return marker !== previous2.charAt(0) && marker !== next.charAt(0) || items.length === 1 && builtins.has(marker) && value.length > before.length;
|
|
1612
|
+
}) || item.sequences[0];
|
|
1613
|
+
if (sequence !== item.sequences[0]) chosen.set(item, sequence);
|
|
1614
|
+
guess(item.children, chosen, sequence, sequence);
|
|
1615
|
+
previous2 = sequence;
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
__name(guess, "guess");
|
|
1619
|
+
function render(items, chosen, before, after) {
|
|
1620
|
+
const tokens = [];
|
|
1621
|
+
let encodeAfter;
|
|
1622
|
+
let previous2 = lastCharacter(before);
|
|
1623
|
+
let index = -1;
|
|
1624
|
+
while (++index < items.length) {
|
|
1625
|
+
const item = items[index];
|
|
1626
|
+
if (typeof item === "string") {
|
|
1627
|
+
const token = { value: item, attention: void 0 };
|
|
1628
|
+
if (encodeAfter && encodeAfter === firstCharacter(item)) {
|
|
1629
|
+
encode([token], true);
|
|
1630
|
+
}
|
|
1631
|
+
encodeAfter = void 0;
|
|
1632
|
+
tokens.push(token);
|
|
1633
|
+
if (token.value) previous2 = lastCharacter(token.value);
|
|
1634
|
+
continue;
|
|
1635
|
+
}
|
|
1636
|
+
const sequence = chosen.get(item) || item.sequences[0];
|
|
1637
|
+
const marker = sequence.charAt(0);
|
|
1638
|
+
const next = items[index + 1];
|
|
1639
|
+
const outsideBefore = previous2;
|
|
1640
|
+
const outsideAfter = firstCharacter(
|
|
1641
|
+
next === void 0 ? after : typeof next === "string" ? next : chosen.get(next) || next.sequences[0]
|
|
1642
|
+
);
|
|
1643
|
+
const inside = render(item.children, chosen, sequence, sequence);
|
|
1644
|
+
const head = inside[0].value;
|
|
1645
|
+
const open = encodeInfo(
|
|
1646
|
+
outsideBefore.charCodeAt(outsideBefore.length - 1),
|
|
1647
|
+
head.charCodeAt(0),
|
|
1648
|
+
marker
|
|
1649
|
+
);
|
|
1650
|
+
if (open.inside) encode(inside, true);
|
|
1651
|
+
const tail = lastCharacter(inside[inside.length - 1].value);
|
|
1652
|
+
const close = encodeInfo(
|
|
1653
|
+
outsideAfter.charCodeAt(0),
|
|
1654
|
+
tail.charCodeAt(tail.length - 1),
|
|
1655
|
+
marker
|
|
1656
|
+
);
|
|
1657
|
+
if (close.inside) encode(inside, false);
|
|
1658
|
+
if (open.outside && outsideBefore !== "\n" && outsideBefore !== "\r") {
|
|
1659
|
+
encode(tokens, false);
|
|
1660
|
+
}
|
|
1661
|
+
if (close.outside) encodeAfter = outsideAfter;
|
|
1662
|
+
tokens.push({ value: sequence, attention: item }, ...inside, {
|
|
1663
|
+
value: sequence,
|
|
1664
|
+
attention: item
|
|
1665
|
+
});
|
|
1666
|
+
previous2 = sequence.charAt(sequence.length - 1);
|
|
1667
|
+
}
|
|
1668
|
+
return tokens;
|
|
1669
|
+
}
|
|
1670
|
+
__name(render, "render");
|
|
1671
|
+
function serialize2(items, before, after) {
|
|
1672
|
+
const guessed = /* @__PURE__ */ new Map();
|
|
1673
|
+
guess(items, guessed, before, after);
|
|
1674
|
+
const tokens = (
|
|
1675
|
+
// Start from guesses (based on the preferred sequences).
|
|
1676
|
+
(guessed.size > 0 ? fix(items, guessed, before, after) : void 0) || // If stuck, start from the preferred sequences instead.
|
|
1677
|
+
fix(items, /* @__PURE__ */ new Map(), before, after) || // If stuck again, use the preferred sequences as they are.
|
|
1678
|
+
render(items, /* @__PURE__ */ new Map(), before, after)
|
|
1679
|
+
);
|
|
1680
|
+
let result = "";
|
|
1681
|
+
for (const token of tokens) result += token.value;
|
|
1682
|
+
return result;
|
|
1683
|
+
}
|
|
1684
|
+
__name(serialize2, "serialize");
|
|
1685
|
+
|
|
1686
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/handle/emphasis.js
|
|
1687
|
+
emphasis.attention = attention;
|
|
1688
|
+
emphasis.peek = peek;
|
|
1689
|
+
function emphasis(node, _, state, info) {
|
|
1690
|
+
const exit2 = state.enter("phrasing");
|
|
1691
|
+
const item = attentionItem(node, attention, state, state.createTracker(info));
|
|
1692
|
+
const value = item ? serialize2([item], info.before, info.after) : "";
|
|
1693
|
+
exit2();
|
|
1694
|
+
return value;
|
|
1695
|
+
}
|
|
1696
|
+
__name(emphasis, "emphasis");
|
|
1697
|
+
function attention(_, state) {
|
|
1698
|
+
const marker = checkEmphasis(state);
|
|
1699
|
+
return {
|
|
1700
|
+
construct: "emphasis",
|
|
1701
|
+
markers: marker === "*" ? ["*", "_"] : ["_", "*"],
|
|
1702
|
+
sizes: [1]
|
|
1703
|
+
};
|
|
1704
|
+
}
|
|
1705
|
+
__name(attention, "attention");
|
|
1706
|
+
function peek(_, _1, state) {
|
|
1707
|
+
return state.options.emphasis || "*";
|
|
1708
|
+
}
|
|
1709
|
+
__name(peek, "peek");
|
|
1710
|
+
|
|
1711
|
+
// node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.js
|
|
1712
|
+
function visit(tree, testOrEnterOrVisitors, enterOrVisitorsOrReverse, maybeReverse) {
|
|
1713
|
+
let check2;
|
|
1714
|
+
let visitors;
|
|
1715
|
+
let reverse;
|
|
1716
|
+
if (typeof enterOrVisitorsOrReverse === "function" || enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === "object") {
|
|
1717
|
+
check2 = /** @type {Test} */
|
|
1718
|
+
testOrEnterOrVisitors;
|
|
1719
|
+
visitors = enterOrVisitorsOrReverse;
|
|
1720
|
+
reverse = maybeReverse;
|
|
1721
|
+
} else {
|
|
1722
|
+
visitors = /** @type {Visitor | Visitors} */
|
|
1723
|
+
testOrEnterOrVisitors;
|
|
1724
|
+
reverse = enterOrVisitorsOrReverse;
|
|
1725
|
+
}
|
|
1726
|
+
if (typeof visitors === "function") {
|
|
1727
|
+
visitParents(tree, check2, wrap(visitors), reverse);
|
|
1728
|
+
} else {
|
|
1729
|
+
visitParents(tree, check2, wrapVisitors(visitors), reverse);
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
__name(visit, "visit");
|
|
1733
|
+
function wrapVisitors(visitors) {
|
|
1734
|
+
if (!visitors || typeof visitors !== "object") return visitors;
|
|
1735
|
+
return {
|
|
1736
|
+
enter: typeof visitors.enter === "function" ? wrap(visitors.enter) : visitors.enter,
|
|
1737
|
+
exit: typeof visitors.exit === "function" ? wrap(visitors.exit) : visitors.exit
|
|
1738
|
+
};
|
|
1739
|
+
}
|
|
1740
|
+
__name(wrapVisitors, "wrapVisitors");
|
|
1741
|
+
function wrap(visitor) {
|
|
1742
|
+
return overload;
|
|
1743
|
+
function overload(node, parents, index) {
|
|
1744
|
+
return visitor(node, index, parents[parents.length - 1]);
|
|
1745
|
+
}
|
|
1746
|
+
__name(overload, "overload");
|
|
1747
|
+
}
|
|
1748
|
+
__name(wrap, "wrap");
|
|
1749
|
+
|
|
1750
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.js
|
|
1751
|
+
function formatHeadingAsSetext(node, state) {
|
|
1752
|
+
let literalWithBreak = false;
|
|
1753
|
+
visit(node, function(node2) {
|
|
1754
|
+
if ("value" in node2 && /\r?\n|\r/.test(node2.value) || node2.type === "break") {
|
|
1755
|
+
literalWithBreak = true;
|
|
1756
|
+
return EXIT;
|
|
1757
|
+
}
|
|
1758
|
+
});
|
|
1759
|
+
return Boolean(
|
|
1760
|
+
(!node.depth || node.depth < 3) && toString(node) && (state.options.setext || literalWithBreak)
|
|
1761
|
+
);
|
|
1762
|
+
}
|
|
1763
|
+
__name(formatHeadingAsSetext, "formatHeadingAsSetext");
|
|
1764
|
+
|
|
1765
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/handle/heading.js
|
|
1766
|
+
function heading(node, _, state, info) {
|
|
1767
|
+
const rank = Math.max(Math.min(6, node.depth || 1), 1);
|
|
1768
|
+
const tracker = state.createTracker(info);
|
|
1769
|
+
if (formatHeadingAsSetext(node, state)) {
|
|
1770
|
+
const exit3 = state.enter("headingSetext");
|
|
1771
|
+
const subexit2 = state.enter("phrasing");
|
|
1772
|
+
const value2 = state.containerPhrasing(node, {
|
|
1773
|
+
...tracker.current(),
|
|
1774
|
+
before: "\n",
|
|
1775
|
+
after: "\n"
|
|
1776
|
+
});
|
|
1777
|
+
subexit2();
|
|
1778
|
+
exit3();
|
|
1779
|
+
return value2 + "\n" + (rank === 1 ? "=" : "-").repeat(
|
|
1780
|
+
// The whole size…
|
|
1781
|
+
value2.length - // Minus the position of the character after the last EOL (or
|
|
1782
|
+
// 0 if there is none)…
|
|
1783
|
+
(Math.max(value2.lastIndexOf("\r"), value2.lastIndexOf("\n")) + 1)
|
|
1784
|
+
);
|
|
1785
|
+
}
|
|
1786
|
+
const sequence = "#".repeat(rank);
|
|
1787
|
+
const exit2 = state.enter("headingAtx");
|
|
1788
|
+
const subexit = state.enter("phrasing");
|
|
1789
|
+
tracker.move(sequence + " ");
|
|
1790
|
+
let value = state.containerPhrasing(node, {
|
|
1791
|
+
before: "# ",
|
|
1792
|
+
after: "\n",
|
|
1793
|
+
...tracker.current()
|
|
1794
|
+
});
|
|
1795
|
+
const head = value.charCodeAt(0);
|
|
1796
|
+
if (head === 9 || head === 32) {
|
|
1797
|
+
value = encodeCharacterReference(head) + value.slice(1);
|
|
1798
|
+
}
|
|
1799
|
+
value = value ? sequence + " " + value : sequence;
|
|
1800
|
+
if (state.options.closeAtx) {
|
|
1801
|
+
value += " " + sequence;
|
|
1802
|
+
}
|
|
1803
|
+
subexit();
|
|
1804
|
+
exit2();
|
|
1805
|
+
return value;
|
|
1806
|
+
}
|
|
1807
|
+
__name(heading, "heading");
|
|
1808
|
+
|
|
1809
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/handle/html.js
|
|
1810
|
+
html.peek = htmlPeek;
|
|
1811
|
+
function html(node) {
|
|
1812
|
+
return node.value || "";
|
|
1813
|
+
}
|
|
1814
|
+
__name(html, "html");
|
|
1815
|
+
function htmlPeek() {
|
|
1816
|
+
return "<";
|
|
1817
|
+
}
|
|
1818
|
+
__name(htmlPeek, "htmlPeek");
|
|
1819
|
+
|
|
1820
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/handle/image.js
|
|
1821
|
+
image.peek = imagePeek;
|
|
1822
|
+
function image(node, _, state, info) {
|
|
1823
|
+
const quote = checkQuote(state);
|
|
1824
|
+
const suffix = quote === '"' ? "Quote" : "Apostrophe";
|
|
1825
|
+
const exit2 = state.enter("image");
|
|
1826
|
+
let subexit = state.enter("label");
|
|
1827
|
+
const tracker = state.createTracker(info);
|
|
1828
|
+
let value = tracker.move("![");
|
|
1829
|
+
value += tracker.move(
|
|
1830
|
+
state.safe(node.alt, { before: value, after: "]", ...tracker.current() })
|
|
1831
|
+
);
|
|
1832
|
+
value += tracker.move("](");
|
|
1833
|
+
subexit();
|
|
1834
|
+
if (
|
|
1835
|
+
// If there’s no url but there is a title…
|
|
1836
|
+
!node.url && node.title || // If there are control characters or whitespace.
|
|
1837
|
+
/[\0- \u007F]/.test(node.url)
|
|
1838
|
+
) {
|
|
1839
|
+
subexit = state.enter("destinationLiteral");
|
|
1840
|
+
value += tracker.move("<");
|
|
1841
|
+
value += tracker.move(
|
|
1842
|
+
state.safe(node.url, { before: value, after: ">", ...tracker.current() })
|
|
1843
|
+
);
|
|
1844
|
+
value += tracker.move(">");
|
|
1845
|
+
} else {
|
|
1846
|
+
subexit = state.enter("destinationRaw");
|
|
1847
|
+
value += tracker.move(
|
|
1848
|
+
state.safe(node.url, {
|
|
1849
|
+
before: value,
|
|
1850
|
+
after: node.title ? " " : ")",
|
|
1851
|
+
...tracker.current()
|
|
1852
|
+
})
|
|
1853
|
+
);
|
|
1854
|
+
}
|
|
1855
|
+
subexit();
|
|
1856
|
+
if (node.title) {
|
|
1857
|
+
subexit = state.enter(`title${suffix}`);
|
|
1858
|
+
value += tracker.move(" " + quote);
|
|
1859
|
+
value += tracker.move(
|
|
1860
|
+
state.safe(node.title, {
|
|
1861
|
+
before: value,
|
|
1862
|
+
after: quote,
|
|
1863
|
+
...tracker.current()
|
|
1864
|
+
})
|
|
1865
|
+
);
|
|
1866
|
+
value += tracker.move(quote);
|
|
1867
|
+
subexit();
|
|
1868
|
+
}
|
|
1869
|
+
value += tracker.move(")");
|
|
1870
|
+
exit2();
|
|
1871
|
+
return value;
|
|
1872
|
+
}
|
|
1873
|
+
__name(image, "image");
|
|
1874
|
+
function imagePeek() {
|
|
1875
|
+
return "!";
|
|
1876
|
+
}
|
|
1877
|
+
__name(imagePeek, "imagePeek");
|
|
1878
|
+
|
|
1879
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/handle/image-reference.js
|
|
1880
|
+
imageReference.peek = imageReferencePeek;
|
|
1881
|
+
function imageReference(node, _, state, info) {
|
|
1882
|
+
const type = node.referenceType;
|
|
1883
|
+
const exit2 = state.enter("imageReference");
|
|
1884
|
+
let subexit = state.enter("label");
|
|
1885
|
+
const tracker = state.createTracker(info);
|
|
1886
|
+
let value = tracker.move("![");
|
|
1887
|
+
const alt = state.safe(node.alt, {
|
|
1888
|
+
before: value,
|
|
1889
|
+
after: "]",
|
|
1890
|
+
...tracker.current()
|
|
1891
|
+
});
|
|
1892
|
+
value += tracker.move(alt + "][");
|
|
1893
|
+
subexit();
|
|
1894
|
+
const stack = state.stack;
|
|
1895
|
+
state.stack = stack.filter(function(d) {
|
|
1896
|
+
return d !== "phrasing";
|
|
1897
|
+
});
|
|
1898
|
+
subexit = state.enter("reference");
|
|
1899
|
+
const reference = state.safe(state.associationId(node), {
|
|
1900
|
+
before: value,
|
|
1901
|
+
after: "]",
|
|
1902
|
+
...tracker.current()
|
|
1903
|
+
});
|
|
1904
|
+
subexit();
|
|
1905
|
+
state.stack = stack;
|
|
1906
|
+
exit2();
|
|
1907
|
+
if (type === "full" || !alt || alt !== reference) {
|
|
1908
|
+
value += tracker.move(reference + "]");
|
|
1909
|
+
} else if (type === "shortcut") {
|
|
1910
|
+
value = value.slice(0, -1);
|
|
1911
|
+
} else {
|
|
1912
|
+
value += tracker.move("]");
|
|
1913
|
+
}
|
|
1914
|
+
return value;
|
|
1915
|
+
}
|
|
1916
|
+
__name(imageReference, "imageReference");
|
|
1917
|
+
function imageReferencePeek() {
|
|
1918
|
+
return "!";
|
|
1919
|
+
}
|
|
1920
|
+
__name(imageReferencePeek, "imageReferencePeek");
|
|
1921
|
+
|
|
1922
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/handle/inline-code.js
|
|
1923
|
+
inlineCode.peek = inlineCodePeek;
|
|
1924
|
+
function inlineCode(node, _, state) {
|
|
1925
|
+
let value = node.value || "";
|
|
1926
|
+
let sequence = "`";
|
|
1927
|
+
let index = -1;
|
|
1928
|
+
while (new RegExp("(^|[^`])" + sequence + "([^`]|$)").test(value)) {
|
|
1929
|
+
sequence += "`";
|
|
1930
|
+
}
|
|
1931
|
+
if (/[^\n\r ]/.test(value) && (/^[\n\r ]/.test(value) && /[\n\r ]$/.test(value) || /^`|`$/.test(value))) {
|
|
1932
|
+
value = " " + value + " ";
|
|
1933
|
+
}
|
|
1934
|
+
while (++index < state.unsafe.length) {
|
|
1935
|
+
const pattern = state.unsafe[index];
|
|
1936
|
+
const expression = state.compilePattern(pattern);
|
|
1937
|
+
if (!pattern.atBreak) continue;
|
|
1938
|
+
let match;
|
|
1939
|
+
while (match = expression.exec(value)) {
|
|
1940
|
+
let position = match.index;
|
|
1941
|
+
if (value.charCodeAt(position) === 10 && value.charCodeAt(position - 1) === 13) {
|
|
1942
|
+
position--;
|
|
1943
|
+
}
|
|
1944
|
+
value = value.slice(0, position) + " " + value.slice(match.index + 1);
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
return sequence + value + sequence;
|
|
1948
|
+
}
|
|
1949
|
+
__name(inlineCode, "inlineCode");
|
|
1950
|
+
function inlineCodePeek() {
|
|
1951
|
+
return "`";
|
|
1952
|
+
}
|
|
1953
|
+
__name(inlineCodePeek, "inlineCodePeek");
|
|
1954
|
+
|
|
1955
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/util/format-link-as-autolink.js
|
|
1956
|
+
function formatLinkAsAutolink(node, state) {
|
|
1957
|
+
const raw = toString(node);
|
|
1958
|
+
return Boolean(
|
|
1959
|
+
!state.options.resourceLink && // If there’s a url…
|
|
1960
|
+
node.url && // And there’s no title…
|
|
1961
|
+
!node.title && // And the content of `node` is a single text node…
|
|
1962
|
+
node.children && node.children.length === 1 && node.children[0].type === "text" && // And if the url is the same as the content…
|
|
1963
|
+
(raw === node.url || "mailto:" + raw === node.url) && // And that starts w/ a protocol…
|
|
1964
|
+
/^[a-z][+\-.a-z]+:/i.test(node.url) && // And that doesn’t contain ASCII control codes (character escapes and
|
|
1965
|
+
// references don’t work), space, or angle brackets…
|
|
1966
|
+
!/[\0- <>\u007F]/.test(node.url)
|
|
1967
|
+
);
|
|
1968
|
+
}
|
|
1969
|
+
__name(formatLinkAsAutolink, "formatLinkAsAutolink");
|
|
1970
|
+
|
|
1971
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/handle/link.js
|
|
1972
|
+
link.peek = linkPeek;
|
|
1973
|
+
function link(node, _, state, info) {
|
|
1974
|
+
const quote = checkQuote(state);
|
|
1975
|
+
const suffix = quote === '"' ? "Quote" : "Apostrophe";
|
|
1976
|
+
const tracker = state.createTracker(info);
|
|
1977
|
+
if (formatLinkAsAutolink(node, state)) {
|
|
1978
|
+
const stack = state.stack;
|
|
1979
|
+
state.stack = stack.filter(function(d) {
|
|
1980
|
+
return d !== "phrasing";
|
|
1981
|
+
});
|
|
1982
|
+
const exit3 = state.enter("autolink");
|
|
1983
|
+
let value2 = tracker.move("<");
|
|
1984
|
+
value2 += tracker.move(
|
|
1985
|
+
state.containerPhrasing(node, {
|
|
1986
|
+
before: value2,
|
|
1987
|
+
after: ">",
|
|
1988
|
+
...tracker.current()
|
|
1989
|
+
})
|
|
1990
|
+
);
|
|
1991
|
+
value2 += tracker.move(">");
|
|
1992
|
+
exit3();
|
|
1993
|
+
state.stack = stack;
|
|
1994
|
+
return value2;
|
|
1995
|
+
}
|
|
1996
|
+
const exit2 = state.enter("link");
|
|
1997
|
+
let subexit = state.enter("label");
|
|
1998
|
+
let value = tracker.move("[");
|
|
1999
|
+
const text2 = state.containerPhrasing(node, {
|
|
2000
|
+
before: value,
|
|
2001
|
+
after: "](",
|
|
2002
|
+
...tracker.current()
|
|
2003
|
+
});
|
|
2004
|
+
value += tracker.move(text2);
|
|
2005
|
+
subexit();
|
|
2006
|
+
value += tracker.move("](");
|
|
2007
|
+
const enclose = /[\0- \u007F]/.test(node.url);
|
|
2008
|
+
const last = info.before.charAt(info.before.length - 1);
|
|
2009
|
+
let title = node.title || void 0;
|
|
2010
|
+
if (!title && !enclose && (last === "\n" || last === "\r")) {
|
|
2011
|
+
let index = 0;
|
|
2012
|
+
while (index < text2.length && text2.charCodeAt(index) !== 93) {
|
|
2013
|
+
index += text2.charCodeAt(index) === 92 ? 2 : 1;
|
|
2014
|
+
}
|
|
2015
|
+
if (text2.charCodeAt(index + 1) === 58) title = "";
|
|
2016
|
+
}
|
|
2017
|
+
if (
|
|
2018
|
+
// If there’s no url but there is a title…
|
|
2019
|
+
!node.url && typeof title === "string" || // If there are control characters or whitespace.
|
|
2020
|
+
enclose
|
|
2021
|
+
) {
|
|
2022
|
+
subexit = state.enter("destinationLiteral");
|
|
2023
|
+
value += tracker.move("<");
|
|
2024
|
+
value += tracker.move(
|
|
2025
|
+
state.safe(node.url, { before: value, after: ">", ...tracker.current() })
|
|
2026
|
+
);
|
|
2027
|
+
value += tracker.move(">");
|
|
2028
|
+
} else {
|
|
2029
|
+
subexit = state.enter("destinationRaw");
|
|
2030
|
+
value += tracker.move(
|
|
2031
|
+
state.safe(node.url, {
|
|
2032
|
+
before: value,
|
|
2033
|
+
after: typeof title === "string" ? " " : ")",
|
|
2034
|
+
...tracker.current()
|
|
2035
|
+
})
|
|
2036
|
+
);
|
|
2037
|
+
}
|
|
2038
|
+
subexit();
|
|
2039
|
+
if (typeof title === "string") {
|
|
2040
|
+
subexit = state.enter(`title${suffix}`);
|
|
2041
|
+
value += tracker.move(" " + quote);
|
|
2042
|
+
value += tracker.move(
|
|
2043
|
+
state.safe(title, {
|
|
2044
|
+
before: value,
|
|
2045
|
+
after: quote,
|
|
2046
|
+
...tracker.current()
|
|
2047
|
+
})
|
|
2048
|
+
);
|
|
2049
|
+
value += tracker.move(quote);
|
|
2050
|
+
subexit();
|
|
2051
|
+
}
|
|
2052
|
+
value += tracker.move(")");
|
|
2053
|
+
exit2();
|
|
2054
|
+
return value;
|
|
2055
|
+
}
|
|
2056
|
+
__name(link, "link");
|
|
2057
|
+
function linkPeek(node, _, state) {
|
|
2058
|
+
return formatLinkAsAutolink(node, state) ? "<" : "[";
|
|
2059
|
+
}
|
|
2060
|
+
__name(linkPeek, "linkPeek");
|
|
2061
|
+
|
|
2062
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/handle/link-reference.js
|
|
2063
|
+
linkReference.peek = linkReferencePeek;
|
|
2064
|
+
function linkReference(node, _, state, info) {
|
|
2065
|
+
const type = node.referenceType;
|
|
2066
|
+
const exit2 = state.enter("linkReference");
|
|
2067
|
+
let subexit = state.enter("label");
|
|
2068
|
+
const tracker = state.createTracker(info);
|
|
2069
|
+
let value = tracker.move("[");
|
|
2070
|
+
const text2 = state.containerPhrasing(node, {
|
|
2071
|
+
before: value,
|
|
2072
|
+
after: "]",
|
|
2073
|
+
...tracker.current()
|
|
2074
|
+
});
|
|
2075
|
+
value += tracker.move(text2 + "][");
|
|
2076
|
+
subexit();
|
|
2077
|
+
const stack = state.stack;
|
|
2078
|
+
state.stack = stack.filter(function(d) {
|
|
2079
|
+
return d !== "phrasing";
|
|
2080
|
+
});
|
|
2081
|
+
subexit = state.enter("reference");
|
|
2082
|
+
const reference = state.safe(state.associationId(node), {
|
|
2083
|
+
before: value,
|
|
2084
|
+
after: "]",
|
|
2085
|
+
...tracker.current()
|
|
2086
|
+
});
|
|
2087
|
+
subexit();
|
|
2088
|
+
state.stack = stack;
|
|
2089
|
+
exit2();
|
|
2090
|
+
if (type === "full" || !text2 || text2 !== reference) {
|
|
2091
|
+
value += tracker.move(reference + "]");
|
|
2092
|
+
} else if (type === "shortcut") {
|
|
2093
|
+
value = value.slice(0, -1);
|
|
2094
|
+
} else {
|
|
2095
|
+
value += tracker.move("]");
|
|
2096
|
+
}
|
|
2097
|
+
return value;
|
|
2098
|
+
}
|
|
2099
|
+
__name(linkReference, "linkReference");
|
|
2100
|
+
function linkReferencePeek() {
|
|
2101
|
+
return "[";
|
|
2102
|
+
}
|
|
2103
|
+
__name(linkReferencePeek, "linkReferencePeek");
|
|
2104
|
+
|
|
2105
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/util/check-bullet.js
|
|
2106
|
+
function checkBullet(state) {
|
|
2107
|
+
const marker = state.options.bullet || "*";
|
|
2108
|
+
if (marker !== "*" && marker !== "+" && marker !== "-") {
|
|
2109
|
+
throw new Error(
|
|
2110
|
+
"Cannot serialize items with `" + marker + "` for `options.bullet`, expected `*`, `+`, or `-`"
|
|
2111
|
+
);
|
|
2112
|
+
}
|
|
2113
|
+
return marker;
|
|
2114
|
+
}
|
|
2115
|
+
__name(checkBullet, "checkBullet");
|
|
2116
|
+
|
|
2117
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/util/check-bullet-other.js
|
|
2118
|
+
function checkBulletOther(state) {
|
|
2119
|
+
const bullet = checkBullet(state);
|
|
2120
|
+
const bulletOther = state.options.bulletOther;
|
|
2121
|
+
if (!bulletOther) {
|
|
2122
|
+
return bullet === "*" ? "-" : "*";
|
|
2123
|
+
}
|
|
2124
|
+
if (bulletOther !== "*" && bulletOther !== "+" && bulletOther !== "-") {
|
|
2125
|
+
throw new Error(
|
|
2126
|
+
"Cannot serialize items with `" + bulletOther + "` for `options.bulletOther`, expected `*`, `+`, or `-`"
|
|
2127
|
+
);
|
|
2128
|
+
}
|
|
2129
|
+
if (bulletOther === bullet) {
|
|
2130
|
+
throw new Error(
|
|
2131
|
+
"Expected `bullet` (`" + bullet + "`) and `bulletOther` (`" + bulletOther + "`) to be different"
|
|
2132
|
+
);
|
|
2133
|
+
}
|
|
2134
|
+
return bulletOther;
|
|
2135
|
+
}
|
|
2136
|
+
__name(checkBulletOther, "checkBulletOther");
|
|
2137
|
+
|
|
2138
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/util/check-bullet-ordered.js
|
|
2139
|
+
function checkBulletOrdered(state) {
|
|
2140
|
+
const marker = state.options.bulletOrdered || ".";
|
|
2141
|
+
if (marker !== "." && marker !== ")") {
|
|
2142
|
+
throw new Error(
|
|
2143
|
+
"Cannot serialize items with `" + marker + "` for `options.bulletOrdered`, expected `.` or `)`"
|
|
2144
|
+
);
|
|
2145
|
+
}
|
|
2146
|
+
return marker;
|
|
2147
|
+
}
|
|
2148
|
+
__name(checkBulletOrdered, "checkBulletOrdered");
|
|
2149
|
+
|
|
2150
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/util/check-rule.js
|
|
2151
|
+
function checkRule(state) {
|
|
2152
|
+
const marker = state.options.rule || "*";
|
|
2153
|
+
if (marker !== "*" && marker !== "-" && marker !== "_") {
|
|
2154
|
+
throw new Error(
|
|
2155
|
+
"Cannot serialize rules with `" + marker + "` for `options.rule`, expected `*`, `-`, or `_`"
|
|
2156
|
+
);
|
|
2157
|
+
}
|
|
2158
|
+
return marker;
|
|
2159
|
+
}
|
|
2160
|
+
__name(checkRule, "checkRule");
|
|
2161
|
+
|
|
2162
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/handle/list.js
|
|
2163
|
+
function list(node, parent, state, info) {
|
|
2164
|
+
const exit2 = state.enter("list");
|
|
2165
|
+
const bulletCurrent = state.bulletCurrent;
|
|
2166
|
+
let bullet = node.ordered ? checkBulletOrdered(state) : checkBullet(state);
|
|
2167
|
+
const bulletOther = node.ordered ? bullet === "." ? ")" : "." : checkBulletOther(state);
|
|
2168
|
+
let useDifferentMarker = parent && state.bulletLastUsed ? bullet === state.bulletLastUsed : false;
|
|
2169
|
+
if (!node.ordered) {
|
|
2170
|
+
const firstListItem = node.children ? node.children[0] : void 0;
|
|
2171
|
+
if (
|
|
2172
|
+
// Bullet could be used as a thematic break marker:
|
|
2173
|
+
(bullet === "*" || bullet === "-") && // Empty first list item:
|
|
2174
|
+
firstListItem && (!firstListItem.children || !firstListItem.children[0]) && // Directly in two other list items:
|
|
2175
|
+
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" && // That are each the first child.
|
|
2176
|
+
state.indexStack[state.indexStack.length - 1] === 0 && state.indexStack[state.indexStack.length - 2] === 0 && state.indexStack[state.indexStack.length - 3] === 0
|
|
2177
|
+
) {
|
|
2178
|
+
useDifferentMarker = true;
|
|
2179
|
+
}
|
|
2180
|
+
if (checkRule(state) === bullet && firstListItem) {
|
|
2181
|
+
let index = -1;
|
|
2182
|
+
while (++index < node.children.length) {
|
|
2183
|
+
const item = node.children[index];
|
|
2184
|
+
if (item && item.type === "listItem" && item.children && item.children[0] && item.children[0].type === "thematicBreak") {
|
|
2185
|
+
useDifferentMarker = true;
|
|
2186
|
+
break;
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
if (useDifferentMarker) {
|
|
2192
|
+
bullet = bulletOther;
|
|
2193
|
+
}
|
|
2194
|
+
state.bulletCurrent = bullet;
|
|
2195
|
+
const value = state.containerFlow(node, info);
|
|
2196
|
+
state.bulletLastUsed = bullet;
|
|
2197
|
+
state.bulletCurrent = bulletCurrent;
|
|
2198
|
+
exit2();
|
|
2199
|
+
return value;
|
|
2200
|
+
}
|
|
2201
|
+
__name(list, "list");
|
|
2202
|
+
|
|
2203
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/util/check-list-item-indent.js
|
|
2204
|
+
function checkListItemIndent(state) {
|
|
2205
|
+
const style = state.options.listItemIndent || "one";
|
|
2206
|
+
if (style !== "tab" && style !== "one" && style !== "mixed") {
|
|
2207
|
+
throw new Error(
|
|
2208
|
+
"Cannot serialize items with `" + style + "` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`"
|
|
2209
|
+
);
|
|
2210
|
+
}
|
|
2211
|
+
return style;
|
|
2212
|
+
}
|
|
2213
|
+
__name(checkListItemIndent, "checkListItemIndent");
|
|
2214
|
+
|
|
2215
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/handle/list-item.js
|
|
2216
|
+
function listItem(node, parent, state, info) {
|
|
2217
|
+
const listItemIndent = checkListItemIndent(state);
|
|
2218
|
+
let bullet = state.bulletCurrent || checkBullet(state);
|
|
2219
|
+
if (parent && parent.type === "list" && parent.ordered) {
|
|
2220
|
+
bullet = (typeof parent.start === "number" && parent.start > -1 ? parent.start : 1) + (state.options.incrementListMarker === false ? 0 : parent.children.indexOf(node)) + bullet;
|
|
2221
|
+
}
|
|
2222
|
+
let size = bullet.length + 1;
|
|
2223
|
+
if (listItemIndent === "tab" || listItemIndent === "mixed" && (parent && parent.type === "list" && parent.spread || node.spread)) {
|
|
2224
|
+
size = Math.ceil(size / 4) * 4;
|
|
2225
|
+
}
|
|
2226
|
+
const tracker = state.createTracker(info);
|
|
2227
|
+
tracker.move(bullet + " ".repeat(size - bullet.length));
|
|
2228
|
+
tracker.shift(size);
|
|
2229
|
+
const exit2 = state.enter("listItem");
|
|
2230
|
+
const value = state.indentLines(
|
|
2231
|
+
state.containerFlow(node, tracker.current()),
|
|
2232
|
+
map3
|
|
2233
|
+
);
|
|
2234
|
+
exit2();
|
|
2235
|
+
return value;
|
|
2236
|
+
function map3(line, index, blank) {
|
|
2237
|
+
if (index) {
|
|
2238
|
+
return (blank ? "" : " ".repeat(size)) + line;
|
|
2239
|
+
}
|
|
2240
|
+
return (blank ? bullet : bullet + " ".repeat(size - bullet.length)) + line;
|
|
2241
|
+
}
|
|
2242
|
+
__name(map3, "map");
|
|
2243
|
+
}
|
|
2244
|
+
__name(listItem, "listItem");
|
|
2245
|
+
|
|
2246
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/handle/paragraph.js
|
|
2247
|
+
function paragraph(node, _, state, info) {
|
|
2248
|
+
const exit2 = state.enter("paragraph");
|
|
2249
|
+
const subexit = state.enter("phrasing");
|
|
2250
|
+
const value = state.containerPhrasing(node, info);
|
|
2251
|
+
subexit();
|
|
2252
|
+
exit2();
|
|
2253
|
+
return value;
|
|
2254
|
+
}
|
|
2255
|
+
__name(paragraph, "paragraph");
|
|
2256
|
+
|
|
2257
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/handle/root.js
|
|
2258
|
+
function root(node, _, state, info) {
|
|
2259
|
+
const hasPhrasing = node.children.some(function(d) {
|
|
2260
|
+
return phrasing(d);
|
|
2261
|
+
});
|
|
2262
|
+
if (!hasPhrasing) return state.containerFlow(node, info);
|
|
2263
|
+
const exit2 = state.enter("phrasing");
|
|
2264
|
+
const value = state.containerPhrasing(node, info);
|
|
2265
|
+
exit2();
|
|
2266
|
+
return value;
|
|
2267
|
+
}
|
|
2268
|
+
__name(root, "root");
|
|
2269
|
+
|
|
2270
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/util/check-strong.js
|
|
2271
|
+
function checkStrong(state) {
|
|
2272
|
+
const marker = state.options.strong || "*";
|
|
2273
|
+
if (marker !== "*" && marker !== "_") {
|
|
2274
|
+
throw new Error(
|
|
2275
|
+
"Cannot serialize strong with `" + marker + "` for `options.strong`, expected `*`, or `_`"
|
|
2276
|
+
);
|
|
2277
|
+
}
|
|
2278
|
+
return marker;
|
|
2279
|
+
}
|
|
2280
|
+
__name(checkStrong, "checkStrong");
|
|
2281
|
+
|
|
2282
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/handle/strong.js
|
|
2283
|
+
strong.attention = attention2;
|
|
2284
|
+
strong.peek = peek2;
|
|
2285
|
+
function strong(node, _, state, info) {
|
|
2286
|
+
const exit2 = state.enter("phrasing");
|
|
2287
|
+
const item = attentionItem(node, attention2, state, state.createTracker(info));
|
|
2288
|
+
const value = item ? serialize2([item], info.before, info.after) : "";
|
|
2289
|
+
exit2();
|
|
2290
|
+
return value;
|
|
2291
|
+
}
|
|
2292
|
+
__name(strong, "strong");
|
|
2293
|
+
function attention2(_, state) {
|
|
2294
|
+
const marker = checkStrong(state);
|
|
2295
|
+
return {
|
|
2296
|
+
construct: "strong",
|
|
2297
|
+
markers: marker === "*" ? ["*", "_"] : ["_", "*"],
|
|
2298
|
+
sizes: [2]
|
|
2299
|
+
};
|
|
2300
|
+
}
|
|
2301
|
+
__name(attention2, "attention");
|
|
2302
|
+
function peek2(_, _1, state) {
|
|
2303
|
+
return state.options.strong || "*";
|
|
2304
|
+
}
|
|
2305
|
+
__name(peek2, "peek");
|
|
2306
|
+
|
|
2307
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/handle/text.js
|
|
2308
|
+
function text(node, parent, state, info) {
|
|
2309
|
+
const siblings = parent ? parent.children : [];
|
|
2310
|
+
const index = state.indexStack[state.indexStack.length - 1];
|
|
2311
|
+
return state.safe(node.value, {
|
|
2312
|
+
...info,
|
|
2313
|
+
afterNode: siblings[index + 1],
|
|
2314
|
+
beforeNode: siblings[index - 1]
|
|
2315
|
+
});
|
|
2316
|
+
}
|
|
2317
|
+
__name(text, "text");
|
|
2318
|
+
|
|
2319
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/util/check-rule-repetition.js
|
|
2320
|
+
function checkRuleRepetition(state) {
|
|
2321
|
+
const repetition = state.options.ruleRepetition || 3;
|
|
2322
|
+
if (repetition < 3) {
|
|
2323
|
+
throw new Error(
|
|
2324
|
+
"Cannot serialize rules with repetition `" + repetition + "` for `options.ruleRepetition`, expected `3` or more"
|
|
2325
|
+
);
|
|
2326
|
+
}
|
|
2327
|
+
return repetition;
|
|
2328
|
+
}
|
|
2329
|
+
__name(checkRuleRepetition, "checkRuleRepetition");
|
|
2330
|
+
|
|
2331
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/handle/thematic-break.js
|
|
2332
|
+
function thematicBreak(_, _1, state) {
|
|
2333
|
+
const value = (checkRule(state) + (state.options.ruleSpaces ? " " : "")).repeat(checkRuleRepetition(state));
|
|
2334
|
+
return state.options.ruleSpaces ? value.slice(0, -1) : value;
|
|
2335
|
+
}
|
|
2336
|
+
__name(thematicBreak, "thematicBreak");
|
|
2337
|
+
|
|
2338
|
+
// node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/handle/index.js
|
|
2339
|
+
var handle = {
|
|
2340
|
+
blockquote,
|
|
2341
|
+
break: hardBreak,
|
|
2342
|
+
code,
|
|
2343
|
+
definition,
|
|
2344
|
+
emphasis,
|
|
2345
|
+
hardBreak,
|
|
2346
|
+
heading,
|
|
2347
|
+
html,
|
|
2348
|
+
image,
|
|
2349
|
+
imageReference,
|
|
2350
|
+
inlineCode,
|
|
2351
|
+
link,
|
|
2352
|
+
linkReference,
|
|
2353
|
+
list,
|
|
2354
|
+
listItem,
|
|
2355
|
+
paragraph,
|
|
2356
|
+
root,
|
|
2357
|
+
strong,
|
|
2358
|
+
text,
|
|
2359
|
+
thematicBreak
|
|
2360
|
+
};
|
|
2361
|
+
|
|
2362
|
+
// node_modules/.pnpm/mdast-util-gfm-table@2.0.1/node_modules/mdast-util-gfm-table/lib/index.js
|
|
2363
|
+
function gfmTableFromMarkdown() {
|
|
2364
|
+
return {
|
|
2365
|
+
enter: {
|
|
2366
|
+
table: enterTable,
|
|
2367
|
+
tableData: enterCell,
|
|
2368
|
+
tableHeader: enterCell,
|
|
2369
|
+
tableRow: enterRow
|
|
2370
|
+
},
|
|
2371
|
+
exit: {
|
|
2372
|
+
codeText: exitCodeText,
|
|
2373
|
+
table: exitTable,
|
|
2374
|
+
tableData: exit,
|
|
2375
|
+
tableHeader: exit,
|
|
2376
|
+
tableRow: exit
|
|
2377
|
+
}
|
|
2378
|
+
};
|
|
2379
|
+
}
|
|
2380
|
+
__name(gfmTableFromMarkdown, "gfmTableFromMarkdown");
|
|
2381
|
+
function enterTable(token) {
|
|
2382
|
+
const align = token._align;
|
|
2383
|
+
ok(align, "expected `_align` on table");
|
|
2384
|
+
this.enter(
|
|
2385
|
+
{
|
|
2386
|
+
type: "table",
|
|
2387
|
+
align: align.map(function(d) {
|
|
2388
|
+
return d === "none" ? null : d;
|
|
2389
|
+
}),
|
|
2390
|
+
children: [],
|
|
2391
|
+
position: void 0
|
|
2392
|
+
},
|
|
2393
|
+
token
|
|
2394
|
+
);
|
|
2395
|
+
this.data.inTable = true;
|
|
2396
|
+
}
|
|
2397
|
+
__name(enterTable, "enterTable");
|
|
2398
|
+
function exitTable(token) {
|
|
2399
|
+
this.exit(token);
|
|
2400
|
+
this.data.inTable = void 0;
|
|
2401
|
+
}
|
|
2402
|
+
__name(exitTable, "exitTable");
|
|
2403
|
+
function enterRow(token) {
|
|
2404
|
+
this.enter({ type: "tableRow", children: [], position: void 0 }, token);
|
|
2405
|
+
}
|
|
2406
|
+
__name(enterRow, "enterRow");
|
|
2407
|
+
function exit(token) {
|
|
2408
|
+
this.exit(token);
|
|
2409
|
+
}
|
|
2410
|
+
__name(exit, "exit");
|
|
2411
|
+
function enterCell(token) {
|
|
2412
|
+
this.enter({ type: "tableCell", children: [], position: void 0 }, token);
|
|
2413
|
+
}
|
|
2414
|
+
__name(enterCell, "enterCell");
|
|
2415
|
+
function exitCodeText(token) {
|
|
2416
|
+
let value = this.resume();
|
|
2417
|
+
if (this.data.inTable) {
|
|
2418
|
+
value = value.replace(/\\([\\|])/g, replace);
|
|
2419
|
+
}
|
|
2420
|
+
const node = this.stack[this.stack.length - 1];
|
|
2421
|
+
ok(node.type === "inlineCode");
|
|
2422
|
+
node.value = value;
|
|
2423
|
+
this.exit(token);
|
|
2424
|
+
}
|
|
2425
|
+
__name(exitCodeText, "exitCodeText");
|
|
2426
|
+
function replace($0, $1) {
|
|
2427
|
+
return $1 === "|" ? $1 : $0;
|
|
2428
|
+
}
|
|
2429
|
+
__name(replace, "replace");
|
|
2430
|
+
function gfmTableToMarkdown(options) {
|
|
2431
|
+
const settings = options || {};
|
|
2432
|
+
const {
|
|
2433
|
+
tableCellPadding: padding,
|
|
2434
|
+
tablePipeAlign: alignDelimiters,
|
|
2435
|
+
stringLength
|
|
2436
|
+
} = settings;
|
|
2437
|
+
const around = padding ? " " : "|";
|
|
2438
|
+
return {
|
|
2439
|
+
handlers: {
|
|
2440
|
+
inlineCode: inlineCodeWithTable,
|
|
2441
|
+
table: handleTable,
|
|
2442
|
+
tableCell: handleTableCell,
|
|
2443
|
+
tableRow: handleTableRow
|
|
2444
|
+
},
|
|
2445
|
+
join: [joinTable],
|
|
2446
|
+
unsafe: [
|
|
2447
|
+
{ character: "\r", inConstruct: "tableCell" },
|
|
2448
|
+
{ character: "\n", inConstruct: "tableCell" },
|
|
2449
|
+
// A pipe, when followed by a tab or space (padding), or a dash or colon
|
|
2450
|
+
// (unpadded delimiter row), could result in a table.
|
|
2451
|
+
{ atBreak: true, character: "|", after: "[ :-]" },
|
|
2452
|
+
// A pipe in a cell must be encoded.
|
|
2453
|
+
{ character: "|", inConstruct: "tableCell" },
|
|
2454
|
+
// A colon must be followed by a dash, in which case it could start a
|
|
2455
|
+
// delimiter row.
|
|
2456
|
+
{ atBreak: true, character: ":", after: "-" },
|
|
2457
|
+
// A delimiter row can also start with a dash, when followed by more
|
|
2458
|
+
// dashes, a colon, or a pipe.
|
|
2459
|
+
// This is a stricter version than the built in check for lists, thematic
|
|
2460
|
+
// breaks, and setex heading underlines though:
|
|
2461
|
+
// <https://github.com/syntax-tree/mdast-util-to-markdown/blob/51a2038/lib/unsafe.js#L57>
|
|
2462
|
+
{ atBreak: true, character: "-", after: "[:|-]" }
|
|
2463
|
+
]
|
|
2464
|
+
};
|
|
2465
|
+
function handleTable(node, _, state, info) {
|
|
2466
|
+
const matrix = handleTableAsData(node, state, info);
|
|
2467
|
+
const head = matrix[0];
|
|
2468
|
+
if (head) {
|
|
2469
|
+
let columns = node.align ? node.align.length : 0;
|
|
2470
|
+
let index = -1;
|
|
2471
|
+
if (!columns) {
|
|
2472
|
+
while (++index < matrix.length) {
|
|
2473
|
+
if (matrix[index].length > columns) columns = matrix[index].length;
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
while (head.length < columns) head.push("");
|
|
2477
|
+
}
|
|
2478
|
+
return serializeData(matrix, node.align);
|
|
2479
|
+
}
|
|
2480
|
+
__name(handleTable, "handleTable");
|
|
2481
|
+
function handleTableRow(node, _, state, info) {
|
|
2482
|
+
const row = handleTableRowAsData(node, state, info);
|
|
2483
|
+
const value = serializeData([row]);
|
|
2484
|
+
return value.slice(0, value.indexOf("\n"));
|
|
2485
|
+
}
|
|
2486
|
+
__name(handleTableRow, "handleTableRow");
|
|
2487
|
+
function handleTableCell(node, _, state, info) {
|
|
2488
|
+
const exit2 = state.enter("tableCell");
|
|
2489
|
+
const subexit = state.enter("phrasing");
|
|
2490
|
+
const value = state.containerPhrasing(node, {
|
|
2491
|
+
...info,
|
|
2492
|
+
before: around,
|
|
2493
|
+
after: around
|
|
2494
|
+
});
|
|
2495
|
+
subexit();
|
|
2496
|
+
exit2();
|
|
2497
|
+
return value;
|
|
2498
|
+
}
|
|
2499
|
+
__name(handleTableCell, "handleTableCell");
|
|
2500
|
+
function serializeData(matrix, align) {
|
|
2501
|
+
return markdownTable(matrix, {
|
|
2502
|
+
align,
|
|
2503
|
+
alignDelimiters,
|
|
2504
|
+
fillRows: false,
|
|
2505
|
+
padding,
|
|
2506
|
+
stringLength
|
|
2507
|
+
});
|
|
2508
|
+
}
|
|
2509
|
+
__name(serializeData, "serializeData");
|
|
2510
|
+
function handleTableAsData(node, state, info) {
|
|
2511
|
+
const { children } = node;
|
|
2512
|
+
let index = -1;
|
|
2513
|
+
const result = [];
|
|
2514
|
+
const subexit = state.enter("table");
|
|
2515
|
+
while (++index < children.length) {
|
|
2516
|
+
result[index] = handleTableRowAsData(children[index], state, info);
|
|
2517
|
+
}
|
|
2518
|
+
subexit();
|
|
2519
|
+
return result;
|
|
2520
|
+
}
|
|
2521
|
+
__name(handleTableAsData, "handleTableAsData");
|
|
2522
|
+
function handleTableRowAsData(node, state, info) {
|
|
2523
|
+
const { children } = node;
|
|
2524
|
+
let index = -1;
|
|
2525
|
+
const result = [];
|
|
2526
|
+
const subexit = state.enter("tableRow");
|
|
2527
|
+
while (++index < children.length) {
|
|
2528
|
+
result[index] = handleTableCell(children[index], node, state, info);
|
|
2529
|
+
}
|
|
2530
|
+
subexit();
|
|
2531
|
+
return result;
|
|
2532
|
+
}
|
|
2533
|
+
__name(handleTableRowAsData, "handleTableRowAsData");
|
|
2534
|
+
function inlineCodeWithTable(node, parent, state) {
|
|
2535
|
+
const value = handle.inlineCode(node, parent, state);
|
|
2536
|
+
if (!state.stack.includes("tableCell")) return value;
|
|
2537
|
+
const result = [];
|
|
2538
|
+
let start = 0;
|
|
2539
|
+
let index = value.indexOf("|");
|
|
2540
|
+
while (index !== -1) {
|
|
2541
|
+
let before = index;
|
|
2542
|
+
while (before > start && value.charCodeAt(before - 1) === 92) {
|
|
2543
|
+
before--;
|
|
2544
|
+
}
|
|
2545
|
+
result.push(value.slice(start, index));
|
|
2546
|
+
if ((index - before) % 2 === 0) result.push("\\");
|
|
2547
|
+
start = index;
|
|
2548
|
+
index = value.indexOf("|", index + 1);
|
|
2549
|
+
}
|
|
2550
|
+
result.push(value.slice(start));
|
|
2551
|
+
return result.join("");
|
|
2552
|
+
}
|
|
2553
|
+
__name(inlineCodeWithTable, "inlineCodeWithTable");
|
|
2554
|
+
}
|
|
2555
|
+
__name(gfmTableToMarkdown, "gfmTableToMarkdown");
|
|
2556
|
+
function joinTable(left, right, parent, state) {
|
|
2557
|
+
if (left.type === "table" && parent.type === "listItem" && parent.spread === false && (right.type === "definition" || right.type === "heading" && formatHeadingAsSetext2(right, state) || right.type === "paragraph" || right.type === "table")) {
|
|
2558
|
+
return 1;
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
__name(joinTable, "joinTable");
|
|
2562
|
+
function formatHeadingAsSetext2(node, state) {
|
|
2563
|
+
let literalWithBreak = false;
|
|
2564
|
+
visit(node, function(node2) {
|
|
2565
|
+
if (node2.type === "break" || "value" in node2 && /\r?\n|\r/.test(node2.value)) {
|
|
2566
|
+
literalWithBreak = true;
|
|
2567
|
+
return EXIT;
|
|
2568
|
+
}
|
|
2569
|
+
});
|
|
2570
|
+
return Boolean(
|
|
2571
|
+
(!node.depth || node.depth < 3) && toString(node) && (state.options.setext || literalWithBreak)
|
|
2572
|
+
);
|
|
2573
|
+
}
|
|
2574
|
+
__name(formatHeadingAsSetext2, "formatHeadingAsSetext");
|
|
2575
|
+
|
|
2576
|
+
// node_modules/.pnpm/mdast-util-gfm-task-list-item@2.0.1/node_modules/mdast-util-gfm-task-list-item/lib/index.js
|
|
2577
|
+
function gfmTaskListItemFromMarkdown() {
|
|
2578
|
+
return {
|
|
2579
|
+
exit: {
|
|
2580
|
+
taskListCheckValueChecked: exitCheck,
|
|
2581
|
+
taskListCheckValueUnchecked: exitCheck,
|
|
2582
|
+
paragraph: exitParagraphWithTaskListItem
|
|
2583
|
+
}
|
|
2584
|
+
};
|
|
2585
|
+
}
|
|
2586
|
+
__name(gfmTaskListItemFromMarkdown, "gfmTaskListItemFromMarkdown");
|
|
2587
|
+
function gfmTaskListItemToMarkdown() {
|
|
2588
|
+
return {
|
|
2589
|
+
handlers: { paragraph: paragraphWithTaskListItem },
|
|
2590
|
+
join: [joinDefinitionsBeforeTaskListItemParagraph]
|
|
2591
|
+
};
|
|
2592
|
+
}
|
|
2593
|
+
__name(gfmTaskListItemToMarkdown, "gfmTaskListItemToMarkdown");
|
|
2594
|
+
function exitCheck(token) {
|
|
2595
|
+
const node = this.stack[this.stack.length - 2];
|
|
2596
|
+
ok(node.type === "listItem");
|
|
2597
|
+
node.checked = token.type === "taskListCheckValueChecked";
|
|
2598
|
+
}
|
|
2599
|
+
__name(exitCheck, "exitCheck");
|
|
2600
|
+
function exitParagraphWithTaskListItem(token) {
|
|
2601
|
+
const parent = this.stack[this.stack.length - 2];
|
|
2602
|
+
if (parent && parent.type === "listItem" && typeof parent.checked === "boolean") {
|
|
2603
|
+
const node = this.stack[this.stack.length - 1];
|
|
2604
|
+
ok(node.type === "paragraph");
|
|
2605
|
+
const head = node.children[0];
|
|
2606
|
+
if (head && head.type === "text") {
|
|
2607
|
+
const siblings = parent.children;
|
|
2608
|
+
let index = -1;
|
|
2609
|
+
let firstParagraph;
|
|
2610
|
+
while (++index < siblings.length) {
|
|
2611
|
+
const sibling = siblings[index];
|
|
2612
|
+
if (sibling.type === "paragraph") {
|
|
2613
|
+
firstParagraph = sibling;
|
|
2614
|
+
break;
|
|
2615
|
+
}
|
|
2616
|
+
}
|
|
2617
|
+
if (firstParagraph === node) {
|
|
2618
|
+
head.value = head.value.slice(1);
|
|
2619
|
+
if (head.value.length === 0) {
|
|
2620
|
+
node.children.shift();
|
|
2621
|
+
} else if (node.position && head.position && typeof head.position.start.offset === "number") {
|
|
2622
|
+
head.position.start.column++;
|
|
2623
|
+
head.position.start.offset++;
|
|
2624
|
+
node.position.start = { ...head.position.start };
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2629
|
+
this.exit(token);
|
|
2630
|
+
}
|
|
2631
|
+
__name(exitParagraphWithTaskListItem, "exitParagraphWithTaskListItem");
|
|
2632
|
+
function paragraphWithTaskListItem(node, parent, state, info) {
|
|
2633
|
+
if (!parent || parent.type !== "listItem" || taskListItemParagraph(parent) !== node) {
|
|
2634
|
+
return handle.paragraph(node, parent, state, info);
|
|
2635
|
+
}
|
|
2636
|
+
const checkbox = "[" + (parent.checked ? "x" : " ") + "] ";
|
|
2637
|
+
const tracker = state.createTracker(info);
|
|
2638
|
+
tracker.move(checkbox);
|
|
2639
|
+
const value = handle.paragraph(
|
|
2640
|
+
node.children.length > 0 ? node : { type: "paragraph", children: [{ type: "text", value: " " }] },
|
|
2641
|
+
parent,
|
|
2642
|
+
state,
|
|
2643
|
+
{ ...info, ...tracker.current() }
|
|
2644
|
+
);
|
|
2645
|
+
return checkbox + value;
|
|
2646
|
+
}
|
|
2647
|
+
__name(paragraphWithTaskListItem, "paragraphWithTaskListItem");
|
|
2648
|
+
function joinDefinitionsBeforeTaskListItemParagraph(left, _, parent) {
|
|
2649
|
+
if (!(left.type === "definition" && parent.type === "listItem")) {
|
|
2650
|
+
return;
|
|
2651
|
+
}
|
|
2652
|
+
const paragraph2 = taskListItemParagraph(parent);
|
|
2653
|
+
if (paragraph2 && parent.children.indexOf(left) < parent.children.indexOf(paragraph2)) {
|
|
2654
|
+
return 0;
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
__name(joinDefinitionsBeforeTaskListItemParagraph, "joinDefinitionsBeforeTaskListItemParagraph");
|
|
2658
|
+
function taskListItemParagraph(node) {
|
|
2659
|
+
if (typeof node.checked !== "boolean") {
|
|
2660
|
+
return;
|
|
2661
|
+
}
|
|
2662
|
+
for (const child of node.children) {
|
|
2663
|
+
if (child.type === "paragraph") {
|
|
2664
|
+
return child;
|
|
2665
|
+
}
|
|
2666
|
+
if (child.type !== "definition") {
|
|
2667
|
+
return;
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
}
|
|
2671
|
+
__name(taskListItemParagraph, "taskListItemParagraph");
|
|
2672
|
+
|
|
2673
|
+
// node_modules/.pnpm/mdast-util-gfm@3.1.0/node_modules/mdast-util-gfm/lib/index.js
|
|
2674
|
+
function gfmFromMarkdown() {
|
|
2675
|
+
return [
|
|
2676
|
+
gfmAutolinkLiteralFromMarkdown(),
|
|
2677
|
+
gfmFootnoteFromMarkdown(),
|
|
2678
|
+
gfmStrikethroughFromMarkdown(),
|
|
2679
|
+
gfmTableFromMarkdown(),
|
|
2680
|
+
gfmTaskListItemFromMarkdown()
|
|
2681
|
+
];
|
|
2682
|
+
}
|
|
2683
|
+
__name(gfmFromMarkdown, "gfmFromMarkdown");
|
|
2684
|
+
function gfmToMarkdown(options) {
|
|
2685
|
+
return {
|
|
2686
|
+
extensions: [
|
|
2687
|
+
gfmAutolinkLiteralToMarkdown(),
|
|
2688
|
+
gfmFootnoteToMarkdown(options),
|
|
2689
|
+
gfmStrikethroughToMarkdown(),
|
|
2690
|
+
gfmTableToMarkdown(options),
|
|
2691
|
+
gfmTaskListItemToMarkdown()
|
|
2692
|
+
]
|
|
2693
|
+
};
|
|
2694
|
+
}
|
|
2695
|
+
__name(gfmToMarkdown, "gfmToMarkdown");
|
|
2696
|
+
export {
|
|
2697
|
+
gfmFromMarkdown,
|
|
2698
|
+
gfmToMarkdown
|
|
2699
|
+
};
|