@bendyline/squisq 2.11.15 → 2.11.17
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/{Doc-C-cv1g4G.d.ts → Doc-CXx1WL8G.d.ts} +28 -3
- package/dist/{ImageEditDoc-3J4PRw8N.d.ts → ImageEditDoc-BVLXI-Zd.d.ts} +1 -1
- package/dist/{annotationCoercion-Ckqpu33y.d.ts → annotationCoercion-BgL52343.d.ts} +1 -1
- package/dist/{chunk-4IQ2DHCI.js → chunk-54RU7TBZ.js} +34 -7
- package/dist/{chunk-C3NAY5YP.js → chunk-A5QJJZ5S.js} +8 -5
- package/dist/{chunk-HVJ6VFDX.js → chunk-GB7OFYUK.js} +4 -0
- package/dist/{chunk-4P557IPH.js → chunk-KNC4ZBQC.js} +5 -5
- package/dist/{chunk-YPI2VJSB.js → chunk-L7IIFWWW.js} +127 -20
- package/dist/{chunk-UVQPK6A3.js → chunk-LJZHC6GN.js} +146 -11
- package/dist/{chunk-GQWIUBJU.js → chunk-MY46W5O5.js} +2 -2
- package/dist/{chunk-HUXK7EOT.js → chunk-PGWYC3S2.js} +93 -4
- package/dist/{chunk-Z35TG4WR.js → chunk-PNXBDMNS.js} +1 -1
- package/dist/{chunk-X7BNDUNI.js → chunk-Q6ELOAOQ.js} +383 -1
- package/dist/{chunk-TMOHAFYE.js → chunk-WSFXV5BT.js} +17 -0
- package/dist/doc/index.d.ts +54 -9
- package/dist/doc/index.js +13 -7
- package/dist/fence/index.d.ts +2 -2
- package/dist/generate/index.d.ts +2 -2
- package/dist/imageEdit/index.d.ts +4 -4
- package/dist/index.d.ts +8 -8
- package/dist/index.js +37 -11
- package/dist/jsonForm/index.d.ts +2 -2
- package/dist/jsonForm/index.js +1 -1
- package/dist/markdown/index.d.ts +171 -5
- package/dist/markdown/index.js +24 -4
- package/dist/{materializePageSection-Dmy_-AUQ.d.ts → materializePageSection-BX1uOAlN.d.ts} +7 -2
- package/dist/mediaEdit/index.d.ts +3 -3
- package/dist/narration/index.d.ts +2 -2
- package/dist/narration/index.js +6 -6
- package/dist/recommend/index.d.ts +1 -1
- package/dist/recommend/index.js +2 -2
- package/dist/schemas/index.d.ts +5 -5
- package/dist/schemas/index.js +1 -1
- package/dist/{themeLibrary-CROfw3YK.d.ts → themeLibrary-Bnq_x-db.d.ts} +1 -1
- package/dist/timing/index.d.ts +2 -2
- package/dist/transform/index.d.ts +3 -3
- package/dist/transform/index.js +6 -6
- package/dist/{types-Be6sBUBx.d.ts → types-C6VvDDL2.d.ts} +5 -1
- package/package.json +1 -1
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
assertMarkdownDocumentWithinLimits,
|
|
3
3
|
parseMarkdown,
|
|
4
4
|
toMdast
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-PGWYC3S2.js";
|
|
6
6
|
import {
|
|
7
7
|
formatFrontmatterYaml,
|
|
8
8
|
getChildren,
|
|
9
9
|
splitFrontmatterBlock,
|
|
10
10
|
stringifyHtmlNodes,
|
|
11
11
|
walkMarkdownTree
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-Q6ELOAOQ.js";
|
|
13
13
|
|
|
14
14
|
// src/markdown/stringify.ts
|
|
15
15
|
import { unified } from "unified";
|
|
@@ -21,17 +21,41 @@ var defaultProcessor;
|
|
|
21
21
|
var DQ_RUN = `"(?:[^"\\\\]|\\\\.)*"`;
|
|
22
22
|
var SQ_RUN = `'(?:[^'\\\\]|\\\\.)*'`;
|
|
23
23
|
var ESCAPED_TEMPLATE_SPAN_RE = new RegExp(
|
|
24
|
-
`\\{\\\\\\[((?:${DQ_RUN}|${SQ_RUN}|\\\\.|[^\\]\\\\])*)\\]\\}`,
|
|
24
|
+
`\\{\\\\\\[((?:${DQ_RUN}|${SQ_RUN}|\\\\.|[^\\]\\\\"'])*)\\]\\}`,
|
|
25
25
|
"g"
|
|
26
26
|
);
|
|
27
27
|
var HEADING_LINE_RE = /^#{1,6} .*$/gm;
|
|
28
28
|
var TRAILING_ESCAPED_PANDOC_SPAN_RE = new RegExp(
|
|
29
|
-
`\\{(?!\\\\?\\[)((?:${DQ_RUN}|${SQ_RUN}|\\\\.|[^}\\\\])*)\\}(?=\\s*(?:\\{\\[.*)?$)`
|
|
29
|
+
`\\{(?!\\\\?\\[)((?:${DQ_RUN}|${SQ_RUN}|\\\\.|[^}\\\\"'])*)\\}(?=\\s*(?:\\{\\[.*)?$)`
|
|
30
30
|
);
|
|
31
31
|
var UNESCAPE_PUNCT_RE = /\\([\\[\]:#.,+=/?;@%$(){}'"-])/g;
|
|
32
32
|
function unescapeMarkdownPunct(text) {
|
|
33
33
|
return text.replace(UNESCAPE_PUNCT_RE, "$1");
|
|
34
34
|
}
|
|
35
|
+
function literalTextUnsafe(options) {
|
|
36
|
+
return [
|
|
37
|
+
// GFM's writer only guards lowercase protocol endings, while its parser
|
|
38
|
+
// recognizes uppercase ones. Escape the colon before the domain dot can
|
|
39
|
+
// become a literal backslash inside an automatically recognized URL.
|
|
40
|
+
...options?.gfm === false ? [] : [
|
|
41
|
+
{
|
|
42
|
+
character: ":",
|
|
43
|
+
before: "[PS]",
|
|
44
|
+
after: "\\/",
|
|
45
|
+
inConstruct: "phrasing",
|
|
46
|
+
notInConstruct: [
|
|
47
|
+
"autolink",
|
|
48
|
+
"link",
|
|
49
|
+
"image",
|
|
50
|
+
"label"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
{ character: "\\", after: "[ ]", inConstruct: "phrasing" },
|
|
55
|
+
...options?.math === false ? [] : [{ character: "$", inConstruct: "phrasing" }],
|
|
56
|
+
...options?.directive === false ? [] : [{ character: ":", after: "[A-Za-z]", inConstruct: "phrasing" }]
|
|
57
|
+
];
|
|
58
|
+
}
|
|
35
59
|
var PREFERRED_MASK_SENTINEL = "\0";
|
|
36
60
|
function pickMaskSentinel(text) {
|
|
37
61
|
const present = new Set(text);
|
|
@@ -154,7 +178,8 @@ function stringifyMarkdown(doc, options) {
|
|
|
154
178
|
strong: "*",
|
|
155
179
|
rule: "-",
|
|
156
180
|
fence: "`",
|
|
157
|
-
setext: false
|
|
181
|
+
setext: false,
|
|
182
|
+
unsafe: literalTextUnsafe()
|
|
158
183
|
});
|
|
159
184
|
}
|
|
160
185
|
processor = defaultProcessor;
|
|
@@ -176,7 +201,8 @@ function stringifyMarkdown(doc, options) {
|
|
|
176
201
|
strong: options?.strong ?? "*",
|
|
177
202
|
rule: options?.rule ?? "-",
|
|
178
203
|
fence: options?.fence ?? "`",
|
|
179
|
-
setext: options?.setext ?? false
|
|
204
|
+
setext: options?.setext ?? false,
|
|
205
|
+
unsafe: literalTextUnsafe(options)
|
|
180
206
|
});
|
|
181
207
|
}
|
|
182
208
|
const result = processor.stringify(mdastTree);
|
|
@@ -1204,11 +1230,22 @@ function rewriteMarkdownReferences(source, options = {}) {
|
|
|
1204
1230
|
|
|
1205
1231
|
// src/markdown/docfxMarkdown.ts
|
|
1206
1232
|
function normalizeDocfxMarkdown(source, options = {}) {
|
|
1207
|
-
|
|
1233
|
+
let output = normalizeDocfxMarkdownPass(source, options);
|
|
1234
|
+
if (options.unknownDirectives === "preserve") {
|
|
1235
|
+
for (let pass = 0; pass < 2 && output !== source && /:::/u.test(output); pass++) {
|
|
1236
|
+
source = output;
|
|
1237
|
+
output = normalizeDocfxMarkdownPass(source, options);
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
return output;
|
|
1241
|
+
}
|
|
1242
|
+
function normalizeDocfxMarkdownPass(source, options = {}) {
|
|
1243
|
+
const { frontmatter, body: originalBody } = splitFrontmatterBlock(source);
|
|
1244
|
+
const body = flattenDocfxLayout(originalBody);
|
|
1208
1245
|
const protectedSpans = [];
|
|
1209
|
-
for (const comment of body.matchAll(/<!--[\s\S]
|
|
1246
|
+
for (const comment of body.matchAll(/<!--[\s\S]*?(?:-->|$)/g))
|
|
1210
1247
|
protectedSpans.push([comment.index, comment.index + comment[0].length]);
|
|
1211
|
-
walkMarkdownTree(parseMarkdown(body, { frontmatter: false }), (node) => {
|
|
1248
|
+
walkMarkdownTree(parseMarkdown(body, { frontmatter: false, directive: false }), (node) => {
|
|
1212
1249
|
if ((node.type === "code" || node.type === "inlineCode") && node.position?.start.offset !== void 0 && node.position.end.offset !== void 0)
|
|
1213
1250
|
protectedSpans.push([node.position.start.offset, node.position.end.offset]);
|
|
1214
1251
|
});
|
|
@@ -1216,8 +1253,8 @@ function normalizeDocfxMarkdown(source, options = {}) {
|
|
|
1216
1253
|
type: "document",
|
|
1217
1254
|
children: [{ type: "paragraph", children: [{ type: "text", value: text }] }]
|
|
1218
1255
|
}).trimEnd();
|
|
1219
|
-
|
|
1220
|
-
/(^[^\S\n]*(?:>\s*)?):::\s*([\w-]+)([^\n]*?)(?=\r?$)|(^[^\S\n]*>\s*)\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION|div)\b([^\]]*)\]|:::\s*(image)\b([^\n]*?):::/gim,
|
|
1256
|
+
let output = body.replace(
|
|
1257
|
+
/(^[^\S\n]*(?:>\s*)?):::\s*([\w-]+)([^\n]*?)(?=\r?$)|(^[^\S\n]*>\s*)\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION|div)\b([^\]]*)\]|:::\s*(image|no-loc)\b([^\n]*?):::/gim,
|
|
1221
1258
|
(match, prefix, name, raw, quote, admonition, _extra, inlineName, inlineRaw, offset) => {
|
|
1222
1259
|
if (protectedSpans.some(([start, end]) => offset >= start && offset < end)) return match;
|
|
1223
1260
|
if (admonition)
|
|
@@ -1239,6 +1276,16 @@ function normalizeDocfxMarkdown(source, options = {}) {
|
|
|
1239
1276
|
}).trimEnd();
|
|
1240
1277
|
return `${prefix ?? ""}${image}`;
|
|
1241
1278
|
}
|
|
1279
|
+
case "code":
|
|
1280
|
+
if (options.reference && attributes.has("source"))
|
|
1281
|
+
return (prefix ?? "") + options.reference("code", attributes.get("source"), raw?.trim() ?? "Code example");
|
|
1282
|
+
throw new Error("Unsupported DocFX code without a source reference resolver");
|
|
1283
|
+
case "no-loc":
|
|
1284
|
+
return (prefix ?? "") + escape(attributes.get("text") ?? "");
|
|
1285
|
+
case "moniker":
|
|
1286
|
+
return (prefix ?? "") + "**Applies to: " + escape(attributes.get("range") ?? raw?.trim() ?? "") + "**";
|
|
1287
|
+
case "moniker-end":
|
|
1288
|
+
return "";
|
|
1242
1289
|
case "zone":
|
|
1243
1290
|
return attributes.has("pivot") ? `${prefix ?? ""}**Applies to: ${escape(attributes.get("pivot"))}**
|
|
1244
1291
|
` : "";
|
|
@@ -1250,12 +1297,100 @@ function normalizeDocfxMarkdown(source, options = {}) {
|
|
|
1250
1297
|
case "column-end":
|
|
1251
1298
|
return "";
|
|
1252
1299
|
default:
|
|
1300
|
+
if (options.unknownDirectives === "preserve") {
|
|
1301
|
+
const fence = "`".repeat(
|
|
1302
|
+
Math.max(1, ...Array.from(match.matchAll(/`+/g), (m) => m[0].length + 1))
|
|
1303
|
+
);
|
|
1304
|
+
return `${prefix ?? ""}${fence}${match.trim()}${fence}`;
|
|
1305
|
+
}
|
|
1253
1306
|
throw new Error(`Unsupported DocFX directive: ${name}`);
|
|
1254
1307
|
}
|
|
1255
1308
|
}
|
|
1256
1309
|
);
|
|
1310
|
+
if (options.reference) {
|
|
1311
|
+
const spans = [];
|
|
1312
|
+
for (const comment of output.matchAll(/<!--[\s\S]*?(?:-->|$)/g))
|
|
1313
|
+
spans.push([comment.index, comment.index + comment[0].length]);
|
|
1314
|
+
walkMarkdownTree(parseMarkdown(output, { frontmatter: false, directive: false }), (node) => {
|
|
1315
|
+
if ((node.type === "code" || node.type === "inlineCode") && node.position)
|
|
1316
|
+
spans.push([node.position.start.offset, node.position.end.offset]);
|
|
1317
|
+
});
|
|
1318
|
+
output = output.replace(
|
|
1319
|
+
/\[!code-[\w-]+\s*\[([^\]]*)\]\(([^)\n]+)\)\]|<xref:([^>\n]+)>/gi,
|
|
1320
|
+
(match, label, target, uid, offset) => {
|
|
1321
|
+
if (spans.some(([start, end]) => offset >= start && offset < end)) return match;
|
|
1322
|
+
return uid ? options.reference("xref", uid, uid.split("?")[0]) : options.reference("code", target, label || "Code example");
|
|
1323
|
+
}
|
|
1324
|
+
);
|
|
1325
|
+
}
|
|
1326
|
+
if (options.unknownDirectives === "preserve" && /\[!code-|\[!INCLUDE\b|<xref:/i.test(output)) {
|
|
1327
|
+
const spans = [];
|
|
1328
|
+
for (const comment of output.matchAll(/<!--[\s\S]*?(?:-->|$)/g))
|
|
1329
|
+
spans.push([comment.index, comment.index + comment[0].length]);
|
|
1330
|
+
walkMarkdownTree(parseMarkdown(output, { frontmatter: false, directive: false }), (node) => {
|
|
1331
|
+
if ((node.type === "code" || node.type === "inlineCode") && node.position)
|
|
1332
|
+
spans.push([node.position.start.offset, node.position.end.offset]);
|
|
1333
|
+
});
|
|
1334
|
+
output = output.replace(
|
|
1335
|
+
/\[!code-[^\n]*|\[!INCLUDE[^\n]*|<xref:[^\n]*/gi,
|
|
1336
|
+
(match, offset) => {
|
|
1337
|
+
if (spans.some(([start, end]) => offset >= start && offset < end)) return match;
|
|
1338
|
+
options.onPreservedReference?.(match);
|
|
1339
|
+
const fence = String.fromCharCode(96).repeat(
|
|
1340
|
+
Math.max(1, ...Array.from(match.matchAll(/\x60+/g), (m) => m[0].length + 1))
|
|
1341
|
+
);
|
|
1342
|
+
return fence + " " + match + " " + fence;
|
|
1343
|
+
}
|
|
1344
|
+
);
|
|
1345
|
+
}
|
|
1346
|
+
if (options.frontmatterAsCode && frontmatter) {
|
|
1347
|
+
const fence = "`".repeat(
|
|
1348
|
+
Math.max(3, ...Array.from(frontmatter.matchAll(/`+/g), (m) => m[0].length + 1))
|
|
1349
|
+
);
|
|
1350
|
+
return output + "\n\n## Original source metadata\n\n" + fence + "text\n" + frontmatter.trimEnd() + "\n" + fence + "\n";
|
|
1351
|
+
}
|
|
1257
1352
|
return (frontmatter ?? "") + output;
|
|
1258
1353
|
}
|
|
1354
|
+
function flattenDocfxLayout(source) {
|
|
1355
|
+
const stack = [];
|
|
1356
|
+
let fence;
|
|
1357
|
+
let comment = false;
|
|
1358
|
+
return source.split("\n").map((line) => {
|
|
1359
|
+
const column = [...stack].reverse().find((entry) => entry.kind === "column");
|
|
1360
|
+
const margin = column ? column.indent + 4 : 0;
|
|
1361
|
+
const indent = /^ */.exec(line)[0].length;
|
|
1362
|
+
const content = line.slice(Math.min(indent, margin));
|
|
1363
|
+
const boundary = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(content);
|
|
1364
|
+
if (fence) {
|
|
1365
|
+
if (boundary && boundary[1][0] === fence.character && boundary[1].length >= fence.length && !boundary[2].trim())
|
|
1366
|
+
fence = void 0;
|
|
1367
|
+
return content;
|
|
1368
|
+
}
|
|
1369
|
+
const commented = comment || line.includes("<!--");
|
|
1370
|
+
const opening = line.lastIndexOf("<!--");
|
|
1371
|
+
const closing = line.lastIndexOf("-->");
|
|
1372
|
+
if (opening > closing) comment = true;
|
|
1373
|
+
else if (closing >= 0) comment = false;
|
|
1374
|
+
if (commented) return content;
|
|
1375
|
+
if (boundary) {
|
|
1376
|
+
fence = { character: boundary[1][0], length: boundary[1].length };
|
|
1377
|
+
return content;
|
|
1378
|
+
}
|
|
1379
|
+
const marker = /^ *:::(row|column)(-end)?(?=\s|:|$)[^\n]*$/i.exec(line);
|
|
1380
|
+
if (!marker || !stack.length && indent > 3) return content;
|
|
1381
|
+
const kind = marker[1].toLowerCase();
|
|
1382
|
+
if (marker[2]) {
|
|
1383
|
+
const index = stack.map((entry) => entry.kind).lastIndexOf(kind);
|
|
1384
|
+
if (index < 0) return content;
|
|
1385
|
+
stack.splice(index);
|
|
1386
|
+
} else {
|
|
1387
|
+
if (stack.length >= 128)
|
|
1388
|
+
throw new Error("DocFX layout exceeds the 128-level nesting safety limit");
|
|
1389
|
+
stack.push({ kind, indent });
|
|
1390
|
+
}
|
|
1391
|
+
return "";
|
|
1392
|
+
}).join("\n");
|
|
1393
|
+
}
|
|
1259
1394
|
|
|
1260
1395
|
export {
|
|
1261
1396
|
stringifyMarkdown,
|
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
buildNarrationScript,
|
|
8
8
|
expectedSyllablesAt,
|
|
9
9
|
wordPosAtExpectedSyllables
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-PNXBDMNS.js";
|
|
11
11
|
import {
|
|
12
12
|
flattenRenderableBlocks
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-L7IIFWWW.js";
|
|
14
14
|
|
|
15
15
|
// src/narration/types.ts
|
|
16
16
|
var DEFAULT_FEATURE_CONFIG = Object.freeze({
|
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
quoteAttrValue,
|
|
7
7
|
splitKeyValueToken,
|
|
8
8
|
tokenizeAttrTokens
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-WSFXV5BT.js";
|
|
10
10
|
import {
|
|
11
11
|
parseFrontmatter,
|
|
12
12
|
parseHtmlToNodes
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-Q6ELOAOQ.js";
|
|
14
14
|
import {
|
|
15
15
|
resolveIcon
|
|
16
16
|
} from "./chunk-7N4G32LG.js";
|
|
@@ -1181,6 +1181,95 @@ import remarkGfm from "remark-gfm";
|
|
|
1181
1181
|
import remarkMath from "remark-math";
|
|
1182
1182
|
import remarkDirective from "remark-directive";
|
|
1183
1183
|
import remarkFrontmatter from "remark-frontmatter";
|
|
1184
|
+
|
|
1185
|
+
// src/markdown/dollarMath.ts
|
|
1186
|
+
var DOLLAR_SIGN = 36;
|
|
1187
|
+
var DIGIT_ZERO = 48;
|
|
1188
|
+
var DIGIT_NINE = 57;
|
|
1189
|
+
function isWhitespace(code) {
|
|
1190
|
+
if (code === null) return false;
|
|
1191
|
+
return code < 0 || /\s/u.test(String.fromCodePoint(code));
|
|
1192
|
+
}
|
|
1193
|
+
function isAsciiDigit(code) {
|
|
1194
|
+
return code !== null && code >= DIGIT_ZERO && code <= DIGIT_NINE;
|
|
1195
|
+
}
|
|
1196
|
+
var dollarMathSpan = {
|
|
1197
|
+
name: "squisqDollarMathSpan",
|
|
1198
|
+
partial: true,
|
|
1199
|
+
tokenize(effects, ok, nok) {
|
|
1200
|
+
let previousWasWhitespace = false;
|
|
1201
|
+
let closingRunLength = 0;
|
|
1202
|
+
return open;
|
|
1203
|
+
function open(code) {
|
|
1204
|
+
effects.enter("squisqDollarMathProbe");
|
|
1205
|
+
effects.consume(code);
|
|
1206
|
+
return afterOpen;
|
|
1207
|
+
}
|
|
1208
|
+
function afterOpen(code) {
|
|
1209
|
+
if (code === DOLLAR_SIGN) return succeed(code);
|
|
1210
|
+
if (code === null || isWhitespace(code)) return fail(code);
|
|
1211
|
+
return inside(code);
|
|
1212
|
+
}
|
|
1213
|
+
function inside(code) {
|
|
1214
|
+
if (code === null) return fail(code);
|
|
1215
|
+
if (code === DOLLAR_SIGN) {
|
|
1216
|
+
closingRunLength = 0;
|
|
1217
|
+
return closingRun(code);
|
|
1218
|
+
}
|
|
1219
|
+
previousWasWhitespace = isWhitespace(code);
|
|
1220
|
+
effects.consume(code);
|
|
1221
|
+
return inside;
|
|
1222
|
+
}
|
|
1223
|
+
function closingRun(code) {
|
|
1224
|
+
if (code === DOLLAR_SIGN) {
|
|
1225
|
+
closingRunLength++;
|
|
1226
|
+
effects.consume(code);
|
|
1227
|
+
return closingRun;
|
|
1228
|
+
}
|
|
1229
|
+
if (closingRunLength !== 1) {
|
|
1230
|
+
previousWasWhitespace = false;
|
|
1231
|
+
return inside(code);
|
|
1232
|
+
}
|
|
1233
|
+
if (previousWasWhitespace || isAsciiDigit(code)) return fail(code);
|
|
1234
|
+
return succeed(code);
|
|
1235
|
+
}
|
|
1236
|
+
function succeed(code) {
|
|
1237
|
+
effects.exit("squisqDollarMathProbe");
|
|
1238
|
+
return ok(code);
|
|
1239
|
+
}
|
|
1240
|
+
function fail(code) {
|
|
1241
|
+
effects.exit("squisqDollarMathProbe");
|
|
1242
|
+
return nok(code);
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
};
|
|
1246
|
+
function previousIsNotUnescapedDollar(code) {
|
|
1247
|
+
return code !== DOLLAR_SIGN || this.events[this.events.length - 1]?.[1].type === "characterEscape";
|
|
1248
|
+
}
|
|
1249
|
+
var dollarTextGuard = {
|
|
1250
|
+
name: "squisqDollarTextGuard",
|
|
1251
|
+
add: "before",
|
|
1252
|
+
previous: previousIsNotUnescapedDollar,
|
|
1253
|
+
tokenize(effects, ok, nok) {
|
|
1254
|
+
return start;
|
|
1255
|
+
function start(code) {
|
|
1256
|
+
return effects.check(dollarMathSpan, nok, literalDollar)(code);
|
|
1257
|
+
}
|
|
1258
|
+
function literalDollar(code) {
|
|
1259
|
+
effects.enter("data");
|
|
1260
|
+
effects.consume(code);
|
|
1261
|
+
effects.exit("data");
|
|
1262
|
+
return ok;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
};
|
|
1266
|
+
function remarkDollarMathRules() {
|
|
1267
|
+
const data = this.data();
|
|
1268
|
+
const extensions = data.micromarkExtensions ?? (data.micromarkExtensions = []);
|
|
1269
|
+
extensions.push({ text: { [DOLLAR_SIGN]: dollarTextGuard } });
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
// src/markdown/parse.ts
|
|
1184
1273
|
var defaultProcessor;
|
|
1185
1274
|
function parseMarkdown(markdown, options) {
|
|
1186
1275
|
options?.signal?.throwIfAborted();
|
|
@@ -1189,7 +1278,7 @@ function parseMarkdown(markdown, options) {
|
|
|
1189
1278
|
let processor;
|
|
1190
1279
|
if (useDefaults) {
|
|
1191
1280
|
if (!defaultProcessor) {
|
|
1192
|
-
defaultProcessor = unified().use(remarkParse).use(remarkGfm).use(remarkMath).use(remarkDirective).use(remarkFrontmatter, ["yaml"]);
|
|
1281
|
+
defaultProcessor = unified().use(remarkParse).use(remarkGfm).use(remarkMath).use(remarkDollarMathRules).use(remarkDirective).use(remarkFrontmatter, ["yaml"]);
|
|
1193
1282
|
}
|
|
1194
1283
|
processor = defaultProcessor;
|
|
1195
1284
|
} else {
|
|
@@ -1198,7 +1287,7 @@ function parseMarkdown(markdown, options) {
|
|
|
1198
1287
|
processor = processor.use(remarkGfm);
|
|
1199
1288
|
}
|
|
1200
1289
|
if (options?.math !== false) {
|
|
1201
|
-
processor = processor.use(remarkMath);
|
|
1290
|
+
processor = processor.use(remarkMath).use(remarkDollarMathRules);
|
|
1202
1291
|
}
|
|
1203
1292
|
if (options?.directive !== false) {
|
|
1204
1293
|
processor = processor.use(remarkDirective);
|