@harbour-enterprises/superdoc 0.28.0-next.10 → 0.28.0-next.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{PdfViewer-DBL2mtV7.es.js → PdfViewer-CLpN99Rl.es.js} +1 -1
- package/dist/chunks/{PdfViewer-BnsPYL5w.cjs → PdfViewer-CvsrAT4c.cjs} +1 -1
- package/dist/chunks/default-BS6z0SoE-BS6z0SoE.es.js +5 -0
- package/dist/chunks/default-BS6z0SoE-Gl4f7Y7J.cjs +4 -0
- package/dist/chunks/index-CHAKf7mX-C5aFF6Zl.es.js +2213 -0
- package/dist/chunks/index-CHAKf7mX-Dx-DOGGJ.cjs +2213 -0
- package/dist/chunks/{index-B5RApJzM.es.js → index-CNPV5EVY.es.js} +2 -2
- package/dist/chunks/index-CSaZZzfe-BzemjgYL.cjs +264 -0
- package/dist/chunks/index-CSaZZzfe-CSaZZzfe.es.js +265 -0
- package/dist/chunks/index-C_x_N6Uh-DJn8hIEt.es.js +2200 -0
- package/dist/chunks/index-C_x_N6Uh-Db3CUJMX.cjs +2200 -0
- package/dist/chunks/index-Cd3D_8gF-CFhMnajQ.es.js +862 -0
- package/dist/chunks/index-Cd3D_8gF-DKJ_wTu_.cjs +861 -0
- package/dist/chunks/index-CvBqQJbG-CvBqQJbG.es.js +878 -0
- package/dist/chunks/index-CvBqQJbG-Dwm0THD7.cjs +877 -0
- package/dist/chunks/index-DL9bff78-8izww2lB.es.js +845 -0
- package/dist/chunks/index-DL9bff78-Cf4UBVvQ.cjs +845 -0
- package/dist/chunks/index-DRCvimau-Cw339678.es.js +9876 -0
- package/dist/chunks/index-DRCvimau-H4Ck3S9a.cjs +9876 -0
- package/dist/chunks/index-D_sWOSiG-BtDZzJ6I.cjs +588 -0
- package/dist/chunks/index-D_sWOSiG-DE96TaT5.es.js +588 -0
- package/dist/chunks/{index-Bn2uXv1T.cjs → index-sLveeSfi.cjs} +2 -2
- package/dist/chunks/{super-editor.es-BZcjzGbD.es.js → super-editor.es-0SXIzzbj.es.js} +6451 -24107
- package/dist/chunks/{super-editor.es-C2gjIEyc.cjs → super-editor.es-Dy32MdYk.cjs} +6360 -24016
- package/dist/core/types/index.d.ts +6 -6
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-DJPby8Vf.js → converter-DMwo26F4.js} +48 -48
- package/dist/super-editor/chunks/default-BS6z0SoE.js +5 -0
- package/dist/super-editor/chunks/{docx-zipper-BES4h7U3.js → docx-zipper-CuoYR_fZ.js} +1 -1
- package/dist/super-editor/chunks/{editor-DS_Pp30R.js → editor-BQ9mPcm5.js} +3693 -21350
- package/dist/super-editor/chunks/index-CHAKf7mX.js +2213 -0
- package/dist/super-editor/chunks/index-CSaZZzfe.js +265 -0
- package/dist/super-editor/chunks/index-C_x_N6Uh.js +2200 -0
- package/dist/super-editor/chunks/index-Cd3D_8gF.js +862 -0
- package/dist/super-editor/chunks/index-CvBqQJbG.js +878 -0
- package/dist/super-editor/chunks/index-DL9bff78.js +845 -0
- package/dist/super-editor/chunks/index-DRCvimau.js +9876 -0
- package/dist/super-editor/chunks/index-D_sWOSiG.js +588 -0
- package/dist/super-editor/chunks/{toolbar-BrhEM0st.js → toolbar-D59d-aMm.js} +2 -2
- package/dist/super-editor/converter.es.js +2 -2
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/super-editor/src/core/Editor.d.ts +2 -2
- package/dist/super-editor/super-editor/src/extensions/track-changes/permission-helpers.d.ts +6 -6
- package/dist/super-editor/super-editor.es.js +15 -15
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +73959 -73921
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const indexCd3D_8gF = require("./index-Cd3D_8gF-DKJ_wTu_.cjs");
|
|
4
|
+
const own$1 = {}.hasOwnProperty;
|
|
5
|
+
function zwitch(key, options) {
|
|
6
|
+
const settings = options || {};
|
|
7
|
+
function one(value, ...parameters) {
|
|
8
|
+
let fn = one.invalid;
|
|
9
|
+
const handlers = one.handlers;
|
|
10
|
+
if (value && own$1.call(value, key)) {
|
|
11
|
+
const id = String(value[key]);
|
|
12
|
+
fn = own$1.call(handlers, id) ? handlers[id] : one.unknown;
|
|
13
|
+
}
|
|
14
|
+
if (fn) {
|
|
15
|
+
return fn.call(this, value, ...parameters);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
one.handlers = settings.handlers || {};
|
|
19
|
+
one.invalid = settings.invalid;
|
|
20
|
+
one.unknown = settings.unknown;
|
|
21
|
+
return one;
|
|
22
|
+
}
|
|
23
|
+
const own = {}.hasOwnProperty;
|
|
24
|
+
function configure(base, extension) {
|
|
25
|
+
let index = -1;
|
|
26
|
+
let key;
|
|
27
|
+
if (extension.extensions) {
|
|
28
|
+
while (++index < extension.extensions.length) {
|
|
29
|
+
configure(base, extension.extensions[index]);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
for (key in extension) {
|
|
33
|
+
if (own.call(extension, key)) {
|
|
34
|
+
switch (key) {
|
|
35
|
+
case "extensions": {
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
/* c8 ignore next 4 */
|
|
39
|
+
case "unsafe": {
|
|
40
|
+
list(base[key], extension[key]);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case "join": {
|
|
44
|
+
list(base[key], extension[key]);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
case "handlers": {
|
|
48
|
+
map(base[key], extension[key]);
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
default: {
|
|
52
|
+
base.options[key] = extension[key];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return base;
|
|
58
|
+
}
|
|
59
|
+
function list(left, right) {
|
|
60
|
+
if (right) {
|
|
61
|
+
left.push(...right);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function map(left, right) {
|
|
65
|
+
if (right) {
|
|
66
|
+
Object.assign(left, right);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const join = [joinDefaults];
|
|
70
|
+
function joinDefaults(left, right, parent, state) {
|
|
71
|
+
if (right.type === "code" && indexCd3D_8gF.formatCodeAsIndented(right, state) && (left.type === "list" || left.type === right.type && indexCd3D_8gF.formatCodeAsIndented(left, state))) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
if ("spread" in parent && typeof parent.spread === "boolean") {
|
|
75
|
+
if (left.type === "paragraph" && // Two paragraphs.
|
|
76
|
+
(left.type === right.type || right.type === "definition" || // Paragraph followed by a setext heading.
|
|
77
|
+
right.type === "heading" && indexCd3D_8gF.formatHeadingAsSetext(right, state))) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
return parent.spread ? 1 : 0;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const fullPhrasingSpans = [
|
|
84
|
+
"autolink",
|
|
85
|
+
"destinationLiteral",
|
|
86
|
+
"destinationRaw",
|
|
87
|
+
"reference",
|
|
88
|
+
"titleQuote",
|
|
89
|
+
"titleApostrophe"
|
|
90
|
+
];
|
|
91
|
+
const unsafe = [
|
|
92
|
+
{ character: " ", after: "[\\r\\n]", inConstruct: "phrasing" },
|
|
93
|
+
{ character: " ", before: "[\\r\\n]", inConstruct: "phrasing" },
|
|
94
|
+
{
|
|
95
|
+
character: " ",
|
|
96
|
+
inConstruct: ["codeFencedLangGraveAccent", "codeFencedLangTilde"]
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
character: "\r",
|
|
100
|
+
inConstruct: [
|
|
101
|
+
"codeFencedLangGraveAccent",
|
|
102
|
+
"codeFencedLangTilde",
|
|
103
|
+
"codeFencedMetaGraveAccent",
|
|
104
|
+
"codeFencedMetaTilde",
|
|
105
|
+
"destinationLiteral",
|
|
106
|
+
"headingAtx"
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
character: "\n",
|
|
111
|
+
inConstruct: [
|
|
112
|
+
"codeFencedLangGraveAccent",
|
|
113
|
+
"codeFencedLangTilde",
|
|
114
|
+
"codeFencedMetaGraveAccent",
|
|
115
|
+
"codeFencedMetaTilde",
|
|
116
|
+
"destinationLiteral",
|
|
117
|
+
"headingAtx"
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
{ character: " ", after: "[\\r\\n]", inConstruct: "phrasing" },
|
|
121
|
+
{ character: " ", before: "[\\r\\n]", inConstruct: "phrasing" },
|
|
122
|
+
{
|
|
123
|
+
character: " ",
|
|
124
|
+
inConstruct: ["codeFencedLangGraveAccent", "codeFencedLangTilde"]
|
|
125
|
+
},
|
|
126
|
+
// An exclamation mark can start an image, if it is followed by a link or
|
|
127
|
+
// a link reference.
|
|
128
|
+
{
|
|
129
|
+
character: "!",
|
|
130
|
+
after: "\\[",
|
|
131
|
+
inConstruct: "phrasing",
|
|
132
|
+
notInConstruct: fullPhrasingSpans
|
|
133
|
+
},
|
|
134
|
+
// A quote can break out of a title.
|
|
135
|
+
{ character: '"', inConstruct: "titleQuote" },
|
|
136
|
+
// A number sign could start an ATX heading if it starts a line.
|
|
137
|
+
{ atBreak: true, character: "#" },
|
|
138
|
+
{ character: "#", inConstruct: "headingAtx", after: "(?:[\r\n]|$)" },
|
|
139
|
+
// Dollar sign and percentage are not used in markdown.
|
|
140
|
+
// An ampersand could start a character reference.
|
|
141
|
+
{ character: "&", after: "[#A-Za-z]", inConstruct: "phrasing" },
|
|
142
|
+
// An apostrophe can break out of a title.
|
|
143
|
+
{ character: "'", inConstruct: "titleApostrophe" },
|
|
144
|
+
// A left paren could break out of a destination raw.
|
|
145
|
+
{ character: "(", inConstruct: "destinationRaw" },
|
|
146
|
+
// A left paren followed by `]` could make something into a link or image.
|
|
147
|
+
{
|
|
148
|
+
before: "\\]",
|
|
149
|
+
character: "(",
|
|
150
|
+
inConstruct: "phrasing",
|
|
151
|
+
notInConstruct: fullPhrasingSpans
|
|
152
|
+
},
|
|
153
|
+
// A right paren could start a list item or break out of a destination
|
|
154
|
+
// raw.
|
|
155
|
+
{ atBreak: true, before: "\\d+", character: ")" },
|
|
156
|
+
{ character: ")", inConstruct: "destinationRaw" },
|
|
157
|
+
// An asterisk can start thematic breaks, list items, emphasis, strong.
|
|
158
|
+
{ atBreak: true, character: "*", after: "(?:[ \r\n*])" },
|
|
159
|
+
{ character: "*", inConstruct: "phrasing", notInConstruct: fullPhrasingSpans },
|
|
160
|
+
// A plus sign could start a list item.
|
|
161
|
+
{ atBreak: true, character: "+", after: "(?:[ \r\n])" },
|
|
162
|
+
// A dash can start thematic breaks, list items, and setext heading
|
|
163
|
+
// underlines.
|
|
164
|
+
{ atBreak: true, character: "-", after: "(?:[ \r\n-])" },
|
|
165
|
+
// A dot could start a list item.
|
|
166
|
+
{ atBreak: true, before: "\\d+", character: ".", after: "(?:[ \r\n]|$)" },
|
|
167
|
+
// Slash, colon, and semicolon are not used in markdown for constructs.
|
|
168
|
+
// A less than can start html (flow or text) or an autolink.
|
|
169
|
+
// HTML could start with an exclamation mark (declaration, cdata, comment),
|
|
170
|
+
// slash (closing tag), question mark (instruction), or a letter (tag).
|
|
171
|
+
// An autolink also starts with a letter.
|
|
172
|
+
// Finally, it could break out of a destination literal.
|
|
173
|
+
{ atBreak: true, character: "<", after: "[!/?A-Za-z]" },
|
|
174
|
+
{
|
|
175
|
+
character: "<",
|
|
176
|
+
after: "[!/?A-Za-z]",
|
|
177
|
+
inConstruct: "phrasing",
|
|
178
|
+
notInConstruct: fullPhrasingSpans
|
|
179
|
+
},
|
|
180
|
+
{ character: "<", inConstruct: "destinationLiteral" },
|
|
181
|
+
// An equals to can start setext heading underlines.
|
|
182
|
+
{ atBreak: true, character: "=" },
|
|
183
|
+
// A greater than can start block quotes and it can break out of a
|
|
184
|
+
// destination literal.
|
|
185
|
+
{ atBreak: true, character: ">" },
|
|
186
|
+
{ character: ">", inConstruct: "destinationLiteral" },
|
|
187
|
+
// Question mark and at sign are not used in markdown for constructs.
|
|
188
|
+
// A left bracket can start definitions, references, labels,
|
|
189
|
+
{ atBreak: true, character: "[" },
|
|
190
|
+
{ character: "[", inConstruct: "phrasing", notInConstruct: fullPhrasingSpans },
|
|
191
|
+
{ character: "[", inConstruct: ["label", "reference"] },
|
|
192
|
+
// A backslash can start an escape (when followed by punctuation) or a
|
|
193
|
+
// hard break (when followed by an eol).
|
|
194
|
+
// Note: typical escapes are handled in `safe`!
|
|
195
|
+
{ character: "\\", after: "[\\r\\n]", inConstruct: "phrasing" },
|
|
196
|
+
// A right bracket can exit labels.
|
|
197
|
+
{ character: "]", inConstruct: ["label", "reference"] },
|
|
198
|
+
// Caret is not used in markdown for constructs.
|
|
199
|
+
// An underscore can start emphasis, strong, or a thematic break.
|
|
200
|
+
{ atBreak: true, character: "_" },
|
|
201
|
+
{ character: "_", inConstruct: "phrasing", notInConstruct: fullPhrasingSpans },
|
|
202
|
+
// A grave accent can start code (fenced or text), or it can break out of
|
|
203
|
+
// a grave accent code fence.
|
|
204
|
+
{ atBreak: true, character: "`" },
|
|
205
|
+
{
|
|
206
|
+
character: "`",
|
|
207
|
+
inConstruct: ["codeFencedLangGraveAccent", "codeFencedMetaGraveAccent"]
|
|
208
|
+
},
|
|
209
|
+
{ character: "`", inConstruct: "phrasing", notInConstruct: fullPhrasingSpans },
|
|
210
|
+
// Left brace, vertical bar, right brace are not used in markdown for
|
|
211
|
+
// constructs.
|
|
212
|
+
// A tilde can start code (fenced).
|
|
213
|
+
{ atBreak: true, character: "~" }
|
|
214
|
+
];
|
|
215
|
+
const element = document.createElement("i");
|
|
216
|
+
function decodeNamedCharacterReference(value) {
|
|
217
|
+
const characterReference = "&" + value + ";";
|
|
218
|
+
element.innerHTML = characterReference;
|
|
219
|
+
const character = element.textContent;
|
|
220
|
+
if (
|
|
221
|
+
// @ts-expect-error: TypeScript is wrong that `textContent` on elements can
|
|
222
|
+
// yield `null`.
|
|
223
|
+
character.charCodeAt(character.length - 1) === 59 && value !== "semi"
|
|
224
|
+
) {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
return character === characterReference ? false : character;
|
|
228
|
+
}
|
|
229
|
+
function decodeNumericCharacterReference(value, base) {
|
|
230
|
+
const code = Number.parseInt(value, base);
|
|
231
|
+
if (
|
|
232
|
+
// C0 except for HT, LF, FF, CR, space.
|
|
233
|
+
code < 9 || code === 11 || code > 13 && code < 32 || // Control character (DEL) of C0, and C1 controls.
|
|
234
|
+
code > 126 && code < 160 || // Lone high surrogates and low surrogates.
|
|
235
|
+
code > 55295 && code < 57344 || // Noncharacters.
|
|
236
|
+
code > 64975 && code < 65008 || /* eslint-disable no-bitwise */
|
|
237
|
+
(code & 65535) === 65535 || (code & 65535) === 65534 || /* eslint-enable no-bitwise */
|
|
238
|
+
// Out of range
|
|
239
|
+
code > 1114111
|
|
240
|
+
) {
|
|
241
|
+
return "�";
|
|
242
|
+
}
|
|
243
|
+
return String.fromCodePoint(code);
|
|
244
|
+
}
|
|
245
|
+
const characterEscapeOrReference = /\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;
|
|
246
|
+
function decodeString(value) {
|
|
247
|
+
return value.replace(characterEscapeOrReference, decode);
|
|
248
|
+
}
|
|
249
|
+
function decode($0, $1, $2) {
|
|
250
|
+
if ($1) {
|
|
251
|
+
return $1;
|
|
252
|
+
}
|
|
253
|
+
const head = $2.charCodeAt(0);
|
|
254
|
+
if (head === 35) {
|
|
255
|
+
const head2 = $2.charCodeAt(1);
|
|
256
|
+
const hex = head2 === 120 || head2 === 88;
|
|
257
|
+
return decodeNumericCharacterReference($2.slice(hex ? 2 : 1), hex ? 16 : 10);
|
|
258
|
+
}
|
|
259
|
+
return decodeNamedCharacterReference($2) || $0;
|
|
260
|
+
}
|
|
261
|
+
function association(node) {
|
|
262
|
+
if (node.label || !node.identifier) {
|
|
263
|
+
return node.label || "";
|
|
264
|
+
}
|
|
265
|
+
return decodeString(node.identifier);
|
|
266
|
+
}
|
|
267
|
+
function compilePattern(pattern) {
|
|
268
|
+
if (!pattern._compiled) {
|
|
269
|
+
const before = (pattern.atBreak ? "[\\r\\n][\\t ]*" : "") + (pattern.before ? "(?:" + pattern.before + ")" : "");
|
|
270
|
+
pattern._compiled = new RegExp(
|
|
271
|
+
(before ? "(" + before + ")" : "") + (/[|\\{}()[\]^$+*?.-]/.test(pattern.character) ? "\\" : "") + pattern.character + (pattern.after ? "(?:" + pattern.after + ")" : ""),
|
|
272
|
+
"g"
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
return pattern._compiled;
|
|
276
|
+
}
|
|
277
|
+
function containerPhrasing(parent, state, info) {
|
|
278
|
+
const indexStack = state.indexStack;
|
|
279
|
+
const children = parent.children || [];
|
|
280
|
+
const results = [];
|
|
281
|
+
let index = -1;
|
|
282
|
+
let before = info.before;
|
|
283
|
+
let encodeAfter;
|
|
284
|
+
indexStack.push(-1);
|
|
285
|
+
let tracker = state.createTracker(info);
|
|
286
|
+
while (++index < children.length) {
|
|
287
|
+
const child = children[index];
|
|
288
|
+
let after;
|
|
289
|
+
indexStack[indexStack.length - 1] = index;
|
|
290
|
+
if (index + 1 < children.length) {
|
|
291
|
+
let handle2 = state.handle.handlers[children[index + 1].type];
|
|
292
|
+
if (handle2 && handle2.peek) handle2 = handle2.peek;
|
|
293
|
+
after = handle2 ? handle2(children[index + 1], parent, state, {
|
|
294
|
+
before: "",
|
|
295
|
+
after: "",
|
|
296
|
+
...tracker.current()
|
|
297
|
+
}).charAt(0) : "";
|
|
298
|
+
} else {
|
|
299
|
+
after = info.after;
|
|
300
|
+
}
|
|
301
|
+
if (results.length > 0 && (before === "\r" || before === "\n") && child.type === "html") {
|
|
302
|
+
results[results.length - 1] = results[results.length - 1].replace(
|
|
303
|
+
/(\r?\n|\r)$/,
|
|
304
|
+
" "
|
|
305
|
+
);
|
|
306
|
+
before = " ";
|
|
307
|
+
tracker = state.createTracker(info);
|
|
308
|
+
tracker.move(results.join(""));
|
|
309
|
+
}
|
|
310
|
+
let value = state.handle(child, parent, state, {
|
|
311
|
+
...tracker.current(),
|
|
312
|
+
after,
|
|
313
|
+
before
|
|
314
|
+
});
|
|
315
|
+
if (encodeAfter && encodeAfter === value.slice(0, 1)) {
|
|
316
|
+
value = indexCd3D_8gF.encodeCharacterReference(encodeAfter.charCodeAt(0)) + value.slice(1);
|
|
317
|
+
}
|
|
318
|
+
const encodingInfo = state.attentionEncodeSurroundingInfo;
|
|
319
|
+
state.attentionEncodeSurroundingInfo = void 0;
|
|
320
|
+
encodeAfter = void 0;
|
|
321
|
+
if (encodingInfo) {
|
|
322
|
+
if (results.length > 0 && encodingInfo.before && before === results[results.length - 1].slice(-1)) {
|
|
323
|
+
results[results.length - 1] = results[results.length - 1].slice(0, -1) + indexCd3D_8gF.encodeCharacterReference(before.charCodeAt(0));
|
|
324
|
+
}
|
|
325
|
+
if (encodingInfo.after) encodeAfter = after;
|
|
326
|
+
}
|
|
327
|
+
tracker.move(value);
|
|
328
|
+
results.push(value);
|
|
329
|
+
before = value.slice(-1);
|
|
330
|
+
}
|
|
331
|
+
indexStack.pop();
|
|
332
|
+
return results.join("");
|
|
333
|
+
}
|
|
334
|
+
function containerFlow(parent, state, info) {
|
|
335
|
+
const indexStack = state.indexStack;
|
|
336
|
+
const children = parent.children || [];
|
|
337
|
+
const tracker = state.createTracker(info);
|
|
338
|
+
const results = [];
|
|
339
|
+
let index = -1;
|
|
340
|
+
indexStack.push(-1);
|
|
341
|
+
while (++index < children.length) {
|
|
342
|
+
const child = children[index];
|
|
343
|
+
indexStack[indexStack.length - 1] = index;
|
|
344
|
+
results.push(
|
|
345
|
+
tracker.move(
|
|
346
|
+
state.handle(child, parent, state, {
|
|
347
|
+
before: "\n",
|
|
348
|
+
after: "\n",
|
|
349
|
+
...tracker.current()
|
|
350
|
+
})
|
|
351
|
+
)
|
|
352
|
+
);
|
|
353
|
+
if (child.type !== "list") {
|
|
354
|
+
state.bulletLastUsed = void 0;
|
|
355
|
+
}
|
|
356
|
+
if (index < children.length - 1) {
|
|
357
|
+
results.push(
|
|
358
|
+
tracker.move(between(child, children[index + 1], parent, state))
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
indexStack.pop();
|
|
363
|
+
return results.join("");
|
|
364
|
+
}
|
|
365
|
+
function between(left, right, parent, state) {
|
|
366
|
+
let index = state.join.length;
|
|
367
|
+
while (index--) {
|
|
368
|
+
const result = state.join[index](left, right, parent, state);
|
|
369
|
+
if (result === true || result === 1) {
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
if (typeof result === "number") {
|
|
373
|
+
return "\n".repeat(1 + result);
|
|
374
|
+
}
|
|
375
|
+
if (result === false) {
|
|
376
|
+
return "\n\n<!---->\n\n";
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return "\n\n";
|
|
380
|
+
}
|
|
381
|
+
const eol = /\r?\n|\r/g;
|
|
382
|
+
function indentLines(value, map2) {
|
|
383
|
+
const result = [];
|
|
384
|
+
let start = 0;
|
|
385
|
+
let line = 0;
|
|
386
|
+
let match;
|
|
387
|
+
while (match = eol.exec(value)) {
|
|
388
|
+
one(value.slice(start, match.index));
|
|
389
|
+
result.push(match[0]);
|
|
390
|
+
start = match.index + match[0].length;
|
|
391
|
+
line++;
|
|
392
|
+
}
|
|
393
|
+
one(value.slice(start));
|
|
394
|
+
return result.join("");
|
|
395
|
+
function one(value2) {
|
|
396
|
+
result.push(map2(value2, line, !value2));
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
function safe(state, input, config) {
|
|
400
|
+
const value = (config.before || "") + (input || "") + (config.after || "");
|
|
401
|
+
const positions = [];
|
|
402
|
+
const result = [];
|
|
403
|
+
const infos = {};
|
|
404
|
+
let index = -1;
|
|
405
|
+
while (++index < state.unsafe.length) {
|
|
406
|
+
const pattern = state.unsafe[index];
|
|
407
|
+
if (!indexCd3D_8gF.patternInScope(state.stack, pattern)) {
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
const expression = state.compilePattern(pattern);
|
|
411
|
+
let match;
|
|
412
|
+
while (match = expression.exec(value)) {
|
|
413
|
+
const before = "before" in pattern || Boolean(pattern.atBreak);
|
|
414
|
+
const after = "after" in pattern;
|
|
415
|
+
const position = match.index + (before ? match[1].length : 0);
|
|
416
|
+
if (positions.includes(position)) {
|
|
417
|
+
if (infos[position].before && !before) {
|
|
418
|
+
infos[position].before = false;
|
|
419
|
+
}
|
|
420
|
+
if (infos[position].after && !after) {
|
|
421
|
+
infos[position].after = false;
|
|
422
|
+
}
|
|
423
|
+
} else {
|
|
424
|
+
positions.push(position);
|
|
425
|
+
infos[position] = { before, after };
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
positions.sort(numerical);
|
|
430
|
+
let start = config.before ? config.before.length : 0;
|
|
431
|
+
const end = value.length - (config.after ? config.after.length : 0);
|
|
432
|
+
index = -1;
|
|
433
|
+
while (++index < positions.length) {
|
|
434
|
+
const position = positions[index];
|
|
435
|
+
if (position < start || position >= end) {
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
if (position + 1 < end && positions[index + 1] === position + 1 && infos[position].after && !infos[position + 1].before && !infos[position + 1].after || positions[index - 1] === position - 1 && infos[position].before && !infos[position - 1].before && !infos[position - 1].after) {
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
if (start !== position) {
|
|
442
|
+
result.push(escapeBackslashes(value.slice(start, position), "\\"));
|
|
443
|
+
}
|
|
444
|
+
start = position;
|
|
445
|
+
if (/[!-/:-@[-`{-~]/.test(value.charAt(position)) && (!config.encode || !config.encode.includes(value.charAt(position)))) {
|
|
446
|
+
result.push("\\");
|
|
447
|
+
} else {
|
|
448
|
+
result.push(indexCd3D_8gF.encodeCharacterReference(value.charCodeAt(position)));
|
|
449
|
+
start++;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
result.push(escapeBackslashes(value.slice(start, end), config.after));
|
|
453
|
+
return result.join("");
|
|
454
|
+
}
|
|
455
|
+
function numerical(a, b) {
|
|
456
|
+
return a - b;
|
|
457
|
+
}
|
|
458
|
+
function escapeBackslashes(value, after) {
|
|
459
|
+
const expression = /\\(?=[!-/:-@[-`{-~])/g;
|
|
460
|
+
const positions = [];
|
|
461
|
+
const results = [];
|
|
462
|
+
const whole = value + after;
|
|
463
|
+
let index = -1;
|
|
464
|
+
let start = 0;
|
|
465
|
+
let match;
|
|
466
|
+
while (match = expression.exec(whole)) {
|
|
467
|
+
positions.push(match.index);
|
|
468
|
+
}
|
|
469
|
+
while (++index < positions.length) {
|
|
470
|
+
if (start !== positions[index]) {
|
|
471
|
+
results.push(value.slice(start, positions[index]));
|
|
472
|
+
}
|
|
473
|
+
results.push("\\");
|
|
474
|
+
start = positions[index];
|
|
475
|
+
}
|
|
476
|
+
results.push(value.slice(start));
|
|
477
|
+
return results.join("");
|
|
478
|
+
}
|
|
479
|
+
function track(config) {
|
|
480
|
+
const options = config || {};
|
|
481
|
+
const now = options.now || {};
|
|
482
|
+
let lineShift = options.lineShift || 0;
|
|
483
|
+
let line = now.line || 1;
|
|
484
|
+
let column = now.column || 1;
|
|
485
|
+
return { move, current, shift };
|
|
486
|
+
function current() {
|
|
487
|
+
return { now: { line, column }, lineShift };
|
|
488
|
+
}
|
|
489
|
+
function shift(value) {
|
|
490
|
+
lineShift += value;
|
|
491
|
+
}
|
|
492
|
+
function move(input) {
|
|
493
|
+
const value = input || "";
|
|
494
|
+
const chunks = value.split(/\r?\n|\r/g);
|
|
495
|
+
const tail = chunks[chunks.length - 1];
|
|
496
|
+
line += chunks.length - 1;
|
|
497
|
+
column = chunks.length === 1 ? column + tail.length : 1 + tail.length + lineShift;
|
|
498
|
+
return value;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
function toMarkdown(tree, options) {
|
|
502
|
+
const settings = options || {};
|
|
503
|
+
const state = {
|
|
504
|
+
associationId: association,
|
|
505
|
+
containerPhrasing: containerPhrasingBound,
|
|
506
|
+
containerFlow: containerFlowBound,
|
|
507
|
+
createTracker: track,
|
|
508
|
+
compilePattern,
|
|
509
|
+
enter,
|
|
510
|
+
// @ts-expect-error: GFM / frontmatter are typed in `mdast` but not defined
|
|
511
|
+
// here.
|
|
512
|
+
handlers: { ...indexCd3D_8gF.handle },
|
|
513
|
+
// @ts-expect-error: add `handle` in a second.
|
|
514
|
+
handle: void 0,
|
|
515
|
+
indentLines,
|
|
516
|
+
indexStack: [],
|
|
517
|
+
join: [...join],
|
|
518
|
+
options: {},
|
|
519
|
+
safe: safeBound,
|
|
520
|
+
stack: [],
|
|
521
|
+
unsafe: [...unsafe]
|
|
522
|
+
};
|
|
523
|
+
configure(state, settings);
|
|
524
|
+
if (state.options.tightDefinitions) {
|
|
525
|
+
state.join.push(joinDefinition);
|
|
526
|
+
}
|
|
527
|
+
state.handle = zwitch("type", {
|
|
528
|
+
invalid,
|
|
529
|
+
unknown,
|
|
530
|
+
handlers: state.handlers
|
|
531
|
+
});
|
|
532
|
+
let result = state.handle(tree, void 0, state, {
|
|
533
|
+
before: "\n",
|
|
534
|
+
after: "\n",
|
|
535
|
+
now: { line: 1, column: 1 },
|
|
536
|
+
lineShift: 0
|
|
537
|
+
});
|
|
538
|
+
if (result && result.charCodeAt(result.length - 1) !== 10 && result.charCodeAt(result.length - 1) !== 13) {
|
|
539
|
+
result += "\n";
|
|
540
|
+
}
|
|
541
|
+
return result;
|
|
542
|
+
function enter(name) {
|
|
543
|
+
state.stack.push(name);
|
|
544
|
+
return exit;
|
|
545
|
+
function exit() {
|
|
546
|
+
state.stack.pop();
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
function invalid(value) {
|
|
551
|
+
throw new Error("Cannot handle value `" + value + "`, expected node");
|
|
552
|
+
}
|
|
553
|
+
function unknown(value) {
|
|
554
|
+
const node = (
|
|
555
|
+
/** @type {Nodes} */
|
|
556
|
+
value
|
|
557
|
+
);
|
|
558
|
+
throw new Error("Cannot handle unknown node `" + node.type + "`");
|
|
559
|
+
}
|
|
560
|
+
function joinDefinition(left, right) {
|
|
561
|
+
if (left.type === "definition" && left.type === right.type) {
|
|
562
|
+
return 0;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
function containerPhrasingBound(parent, info) {
|
|
566
|
+
return containerPhrasing(parent, this, info);
|
|
567
|
+
}
|
|
568
|
+
function containerFlowBound(parent, info) {
|
|
569
|
+
return containerFlow(parent, this, info);
|
|
570
|
+
}
|
|
571
|
+
function safeBound(value, config) {
|
|
572
|
+
return safe(this, value, config);
|
|
573
|
+
}
|
|
574
|
+
function remarkStringify(options) {
|
|
575
|
+
const self = this;
|
|
576
|
+
self.compiler = compiler;
|
|
577
|
+
function compiler(tree) {
|
|
578
|
+
return toMarkdown(tree, {
|
|
579
|
+
...self.data("settings"),
|
|
580
|
+
...options,
|
|
581
|
+
// Note: this option is not in the readme.
|
|
582
|
+
// The goal is for it to be set by plugins on `data` instead of being
|
|
583
|
+
// passed by users.
|
|
584
|
+
extensions: self.data("toMarkdownExtensions") || []
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
exports.default = remarkStringify;
|