mdrefine 0.2.0 → 0.2.1
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 +16 -0
- package/README.md +1 -1
- package/dist/rules/style.js +69 -16
- package/dist/rules/style.js.map +1 -1
- package/dist/syntax/parse.js +3 -1
- package/dist/syntax/parse.js.map +1 -1
- package/docs/dialects.md +2 -1
- package/docs/quick-start.md +1 -1
- package/docs/rules.md +7 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,22 @@ release's section is also its [GitHub
|
|
|
8
8
|
release](https://github.com/viell-dev/slop-markdown-tools/releases)'s notes; the
|
|
9
9
|
prereleases' notes there are longer than their entries here.
|
|
10
10
|
|
|
11
|
+
## 0.2.1 - 2026-10-18
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- The Obsidian dialect reads strikethrough with two tildes only, as Obsidian
|
|
16
|
+
shows it; `~a~` is text there. Before, `style/emphasis` left emphasis that the
|
|
17
|
+
misread strikethrough covered unchanged
|
|
18
|
+
([#327](https://github.com/viell-dev/slop-markdown-tools/pull/327)).
|
|
19
|
+
- `style/emphasis` and `style/strong` no longer change markers that GitHub reads
|
|
20
|
+
otherwise than the parser: after an earlier emphasis, in `~~b *c~~ d*`, where
|
|
21
|
+
GitHub shows the asterisks as text; next to tildes, in `x~~*b b*~~`, where a
|
|
22
|
+
`_` would be text on GitHub; and in runs of markers that the parser pairs
|
|
23
|
+
otherwise than CommonMark, as in `xab***a* a*y`. Each rewrite changed what
|
|
24
|
+
GitHub showed while the safety check, which uses the parser's reading, saw no
|
|
25
|
+
change ([#327](https://github.com/viell-dev/slop-markdown-tools/pull/327)).
|
|
26
|
+
|
|
11
27
|
## 0.2.0 - 2026-10-18
|
|
12
28
|
|
|
13
29
|
The first stable release. It holds everything in the earlier prereleases, and
|
package/README.md
CHANGED
|
@@ -59,7 +59,7 @@ mdrefine needs Node.js 22.12 or newer. The package is `mdrefine`, and its
|
|
|
59
59
|
command is `mdtools`:
|
|
60
60
|
|
|
61
61
|
```sh
|
|
62
|
-
npm install --save-dev --save-exact mdrefine@0.2.
|
|
62
|
+
npm install --save-dev --save-exact mdrefine@0.2.1
|
|
63
63
|
npx mdtools lint
|
|
64
64
|
npx mdtools format --diff
|
|
65
65
|
npx mdtools format --write
|
package/dist/rules/style.js
CHANGED
|
@@ -128,11 +128,13 @@ function markersLoosenRuns() {
|
|
|
128
128
|
/**
|
|
129
129
|
* The delimiter runs at `positions`, sorted, with the characters that `at`
|
|
130
130
|
* gives. Whether a run can open or close follows micromark, which also lets a
|
|
131
|
-
* run next to a `~` in GFM do both
|
|
132
|
-
*
|
|
133
|
-
*
|
|
131
|
+
* run next to a `~` in GFM do both, and in some versions one next to another
|
|
132
|
+
* `*` or `_`; with `commonmark`, it follows CommonMark, where those characters
|
|
133
|
+
* are punctuation. Container markers such as `>` count as punctuation here,
|
|
134
|
+
* while micromark sees the line ending before them; the caller compares the
|
|
135
|
+
* result with the parse.
|
|
134
136
|
*/
|
|
135
|
-
function delimiterRuns(positions, at, gfm) {
|
|
137
|
+
function delimiterRuns(positions, at, gfm, commonmark = false) {
|
|
136
138
|
const runs = [];
|
|
137
139
|
for (const position of positions) {
|
|
138
140
|
const last = runs.at(-1);
|
|
@@ -147,8 +149,9 @@ function delimiterRuns(positions, at, gfm) {
|
|
|
147
149
|
close: false,
|
|
148
150
|
});
|
|
149
151
|
}
|
|
150
|
-
const loosen = markersLoosenRuns();
|
|
151
|
-
const attention = (character) => (gfm && character === "~") ||
|
|
152
|
+
const loosen = !commonmark && markersLoosenRuns();
|
|
153
|
+
const attention = (character) => (!commonmark && gfm && character === "~") ||
|
|
154
|
+
(loosen && (character === "*" || character === "_"));
|
|
152
155
|
for (const run of runs) {
|
|
153
156
|
const previous = at(run.start - 1);
|
|
154
157
|
const next = at(run.end);
|
|
@@ -165,21 +168,23 @@ function delimiterRuns(positions, at, gfm) {
|
|
|
165
168
|
* The emphasis and strong emphasis that micromark makes of `runs`, as
|
|
166
169
|
* `start:end:size` strings: each closing run, in order, pairs with the nearest
|
|
167
170
|
* opening run of its marker before it, except where the rule of three forbids
|
|
168
|
-
* it, and the runs between them become text.
|
|
171
|
+
* it, and the runs between them become text. micromark applies the rule to the
|
|
172
|
+
* parts of two runs that are left; with `whole`, it counts the whole runs, as
|
|
173
|
+
* CommonMark, GitHub, and the reference parsers do (issue #323).
|
|
169
174
|
*/
|
|
170
|
-
function pairings(runs) {
|
|
171
|
-
const left = runs.map((run) => ({ ...run }));
|
|
175
|
+
function pairings(runs, whole = false) {
|
|
176
|
+
const left = runs.map((run) => ({ ...run, size: run.end - run.start }));
|
|
172
177
|
const pairs = [];
|
|
173
178
|
for (let index = 0; index < left.length; index++) {
|
|
174
179
|
const closer = left[index];
|
|
175
180
|
while (closer.close && closer.end > closer.start) {
|
|
176
|
-
const closeSize = closer.end - closer.start;
|
|
181
|
+
const closeSize = whole ? closer.size : closer.end - closer.start;
|
|
177
182
|
let found = index - 1;
|
|
178
183
|
for (; found >= 0; found--) {
|
|
179
184
|
const opener = left[found];
|
|
180
|
-
|
|
181
|
-
if (!opener.open || !openSize || opener.marker !== closer.marker)
|
|
185
|
+
if (!opener.open || opener.end === opener.start || opener.marker !== closer.marker)
|
|
182
186
|
continue;
|
|
187
|
+
const openSize = whole ? opener.size : opener.end - opener.start;
|
|
183
188
|
if ((opener.close || closer.open) && closeSize % 3 && !((openSize + closeSize) % 3))
|
|
184
189
|
continue;
|
|
185
190
|
break;
|
|
@@ -187,7 +192,7 @@ function pairings(runs) {
|
|
|
187
192
|
if (found < 0)
|
|
188
193
|
break;
|
|
189
194
|
const opener = left[found];
|
|
190
|
-
const use = opener.end - opener.start > 1 &&
|
|
195
|
+
const use = opener.end - opener.start > 1 && closer.end - closer.start > 1 ? 2 : 1;
|
|
191
196
|
opener.end -= use;
|
|
192
197
|
closer.start += use;
|
|
193
198
|
pairs.push(`${opener.end}:${closer.start}:${use}`);
|
|
@@ -298,6 +303,25 @@ function eachInline(tree, type, visitor) {
|
|
|
298
303
|
};
|
|
299
304
|
step(tree, tree);
|
|
300
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* Whether the text in `node`, outside code and other literal nodes, holds an
|
|
308
|
+
* unescaped run of tildes that could mark strikethrough in `dialect`, one or
|
|
309
|
+
* two tildes or in Obsidian two, while `scope`, where such runs pair, holds
|
|
310
|
+
* another.
|
|
311
|
+
*/
|
|
312
|
+
function holdsStrikethroughRun(node, scope, source, dialect) {
|
|
313
|
+
const pattern = dialect === "obsidian" ? "(?<![\\\\~])~~(?!~)" : "(?<![\\\\~])~{1,2}(?!~)";
|
|
314
|
+
const runs = located(scope) ? source.slice(...range(scope)).match(new RegExp(pattern, "g")) : [];
|
|
315
|
+
if (located(scope) && (runs?.length ?? 0) < 2)
|
|
316
|
+
return false;
|
|
317
|
+
const run = new RegExp(pattern);
|
|
318
|
+
let found = false;
|
|
319
|
+
walk(node, "text", (text) => {
|
|
320
|
+
if (!found && located(text) && run.test(source.slice(...range(text))))
|
|
321
|
+
found = true;
|
|
322
|
+
});
|
|
323
|
+
return found;
|
|
324
|
+
}
|
|
301
325
|
function markerRule(type, fallback) {
|
|
302
326
|
return {
|
|
303
327
|
description: `Choose ${type} delimiters without reprinting their contents.`,
|
|
@@ -378,6 +402,27 @@ function markerRule(type, fallback) {
|
|
|
378
402
|
reaches(start + size, 1) ||
|
|
379
403
|
reaches(end - size - 1, -1)))
|
|
380
404
|
return;
|
|
405
|
+
// micromark pairs emphasis and strikethrough in separate passes, in the
|
|
406
|
+
// order that their first delimiters appear in the paragraph, while
|
|
407
|
+
// GitHub pairs whichever closes first. So emphasis whose text holds a
|
|
408
|
+
// run of tildes that could mark strikethrough may be strikethrough and
|
|
409
|
+
// text there, and its markers what GitHub shows (issue #320).
|
|
410
|
+
if (gfm && holdsStrikethroughRun(node, scope, source, document.dialect))
|
|
411
|
+
return;
|
|
412
|
+
// GitHub reads a `_` that a run of tildes separates from a letter or
|
|
413
|
+
// digit as inside a word, where it neither opens nor closes, while the
|
|
414
|
+
// parser reads emphasis there (issue #322).
|
|
415
|
+
const tildesToWord = (index, step) => {
|
|
416
|
+
if (source[index] !== "~")
|
|
417
|
+
return false;
|
|
418
|
+
while (source[index] === "~")
|
|
419
|
+
index += step;
|
|
420
|
+
return /[\p{L}\p{N}]/u.test(source[index] ?? "");
|
|
421
|
+
};
|
|
422
|
+
if (gfm &&
|
|
423
|
+
(marker[0] === "_" || original[0] === "_") &&
|
|
424
|
+
(tildesToWord(start - 1, -1) || tildesToWord(end, 1)))
|
|
425
|
+
return;
|
|
381
426
|
const list = candidates.get(scope) ?? [];
|
|
382
427
|
list.push([start, end]);
|
|
383
428
|
candidates.set(scope, list);
|
|
@@ -401,7 +446,11 @@ function markerRule(type, fallback) {
|
|
|
401
446
|
// share a run of markers, as in `***a***` or `*a****c***`.
|
|
402
447
|
const { positions, emphasis, suspicious } = scopeDelimiters(source, scope);
|
|
403
448
|
const expected = emphasis.join(" ");
|
|
404
|
-
|
|
449
|
+
// micromark's pairing, or with `commonmark` CommonMark's.
|
|
450
|
+
const pairing = (changed, commonmark = false) => pairings(delimiterRuns(positions, (at) => (changed.has(at) ? marker[0] : source[at]), gfm, commonmark), commonmark).join(" ");
|
|
451
|
+
// Both micromark's pairing and CommonMark's, which renderers follow,
|
|
452
|
+
// have to stay the same with the new markers.
|
|
453
|
+
const kept = (changed) => pairing(changed) === expected && pairing(changed, true) === expected;
|
|
405
454
|
// micromark pairs `~` in a pass of its own, which can come first, and
|
|
406
455
|
// lets a run next to a `~` pair with one of the new marker, as in `_f~*a*e_`.
|
|
407
456
|
const tilde = gfm && source.slice(...range(scope)).includes("~");
|
|
@@ -409,12 +458,16 @@ function markerRule(type, fallback) {
|
|
|
409
458
|
if (!modelled)
|
|
410
459
|
accepted =
|
|
411
460
|
suspicious || (tilde && positions.some((at) => source[at] === marker[0])) ? [] : list;
|
|
412
|
-
|
|
461
|
+
// Where CommonMark pairs the text as written differently, the parser
|
|
462
|
+
// misread it, and renderers show other emphasis (issue #323).
|
|
463
|
+
else if (pairing(new Set(), true) !== expected)
|
|
464
|
+
accepted = [];
|
|
465
|
+
else if (!kept(markers(list))) {
|
|
413
466
|
accepted = [];
|
|
414
467
|
let changed = new Set();
|
|
415
468
|
for (const item of list) {
|
|
416
469
|
const trial = new Set([...changed, ...markers([item])]);
|
|
417
|
-
if (
|
|
470
|
+
if (!kept(trial))
|
|
418
471
|
continue;
|
|
419
472
|
changed = trial;
|
|
420
473
|
accepted.push(item);
|
package/dist/rules/style.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","sourceRoot":"","sources":["../../src/rules/style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,WAAW,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,KAAK,EACL,KAAK,EACL,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAChG,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAElG,MAAM,UAAU,aAAa,CAAC,UAAmC;IAC/D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;AACrE,CAAC;AACD,oEAAoE;AACpE,MAAM,SAAS,GAAG,YAAY,CAAC;AAC/B,mEAAmE;AACnE,SAAS,UAAU,CAAC,MAAc;IAChC,OAAO,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAA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AM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { walk } from \"../syntax/walk.js\";\nimport stringWidth from \"string-width\";\nimport type { Blockquote, Nodes, Paragraph, Parents, Root, RootContent } from \"mdast\";\nimport { directive } from \"../core/directives.js\";\nimport type { Dialect, Document, Finding, Rule } from \"../core/types.js\";\nimport { blockIdentifier } from \"../syntax/block-identifier.js\";\nimport {\n codeSpanText,\n labelEnd,\n lazyIndentation,\n parse,\n range,\n startsWithMarker,\n} from \"../syntax/parse.js\";\nimport { changesForgeHeading, headingAttributeBlock } from \"../workspace/heading-attributes.js\";\nimport { takesFinalLineEnding, takesLines, underlinedHeadings, underlineEdit } from \"./blocks.js\";\n\nexport function optionsSchema(properties: Record<string, unknown>) {\n return { type: \"object\", properties, additionalProperties: false };\n}\n/** Any CommonMark line ending, including a lone carriage return. */\nconst lineBreak = /\\r\\n|\\r|\\n/;\n/** The document's line ending, taken from its first line break. */\nfunction lineEnding(source: string): string {\n return lineBreak.exec(source)?.[0] ?? \"\\n\";\n}\n/** Start and end of the physical lines containing a source range. */\nfunction lineBounds(source: string, start: number, end: number): [number, number] {\n let lineStart = start;\n while (lineStart > 0 && !/[\\r\\n]/.test(source[lineStart - 1]!)) lineStart--;\n let lineEnd = end;\n while (lineEnd < source.length && !/[\\r\\n]/.test(source[lineEnd]!)) lineEnd++;\n return [lineStart, lineEnd];\n}\n/**\n * Where a document's line breaks are, and where the strings that rules look\n * for on a line occur, all sorted. Rules ask about the line of every emphasis\n * or code span; searching the line itself each time took time that grows with\n * the square of a long line's length.\n */\ninterface LineIndex {\n breaks: number[];\n found: Map<string, number[]>;\n}\nconst lineIndexes = new WeakMap<Document, LineIndex>();\nfunction lineIndex(document: Document): LineIndex {\n let index = lineIndexes.get(document);\n if (!index) {\n const breaks: number[] = [];\n for (let at = 0; at < document.source.length; at++)\n if (document.source[at] === \"\\r\" || document.source[at] === \"\\n\") breaks.push(at);\n lineIndexes.set(document, (index = { breaks, found: new Map() }));\n }\n return index;\n}\n/** The number of values in the sorted `values` that are less than `limit`. */\nfunction countBelow(values: number[], limit: number): number {\n let low = 0;\n let high = values.length;\n while (low < high) {\n const middle = (low + high) >> 1;\n if (values[middle]! < limit) low = middle + 1;\n else high = middle;\n }\n return low;\n}\n/** `lineBounds` for a document, from its line index. */\nfunction indexedLineBounds(document: Document, start: number, end: number): [number, number] {\n const { breaks } = lineIndex(document);\n const before = countBelow(breaks, start);\n const after = countBelow(breaks, end);\n return [before ? breaks[before - 1]! + 1 : 0, breaks[after] ?? document.source.length];\n}\n/**\n * Where `text` occurs in the document between `from` and `to`, wholly: the\n * last occurrence, or -1 for none.\n */\nfunction lastWithin(document: Document, text: string, from: number, to: number): number {\n const { found } = lineIndex(document);\n let positions = found.get(text);\n if (!positions) {\n positions = [];\n for (\n let at = document.source.indexOf(text);\n at >= 0;\n at = document.source.indexOf(text, at + 1)\n )\n positions.push(at);\n found.set(text, positions);\n }\n const last = positions[countBelow(positions, to - text.length + 1) - 1];\n return last !== undefined && last >= from ? last : -1;\n}\n/**\n * Gitea does not parse a `_` run as an emphasis delimiter when the next `_` on\n * its physical line starts `_.py`, or when the run itself does and no `_`\n * follows, so `__init__.py` stays literal. The outcome depends on everything\n * else on the line, code spans included: a line containing `_.py` before or\n * after an edit can gain or lose emphasis when markers change or lines join.\n */\nexport function giteaPyLine(document: Document, start: number, end: number): boolean {\n return lastWithin(document, \"_.py\", ...indexedLineBounds(document, start, end)) >= 0;\n}\n/** Forgejo and its upstream Gitea build on goldmark with shared extensions. */\nconst goldmarkForges: Partial<Record<Dialect, string>> = { forgejo: \"Forgejo\", gitea: \"Gitea\" };\n/**\n * Whether a range lies between `\\(` and `\\)` on its line, which Forgejo, and\n * Gitea where enabled, render as math. GFM parses emphasis and code spans\n * there, and changing them would change the formula.\n */\nexport function inForgeMath(document: Document, start: number, end: number): boolean {\n const [lineStart, lineEnd] = indexedLineBounds(document, start, end);\n return (\n lastWithin(document, \"\\\\(\", lineStart, start) > lastWithin(document, \"\\\\)\", lineStart, start) &&\n lastWithin(document, \"\\\\)\", end, lineEnd) >= 0\n );\n}\n/** The blocks whose inline content the parser reads, and pairs delimiters in, as a whole. */\nconst inlineBlocks = new Set([\"paragraph\", \"heading\", \"tableCell\"]);\n/** Whether the character at `index` is escaped by an odd number of backslashes before it. */\nfunction escaped(source: string, index: number): boolean {\n let count = 0;\n while (source[index - count - 1] === \"\\\\\") count++;\n return count % 2 === 1;\n}\n/**\n * How micromark classifies a character next to a delimiter run: 1 for\n * whitespace and for the start or end of the text, 2 for punctuation and\n * symbols, and 0 for anything else. It looks at UTF-16 code units, so half of\n * a surrogate pair counts as anything else.\n */\nfunction characterGroup(character: string | undefined): 0 | 1 | 2 {\n if (character === undefined || /\\s/.test(character)) return 1;\n return /\\p{P}|\\p{S}/u.test(character) ? 2 : 0;\n}\n/** A run of `*` or `_` that micromark reads as one delimiter sequence. */\ninterface DelimiterRun {\n marker: string;\n /** The part of the run that has not paired yet. */\n start: number;\n end: number;\n open: boolean;\n close: boolean;\n}\n/**\n * Whether the installed micromark lets a run of `*` or `_` next to the other\n * marker open and close whatever else surrounds it, as\n * micromark-core-commonmark did before 2.0.4. It is read from the parse of\n * `*_c_*a`, whose last `*` then closes emphasis.\n */\nlet markersLoosen: boolean | undefined;\nfunction markersLoosenRuns(): boolean {\n markersLoosen ??= parse(\"*_c_*a\", \"commonmark\").tree.children.some(\n (block) => block.type === \"paragraph\" && block.children[0]?.type === \"emphasis\",\n );\n return markersLoosen;\n}\n/**\n * The delimiter runs at `positions`, sorted, with the characters that `at`\n * gives. Whether a run can open or close follows micromark, which also lets a\n * run next to a `~` in GFM do both. Container markers such as `>` count as\n * punctuation here, while micromark sees the line ending before them; the\n * caller compares the result with the parse.\n */\nfunction delimiterRuns(\n positions: number[],\n at: (index: number) => string | undefined,\n gfm: boolean,\n): DelimiterRun[] {\n const runs: DelimiterRun[] = [];\n for (const position of positions) {\n const last = runs.at(-1);\n if (last && last.end === position && at(position) === last.marker) last.end++;\n else\n runs.push({\n marker: at(position)!,\n start: position,\n end: position + 1,\n open: false,\n close: false,\n });\n }\n const loosen = markersLoosenRuns();\n const attention = (character: string | undefined) =>\n (gfm && character === \"~\") || (loosen && (character === \"*\" || character === \"_\"));\n for (const run of runs) {\n const previous = at(run.start - 1);\n const next = at(run.end);\n const before = characterGroup(previous);\n const after = characterGroup(next);\n const open = after === 0 || (after === 2 && before !== 0) || attention(next);\n const close = before === 0 || (before === 2 && after !== 0) || attention(previous);\n run.open = run.marker === \"*\" ? open : open && (before !== 0 || !close);\n run.close = run.marker === \"*\" ? close : close && (after !== 0 || !open);\n }\n return runs;\n}\n/**\n * The emphasis and strong emphasis that micromark makes of `runs`, as\n * `start:end:size` strings: each closing run, in order, pairs with the nearest\n * opening run of its marker before it, except where the rule of three forbids\n * it, and the runs between them become text.\n */\nfunction pairings(runs: DelimiterRun[]): string[] {\n const left = runs.map((run) => ({ ...run }));\n const pairs: string[] = [];\n for (let index = 0; index < left.length; index++) {\n const closer = left[index]!;\n while (closer.close && closer.end > closer.start) {\n const closeSize = closer.end - closer.start;\n let found = index - 1;\n for (; found >= 0; found--) {\n const opener = left[found]!;\n const openSize = opener.end - opener.start;\n if (!opener.open || !openSize || opener.marker !== closer.marker) continue;\n if ((opener.close || closer.open) && closeSize % 3 && !((openSize + closeSize) % 3))\n continue;\n break;\n }\n if (found < 0) break;\n const opener = left[found]!;\n const use = opener.end - opener.start > 1 && closeSize > 1 ? 2 : 1;\n opener.end -= use;\n closer.start += use;\n pairs.push(`${opener.end}:${closer.start}:${use}`);\n for (let between = found + 1; between < index; between++)\n left[between]!.end = left[between]!.start;\n }\n }\n return pairs.sort();\n}\n/**\n * The `*` and `_` characters that micromark reads as delimiters in the text of\n * `scope`, a block or a link whose text it pairs delimiters in on its own: the\n * markers of emphasis, and unescaped characters left as text. Also the\n * emphasis there, as `start:end:size` strings, and whether changing markers\n * could change how they pair: when a character left as text could open or\n * close emphasis, as in `*a _b* c_`, or when one run holds the markers of two\n * emphases, or a marker and text, as in `***a***` or `*****a***`.\n */\nfunction scopeDelimiters(\n source: string,\n scope: Nodes,\n): { positions: number[]; emphasis: string[]; suspicious: boolean } {\n const positions: number[] = [];\n const markers = new Set<string>();\n const emphasis: string[] = [];\n const literal = new Set<number>();\n const visit = (node: Nodes) => {\n if (node !== scope && (node.type === \"link\" || node.type === \"linkReference\")) return;\n if (node.type === \"emphasis\" || node.type === \"strong\") {\n const [a, b] = range(node);\n const size = node.type === \"strong\" ? 2 : 1;\n emphasis.push(`${a}:${b}:${size}`);\n markers.add(`${a}:${a + size}`).add(`${b - size}:${b}`);\n for (let i = 0; i < size; i++) positions.push(a + i, b - size + i);\n } else if (node.type === \"text\") {\n const [a, b] = range(node);\n for (let i = a; i < b; i++)\n if ((source[i] === \"*\" || source[i] === \"_\") && !escaped(source, i)) {\n positions.push(i);\n literal.add(i);\n }\n }\n if (\"children\" in node) for (const child of node.children) visit(child);\n };\n visit(scope);\n positions.sort((a, b) => a - b);\n const suspicious = delimiterRuns(positions, (index) => source[index], true).some((run) => {\n if (markers.has(`${run.start}:${run.end}`)) return false;\n for (let index = run.start; index < run.end; index++)\n if (literal.has(index)) return run.open || run.close;\n return true;\n });\n return { positions, emphasis: emphasis.sort(), suspicious };\n}\n/** A link label as CommonMark compares labels: whitespace collapsed and case folded. */\nconst normalizedLabel = (label: string) =>\n label\n .replace(/[\\t\\n\\r ]+/g, \" \")\n .trim()\n .toLowerCase()\n .toUpperCase();\n/** The labels of the document's definitions and footnotes that hold `*` or `_`, normalized. */\nfunction markerLabels(tree: Root): string[] {\n const labels: string[] = [];\n walk(tree, (node) => {\n if (\n (node.type === \"definition\" || node.type === \"footnoteDefinition\") &&\n node.label &&\n /[*_]/.test(node.label)\n )\n labels.push(normalizedLabel(node.label));\n });\n return labels;\n}\n/**\n * The first lines of the document's Obsidian callouts and GitHub, Forgejo, or\n * Gitea alerts, from the marker on, which hold an Obsidian callout's title and\n * an alert's marker on its own.\n */\nfunction calloutTitles(document: Document): Range[] {\n const titles: Range[] = [];\n if (document.dialect !== \"commonmark\")\n walk(document.tree, \"blockquote\", (quote) => {\n const first = quote.children[0];\n if (first?.type !== \"paragraph\") return;\n const [start] = range(first);\n const end = lineBounds(document.source, start, start)[1];\n if (startsWithMarker(document.source.slice(start, end), first)) titles.push([start, end]);\n });\n return titles;\n}\n/**\n * Visit the nodes of `type` with their scope: the innermost link, whose text\n * micromark pairs delimiters in on its own, or else the block that holds them.\n */\nfunction eachInline<T extends \"emphasis\" | \"strong\">(\n tree: Root,\n type: T,\n visitor: (node: Extract<Nodes, { type: T }>, scope: Nodes) => void,\n): void {\n const step = (node: Nodes, scope: Nodes) => {\n if (inlineBlocks.has(node.type) || node.type === \"link\" || node.type === \"linkReference\")\n scope = node;\n if (node.type === type) visitor(node as Extract<Nodes, { type: T }>, scope);\n if (\"children\" in node) for (const child of node.children) step(child, scope);\n };\n step(tree, tree);\n}\nfunction markerRule(type: \"emphasis\" | \"strong\", fallback: string): Rule {\n return {\n description: `Choose ${type} delimiters without reprinting their contents.`,\n kind: \"style\",\n phase: \"inline\",\n schema: optionsSchema({ marker: { enum: [\"*\", \"_\"] } }),\n check({ document, options }) {\n const findings: Finding[] = [];\n const { source } = document;\n const gfm = document.dialect !== \"commonmark\";\n const size = type === \"strong\" ? 2 : 1;\n const marker = String(options.marker ?? fallback).repeat(size);\n const labels = markerLabels(document.tree);\n const titles = calloutTitles(document);\n /** The ranges of the emphasis to change, by the scope that holds them. */\n const candidates = new Map<Nodes, Range[]>();\n eachInline(document.tree, type, (node, scope) => {\n const [start, end] = range(node);\n const original = source.slice(start, end);\n if (original.startsWith(marker)) return;\n // Underscores cannot delimit intraword emphasis. Preserve these valid forms.\n if (\n marker.startsWith(\"_\") &&\n (/\\p{L}|\\p{N}/u.test(document.source[start - 1] ?? \"\") ||\n /\\p{L}|\\p{N}/u.test(document.source[end] ?? \"\"))\n )\n return;\n // A new marker touching the same character, outside or inside the\n // node, would merge into one delimiter run and change the parse.\n const neighbours = [start - 1, end, start + size, end - size - 1].map(\n (index) => document.source[index],\n );\n if (neighbours.includes(marker[0]!)) return;\n if (goldmarkForges[document.dialect] && inForgeMath(document, start, end)) return;\n // Forgejo, and Gitea before 1.26, build a heading's anchor from its last\n // line as written, keeping `_` and dropping `*`, and both read a trailing\n // `{...}` block as attributes before they parse emphasis.\n if (changesForgeHeading(document, start, end)) return;\n if (\n document.dialect === \"gitea\" &&\n (giteaPyLine(document, start, end) ||\n document.source.startsWith(\".py\", end) ||\n document.source.startsWith(\".py\", start + size))\n )\n return;\n // GitHub, Forgejo, and Gitea end dollar math only at dollars that no\n // `_` follows, so a marker after a `$` can decide where math ends.\n if (\n gfm &&\n document.dialect !== \"obsidian\" &&\n (source[start - 1] === \"$\" || source[end - size - 1] === \"$\")\n )\n return;\n // Emphasis that begins on the line of a callout's or alert's marker\n // and ends below it is text on that line, whose markers would change.\n if (\n titles.length &&\n /[\\r\\n]/.test(original) &&\n titles.some(([a, b]) => start >= a && start < b && end > b)\n )\n return;\n // The text of a collapsed or shortcut reference, such as `[*Title*][]`\n // or `[*Title*]`, is also its label, which would no longer match the\n // definition's.\n if (scope.type === \"linkReference\" && scope.referenceType !== \"full\") return;\n // Text in brackets that would match a definition with the new markers\n // would become a reference.\n if (labels.length) {\n const rewritten = normalizedLabel(marker + original.slice(size, -size) + marker);\n if (labels.some((label) => label.includes(rewritten))) return;\n }\n // micromark lets a run next to a `~` open and close, so a new marker\n // that a `~` separates from another `*` or `_` like it could pair with it.\n const reaches = (index: number, step: number) => {\n while (source[index] === \"~\") index += step;\n return source[index] === marker[0];\n };\n if (\n gfm &&\n (reaches(start - 1, -1) ||\n reaches(end, 1) ||\n reaches(start + size, 1) ||\n reaches(end - size - 1, -1))\n )\n return;\n const list = candidates.get(scope) ?? [];\n list.push([start, end]);\n candidates.set(scope, list);\n });\n /** The positions of the markers of the emphasis in `ranges`. */\n const markers = (ranges: Range[]) => {\n const set = new Set<number>();\n for (const [start, end] of ranges)\n for (let i = 0; i < size; i++) set.add(start + i).add(end - size + i);\n return set;\n };\n for (const [scope, list] of candidates) {\n let accepted = list;\n // The parser's pairing of delimiter runs is modelled, and the markers\n // change where the model, which has to reproduce the parse, pairs the\n // same runs with the new markers: all of them, or else those that can\n // be added one at a time. Where the model cannot be used, markers\n // change only when no run could pair differently, which it could when\n // a `*` or `_` in the same text did not pair, or when two emphases\n // share a run of markers, as in `***a***` or `*a****c***`.\n const { positions, emphasis, suspicious } = scopeDelimiters(source, scope);\n const expected = emphasis.join(\" \");\n const pairing = (changed: Set<number>) =>\n pairings(\n delimiterRuns(positions, (at) => (changed.has(at) ? marker[0] : source[at]), gfm),\n ).join(\" \");\n // micromark pairs `~` in a pass of its own, which can come first, and\n // lets a run next to a `~` pair with one of the new marker, as in `_f~*a*e_`.\n const tilde = gfm && source.slice(...range(scope)).includes(\"~\");\n const modelled = !tilde && positions.length <= 500 && pairing(new Set()) === expected;\n if (!modelled)\n accepted =\n suspicious || (tilde && positions.some((at) => source[at] === marker[0])) ? [] : list;\n else if (pairing(markers(list)) !== expected) {\n accepted = [];\n let changed = new Set<number>();\n for (const item of list) {\n const trial = new Set([...changed, ...markers([item])]);\n if (pairing(trial) !== expected) continue;\n changed = trial;\n accepted.push(item);\n }\n }\n for (const [start, end] of accepted)\n for (const [a, b] of [\n [start, start + size],\n [end - size, end],\n ] as const) {\n findings.push({\n start: a,\n end: b,\n message: `Use ${JSON.stringify(marker)} for ${type}.`,\n edit: { start: a, end: b, text: marker },\n });\n }\n }\n return findings.sort((a, b) => a.start - b.start);\n },\n };\n}\n\n/**\n * Where dollar math could begin or end at the edge of a line although it does\n * not at a space: `start` when a dollar at the start of a line can end math\n * that a dollar before it began, and `end` for the words whose last dollar can\n * begin math at the end of a line, which a dollar after it could end.\n */\ninterface DollarEdges {\n start: boolean;\n end?: (atom: string) => boolean;\n}\n/**\n * Join words into the atoms that reflow puts on lines. Whitespace-only words\n * separate atoms; whitespace inside a word, such as in a code span, does not.\n */\nfunction wrappingAtoms(words: string[], openers: RegExp[], dollars?: DollarEdges): string[] {\n const separated: string[] = [];\n let current = \"\";\n for (const word of words) {\n if (/^[ \\t]+$/.test(word)) {\n if (current) separated.push(current);\n current = \"\";\n } else current += word;\n }\n if (current) separated.push(current);\n // Keep atoms that would open a block or underline a Setext heading at the\n // start of a line attached to the preceding atom, and so a dollar that\n // could end math there.\n const joined: string[] = [];\n let dollarBefore = false;\n for (const atom of separated) {\n if (\n joined.length &&\n (openers.some((opener) => opener.test(atom)) ||\n (dollars?.start && dollarBefore && atom.startsWith(\"$\")))\n )\n joined[joined.length - 1] += ` ${atom}`;\n else joined.push(atom);\n if (atom.includes(\"$\")) dollarBefore = true;\n }\n // An atom ending in an unescaped backslash would become a hard break at the\n // end of a line; keep it attached to the following atom, and so one ending\n // in a dollar that could begin math there.\n let lastDollar = -1;\n joined.forEach((atom, index) => {\n if (atom.includes(\"$\")) lastDollar = index;\n });\n const atoms: string[] = [];\n for (let i = 0; i < joined.length; i++) {\n let atom = joined[i]!;\n while (\n i < joined.length - 1 &&\n (/(?:^|[^\\\\])(?:\\\\\\\\)*\\\\$/.test(atom) || (i < lastDollar && dollars?.end?.(atom)))\n )\n atom += ` ${joined[++i]}`;\n atoms.push(atom);\n }\n return atoms;\n}\n/**\n * Words that open a block or underline a heading at the start of a line, the\n * way CommonMark does with them: as a whole word only. These are list markers,\n * ATX heading markers, and runs of the character of a thematic break or a\n * Setext underline, which a line of such words alone forms. A word that only\n * starts with those characters, such as `--config`, `*delta*`, `#tag`, or\n * `-5`, opens nothing.\n */\nconst wordOpener = /^(?:[-+*]|\\d{1,9}[.)]|#{1,6}|\\*+|-+|_+|=+)$/;\n/**\n * The words of a GFM table's delimiter row, which a line of them alone forms\n * below a line that then becomes the table's header row.\n */\nconst delimiterRowWord = /^[|:-]*[|-][|:-]*$/;\n/**\n * Word starts that open a block whatever follows them on the line: block\n * quotes, fences, math, Obsidian comments, HTML blocks, and footnote\n * definitions.\n */\nconst prefixOpener = /^(?:>|~{3,}|`{3,}|\\$\\$|%%|<[!?/A-Za-z]|\\[\\^[^\\]]+\\]:)/;\n/** A word that ends in an unescaped dollar, which can begin dollar math at the end of a line. */\nconst dollarEnd = /(?:^|[^\\\\])(?:\\\\\\\\)*\\$$/;\n/**\n * A paragraph's first word that would open a thematic break or TOML front\n * matter alone on the first line. The paragraph's first line holds more than\n * this word, so it opened neither there.\n */\nconst firstWordAlone = /^(?:(?:\\*[ \\t]*){3,}|(?:-[ \\t]*){3,}|(?:_[ \\t]*){3,}|\\+\\+\\+)$/;\n/**\n * The start of a fence or of display math, which the first line of a\n * paragraph can start with when what follows on the line, such as a backtick\n * after a backtick fence, keeps it from opening one.\n */\nconst fenceStart = /^(?:`{3,}|~{3,}|\\$\\$)/;\n/** A link reference definition's label and colon, which a paragraph can start with. */\nconst definitionStart = /^\\[(?:[^[\\]\\\\]|\\\\[^])+\\]:/;\n/** A GFM table's delimiter row, such as `| --- | :-: |`, after any container markers. */\nconst delimiterRow = /^[ \\t>]*\\|?[ \\t]*:?-+:?[ \\t]*(?:\\|[ \\t]*:?-+:?[ \\t]*)*\\|?[ \\t]*$/;\n/**\n * Whether text that the parser read as a paragraph or a heading's text has a\n * table delimiter row as its second line. GitHub reads a table there, and so\n * does the parser, except directly below a table that ends in a list item or\n * block quote, where it reads the lines as text (issue #283). Joining the lines\n * or adding a blank line above them would change what GitHub or the parser\n * reads.\n */\nfunction misreadTable(text: string): boolean {\n const second = text.split(lineBreak, 2)[1];\n return second !== undefined && second.includes(\"|\") && delimiterRow.test(second);\n}\n// Forgejo and Gitea additionally open display math with `\\[` and definition\n// descriptions with `:` followed by at least one space or tab, so only a bare\n// `:` atom could open one at the start of a reflowed line.\nconst forgeLineOpener = /^(?::$|\\\\\\[)/;\n/**\n * Site-generator syntax at the start of a line: a container such as\n * Docusaurus's `:::note`, or a template tag such as Liquid's `{% tab %}` or\n * `{{ title }}`. Site generators read it by line, and no dialect gives it\n * meaning, so a paragraph with a line that starts with it keeps its lines, and\n * a word that starts with it stays on the line before it (issue #296).\n */\nconst siteSyntax = /^(?::::|\\{%|\\{\\{)/;\n/**\n * The template tags in `text`, which starts at offset `base`, that each lie on\n * one line, such as Liquid's `{% data x %}` or `{{ page.title }}`: wrapping\n * keeps them whole.\n */\nfunction templateTags(text: string, base: number): Range[] {\n const ranges: Range[] = [];\n if (!text.includes(\"{%\") && !text.includes(\"{{\")) return ranges;\n let at = base;\n for (const line of text.split(/(?<=\\n|\\r(?!\\n))/)) {\n for (const [open, close] of [\n [\"{%\", \"%}\"],\n [\"{{\", \"}}\"],\n ] as const)\n for (let from = 0; ;) {\n const opener = line.indexOf(open, from);\n const closer = opener < 0 ? -1 : line.indexOf(close, opener + open.length);\n if (closer < 0) break;\n ranges.push([at + opener, at + closer + close.length]);\n from = closer + close.length;\n }\n at += line.length;\n }\n return ranges;\n}\n/** Whether a line of a paragraph, after its container markers, starts with `siteSyntax`. */\nfunction startsSiteSyntax(text: string): boolean {\n return text\n .split(lineBreak)\n .some((line, index) => siteSyntax.test(index ? line.replace(/^[ \\t>]+/, \"\") : line));\n}\n/**\n * A list, heading, or block quote marker as the whole first word of a\n * paragraph, with more words after it. Directly below text, the parser reads\n * a marker that would open an empty list item there, such as the second `-` of\n * `- -`, as text, and the paragraph can continue on the next line. Joining the\n * next word to the marker would open the block. On Forgejo and Gitea, a bare\n * `:` joined to the next word would turn a paragraph above it into the term of\n * a definition list.\n */\nconst leadingMarker = /^(?:[-+*]|\\d{1,9}[.)]|#{1,6}|>)[ \\t\\r\\n]/;\n\ntype Range = [number, number];\n/**\n * The positions of a paragraph's source where whitespace is not a wrapping\n * opportunity: those strictly inside a protected source range.\n */\nclass Protection {\n private readonly mask: Uint8Array;\n constructor(\n private readonly start: number,\n end: number,\n ) {\n this.mask = new Uint8Array(Math.max(0, end - start));\n }\n add(from: number, to: number) {\n this.mask.fill(1, Math.max(0, from + 1 - this.start), Math.max(0, to - this.start));\n }\n has(at: number): boolean {\n return this.mask[at - this.start] === 1;\n }\n /** Split text that starts at offset `base` at whitespace outside protected ranges. */\n split(text: string, base: number): string[] {\n const words: string[] = [];\n let cursor = 0;\n for (const match of text.matchAll(/[ \\t]+/g)) {\n if (this.has(base + match.index)) continue;\n if (match.index > cursor) words.push(text.slice(cursor, match.index));\n words.push(match[0]);\n cursor = match.index + match[0].length;\n }\n if (cursor < text.length) words.push(text.slice(cursor));\n return words;\n }\n}\n/**\n * What reflow does with a line ending inside an inline node that it keeps\n * whole: in a code span it becomes the space that it renders as, and so it\n * does in an image description; elsewhere it keeps the paragraph as written,\n * for the reason given. In the text of a link kept whole, it does what the\n * atom `within` it there does, and otherwise what it does in a description.\n */\ntype Joining = \"code\" | \"description\" | { reason: string } | { within: InlineAtom[] };\ninterface InlineAtom {\n from: number;\n to: number;\n joining: Joining;\n}\n/**\n * Inline containers whose text reflow wraps like the paragraph's own: a line\n * ending in them renders as a space, like one between words. Their delimiters,\n * and a link's destination, title, or reference label, stay attached to the\n * neighboring words.\n */\nconst wrappable = new Set<string>([\"emphasis\", \"strong\", \"delete\", \"link\", \"linkReference\"]);\nconst lineBreakIn: Record<string, string> = {\n html: \"inline HTML\",\n inlineMath: \"math\",\n obsidianComment: \"an Obsidian comment\",\n};\nfunction located(node: Nodes): boolean {\n return node.position?.start.offset !== undefined && node.position.end.offset !== undefined;\n}\nfunction holds(node: Nodes, type: string): boolean {\n let found = false;\n walk(node, (child) => {\n if (child.type === type) found = true;\n });\n return found;\n}\n/**\n * The inline nodes of a paragraph, from `start` on, that reflow keeps whole,\n * sorted by position, and the hard line breaks anywhere in it. A container\n * that holds inline HTML is kept whole too, because HTML can make the\n * whitespace inside it significant. With `wholeLinks`, the text of a link is\n * kept whole as an image's description is: Obsidian's Live Preview shows a\n * link whose text spans lines as Markdown source (issue #306).\n */\nfunction inlineAtoms(\n paragraph: Paragraph,\n start: number,\n wholeLinks: boolean,\n): { atoms: InlineAtom[]; breaks: Range[]; unlocated: boolean } {\n const atoms: InlineAtom[] = [];\n const breaks: Range[] = [];\n let unlocated = false;\n const destination = { reason: \"line break in a link destination or title\" };\n const visit = (parent: Parents) => {\n for (const child of parent.children) {\n if (child.type === \"text\") continue;\n if (!located(child)) {\n unlocated = true;\n continue;\n }\n const [a, b] = range(child);\n if (b <= start) continue;\n if (child.type === \"break\") breaks.push([a, b]);\n else if (\n wholeLinks &&\n (child.type === \"link\" || child.type === \"linkReference\") &&\n child.children.length &&\n labelEnd(child) &&\n !holds(child, \"html\")\n ) {\n // The code spans, images, and other atoms in the text keep their own\n // joining; between them, a line ending joins with the space that it\n // renders as, as in an image's description.\n const close = labelEnd(child)!;\n const inner = atoms.length;\n visit(child);\n const within = atoms.splice(inner).sort((x, y) => x.from - y.from);\n atoms.push({ from: a, to: close, joining: { within } });\n atoms.push({ from: close, to: b, joining: destination });\n } else if (\n wrappable.has(child.type) &&\n \"children\" in child &&\n child.children.length &&\n !holds(child, \"html\")\n ) {\n if (child.type === \"link\" || child.type === \"linkReference\") {\n const close = labelEnd(child) ?? range(child.children.at(-1)!)[1];\n atoms.push({ from: close, to: b, joining: destination });\n }\n visit(child);\n } else if (child.type === \"inlineCode\") atoms.push({ from: a, to: b, joining: \"code\" });\n else if ((child.type === \"image\" || child.type === \"imageReference\") && labelEnd(child)) {\n const close = labelEnd(child)!;\n atoms.push({ from: a, to: close, joining: \"description\" });\n atoms.push({ from: close, to: b, joining: destination });\n } else {\n const name = lineBreakIn[child.type] ?? (holds(child, \"html\") ? \"inline HTML\" : undefined);\n const reason = `line break in ${name ?? \"inline syntax\"}`;\n atoms.push({ from: a, to: b, joining: { reason } });\n }\n }\n };\n visit(paragraph);\n atoms.sort((x, y) => x.from - y.from);\n return { atoms, breaks, unlocated };\n}\n/** The atom whose source holds `at`, among atoms sorted by position. */\nfunction atomAt(atoms: InlineAtom[], at: number): InlineAtom | undefined {\n let low = 0;\n let high = atoms.length - 1;\n while (low <= high) {\n const middle = (low + high) >> 1;\n const atom = atoms[middle]!;\n if (at <= atom.from) high = middle - 1;\n else if (at >= atom.to) low = middle + 1;\n else return atom;\n }\n return undefined;\n}\n/**\n * The width of a line or line prefix, with a tab advancing to the next\n * multiple of four columns, the tab stop that CommonMark uses for indentation.\n */\nfunction lineWidth(text: string, measure: (text: string) => number): number {\n if (!text.includes(\"\\t\")) return measure(text);\n let width = 0;\n for (const part of text.split(/(\\t)/)) width += part === \"\\t\" ? 4 - (width % 4) : measure(part);\n return width;\n}\n/** Whether text parses as a single paragraph. */\nfunction oneParagraph(text: string, dialect: Dialect): boolean {\n const { children } = parse(text, dialect).tree;\n return children.length === 1 && children[0]!.type === \"paragraph\";\n}\n/**\n * Syntax that Forgejo and Gitea render but GFM parses as prose. A line starting\n * with `:` and a space turns the preceding lines into a definition list and `\\[`\n * opens display math, so such paragraphs keep their lines. `\\(...\\)` math and\n * `[[...]]` shortlinks are recognized within one physical line: a pair on one\n * line becomes an unbreakable atom, and a pair split across lines, which reflow\n * could join, protects the whole paragraph. Gitea parses the backslash math\n * delimiters only where an administrator enables them, which a document does\n * not reveal, so they are protected there too.\n */\nfunction forgeProtections(\n source: string,\n start: number,\n end: number,\n forge: string,\n): { ranges: Range[]; reason?: string } {\n const ranges: Range[] = [];\n for (const line of source.slice(start, end).split(lineBreak)) {\n const content = line.replace(/^[ \\t>]+/, \"\");\n if (/^:[ \\t]/.test(content)) return { ranges, reason: `${forge} definition list` };\n if (content.startsWith(\"\\\\[\")) return { ranges, reason: `${forge} display math` };\n }\n for (const [open, close] of [\n [\"\\\\(\", \"\\\\)\"],\n [\"[[\", \"]]\"],\n ] as const) {\n let from = start;\n for (;;) {\n const opener = source.indexOf(open, from);\n if (opener < 0 || opener >= end) break;\n const closer = source.indexOf(close, opener + open.length);\n if (closer < 0 || closer >= end) break;\n if (lineBreak.test(source.slice(opener, closer)))\n return { ranges, reason: `${forge} ${open}...${close} syntax spanning lines` };\n ranges.push([opener, closer + close.length]);\n from = closer + close.length;\n }\n }\n return { ranges };\n}\n/**\n * Whether reflow could change Gitea emphasis under its `_.py` exception: the\n * paragraph contains `_.py` and an underscore that Gitea's parser could treat\n * as a delimiter. Underscores inside code spans are safe only without `$` or\n * `\\(` math, which can consume a backtick that GFM reads as opening a code span.\n */\nfunction giteaPyParagraph(source: string, node: Paragraph, start: number, end: number): boolean {\n const text = source.slice(start, end);\n if (!text.includes(\"_.py\")) return false;\n if (/\\$|\\\\\\(/.test(text)) return true;\n const code: Range[] = [];\n walk(node, \"inlineCode\", (child) => {\n code.push(range(child));\n });\n for (let at = text.indexOf(\"_\"); at >= 0; at = text.indexOf(\"_\", at + 1)) {\n if (!code.some(([a, b]) => start + at >= a && start + at < b)) return true;\n }\n return false;\n}\n/** Inline nodes whose source joined lines cannot change. */\nconst obsidianOpaque = new Set([\"inlineCode\", \"inlineMath\", \"wikiLink\", \"obsidianHighlight\"]);\n/**\n * Whether joining an Obsidian paragraph's lines could create a highlight or a\n * wikilink. The parser reads neither across a line break, so `==` and `[[` or\n * `]]` that it left as text, outside code, math, and the highlights and links\n * that it did read, could pair up once two lines become one.\n */\nfunction obsidianMarkers(source: string, node: Paragraph, start: number, end: number): boolean {\n if (!/==|\\[\\[|\\]\\]/.test(source.slice(start, end))) return false;\n const opaque: Range[] = [];\n walk(node, (child) => {\n if (obsidianOpaque.has(child.type)) opaque.push(range(child));\n });\n let text = \"\";\n let cursor = start;\n for (const [a, b] of opaque.sort((x, y) => x[0] - y[0])) {\n if (b <= cursor) continue;\n // A space keeps the text on both sides from forming a marker.\n text += source.slice(cursor, Math.max(cursor, a)) + \" \";\n cursor = Math.min(Math.max(cursor, b), end);\n }\n text += source.slice(cursor, end);\n return /==|\\[\\[|\\]\\]/.test(text);\n}\n/** A line's container prefix, with list item markers and checkboxes made blank. */\nfunction continuationOf(prefix: string): string {\n return prefix.replace(/(?:[-+*]|\\d+[.)]|\\[[xX ]\\])(?=\\s)/g, (value) => \" \".repeat(value.length));\n}\n\nconst wrap: Rule = {\n description: \"Reflow paragraphs using configurable width and protected inline atoms.\",\n kind: \"style\",\n phase: \"block\",\n schema: optionsSchema({\n width: { type: \"integer\", minimum: 20, maximum: 500 },\n measure: { enum: [\"columns\", \"codepoints\"] },\n reportUnreflowed: { type: \"boolean\" },\n reportUnbreakable: { type: \"boolean\" },\n }),\n check({ document, options, workspace }) {\n if (document.dialect === \"obsidian\" && workspace?.strictLineBreaks !== true) return [];\n const findings: Finding[] = [];\n const width = Number(options.width ?? 80);\n const measure =\n options.measure === \"codepoints\" ? (text: string) => [...text].length : stringWidth;\n const unit = options.measure === \"codepoints\" ? \"code points\" : \"columns\";\n // Detect the line ending once; scanning the whole source per paragraph is quadratic.\n const newline = lineEnding(document.source);\n walk(document.tree, \"paragraph\", (node, index, parent) => {\n const [paragraphStart, end] = range(node);\n let start = paragraphStart;\n let children = node.children;\n // A task item's paragraph range can begin at the checkbox, and its first\n // text node can begin with the separator. Wrap only the content after them.\n if (children[0]) {\n start = Math.max(start, range(children[0])[0]);\n while (start < end && /[ \\t]/.test(document.source[start]!)) start++;\n }\n let original = document.source.slice(start, end);\n const forge = goldmarkForges[document.dialect];\n // An Obsidian callout or a GitHub, Forgejo, or Gitea alert keeps the line\n // with its marker, and its title in Obsidian, as written. On Forgejo and\n // Gitea, a marker written as `\\[!NOTE]` starts like display math, and\n // its paragraph stays as written.\n let calloutHeader =\n document.dialect !== \"commonmark\" &&\n parent?.type === \"blockquote\" &&\n index === 0 &&\n startsWithMarker(original, node) &&\n !(forge && original.startsWith(\"\\\\[\"));\n /** Whether the lines to wrap are the body below that line, in the same paragraph. */\n let belowHeader = false;\n let lineStart = start;\n while (lineStart > 0 && !/[\\r\\n]/.test(document.source[lineStart - 1]!)) lineStart--;\n let prefix = document.source.slice(lineStart, start);\n const continuation = continuationOf(prefix);\n // Directly below a link reference definition, a paragraph can start with\n // a lazy continuation line, which lacks some of the container markers of\n // the lines around it. The later lines' prefixes cannot be told from it.\n const above = index ? parent?.children[index - 1] : undefined;\n let lazyStart = false;\n if (\n above?.type === \"definition\" &&\n above.position!.end.line === node.position!.start.line - 1\n ) {\n const [definitionStart] = range(above);\n const definitionLine = lineBounds(document.source, definitionStart, definitionStart)[0];\n lazyStart =\n continuationOf(document.source.slice(definitionLine, definitionStart)) !== continuation;\n }\n if (calloutHeader) {\n const headerBreak = lineBreak.exec(original);\n const headerEnd = headerBreak ? start + headerBreak.index : end;\n const header = document.source.slice(start, headerEnd);\n const bodyStart = headerEnd + (headerBreak?.[0].length ?? 0) + continuation.length;\n const bodyLines = headerBreak\n ? original.slice(headerBreak.index + headerBreak[0].length).split(lineBreak)\n : [];\n const supported =\n bodyLines.every((line) => line.startsWith(continuation)) &&\n !children.some((child) => {\n const [a, b] = range(child);\n return child.type !== \"text\" && a < bodyStart && b > bodyStart;\n });\n // Keep unusual continuations and inline syntax spanning the boundary untouched.\n if (supported) {\n if (options.reportUnbreakable === true && lineWidth(prefix + header, measure) > width)\n findings.push({\n start,\n end: start + header.length,\n message: `Paragraph exceeds ${width} ${unit} because of an unbreakable atom.`,\n });\n if (!headerBreak) return;\n start = bodyStart;\n original = document.source.slice(start, end);\n children = children.filter((child) => range(child)[1] > start);\n prefix = continuation;\n calloutHeader = false;\n belowHeader = true;\n }\n }\n const openers = [wordOpener, prefixOpener, siteSyntax];\n if (document.dialect !== \"commonmark\") openers.push(delimiterRowWord);\n if (forge) openers.push(forgeLineOpener);\n const { source } = document;\n // GitHub and Obsidian end dollar math at a single dollar after a line\n // ending, but not after a space, so a word that starts with `$` stays on\n // the line of the word before it when a dollar comes before it. Obsidian\n // also begins math at a single dollar before a line ending, but not\n // before a space, so a word that ends in a dollar of its text, such as a\n // lone `$`, stays on the line of the word after it when a dollar comes\n // after it. Forgejo and Gitea have neither condition.\n const maths: string[] = [];\n if (document.dialect === \"obsidian\")\n walk(node, \"inlineMath\", (math) => {\n maths.push(source.slice(...range(math)));\n });\n const dollars: DollarEdges = {\n start: document.dialect === \"github\" || document.dialect === \"obsidian\",\n ...(document.dialect === \"obsidian\"\n ? {\n end: (atom: string) =>\n dollarEnd.test(atom) && !maths.some((math) => atom.endsWith(math)),\n }\n : {}),\n };\n const inline = inlineAtoms(node, start, document.dialect === \"obsidian\");\n const protection = new Protection(start, end);\n for (const atom of inline.atoms) protection.add(atom.from, atom.to);\n // Forgejo and Gitea protections apply before paragraphs are skipped, so\n // that diagnostics still count one-line math and shortlinks as atoms.\n const protections = forge\n ? forgeProtections(source, start, end, forge)\n : { ranges: [] as Range[] };\n for (const [from, to] of protections.ranges) protection.add(from, to);\n for (const [from, to] of templateTags(source.slice(start, end), start))\n protection.add(from, to);\n const reportUnbreakable = () =>\n findings.push({\n start,\n end,\n message: `Paragraph exceeds ${width} ${unit} because of an unbreakable atom.`,\n });\n const reportSkipped = (reason: string) => {\n if (options.reportUnreflowed !== true && options.reportUnbreakable !== true) return;\n let breakable = false;\n let unbreakable = false;\n let offset = start;\n for (const line of original.split(/(?<=\\n|\\r(?!\\n))/)) {\n const content = line.replace(/(?:\\r\\n|\\r|\\n)$/, \"\");\n const container =\n offset === start\n ? \"\"\n : continuation && content.startsWith(continuation)\n ? continuation\n : (content.match(/^[ \\t>]+/)?.[0] ?? \"\");\n const linePrefix = offset === start ? prefix : container;\n // An Obsidian title occupies one physical line, even when it contains spaces.\n if (calloutHeader && offset === start) {\n if (lineWidth(prefix + content, measure) > width) unbreakable = true;\n offset += line.length;\n continue;\n }\n // Hard-break markers do not count toward the width.\n let contentEnd = offset + content.length;\n for (const [a] of inline.breaks) if (a >= offset && a < contentEnd) contentEnd = a;\n const from = offset + container.length;\n const words = protection.split(source.slice(from, contentEnd), from);\n const atoms = wrappingAtoms(words, openers, dollars);\n const available = width - lineWidth(linePrefix, measure);\n if (measure(words.join(\"\").trimEnd()) > available) {\n if (atoms.length > 1) breakable = true;\n if (atoms.some((atom) => measure(atom) > available)) unbreakable = true;\n }\n offset += line.length;\n }\n if (options.reportUnreflowed === true && breakable)\n findings.push({\n start,\n end,\n message: `Paragraph not reflowed: ${reason} (width ${width} ${unit}).`,\n });\n if (options.reportUnbreakable === true && unbreakable) reportUnbreakable();\n };\n // Only the first paragraph of a block quote can be a callout, so a\n // paragraph elsewhere that starts with a linked image, `[![`, is wrapped.\n // Below the line of a marker, the paragraph's text no longer starts the\n // lines to wrap.\n const markerLike = /^\\[![^\\]]+\\]/;\n const startsLikeMarker =\n parent?.type === \"blockquote\" &&\n index === 0 &&\n (belowHeader ? markerLike.test(original) : startsWithMarker(original, node, markerLike));\n const reason = inline.breaks.length\n ? \"hard line break\"\n : children.some((child) => child.type === \"html\")\n ? \"inline HTML\"\n : startsLikeMarker\n ? \"callout header\"\n : blockIdentifier(document.source, node)\n ? \"block identifier\"\n : leadingMarker.test(original) || (forge && /^:(?:\\r|\\n)/.test(original))\n ? \"leading block marker\"\n : document.dialect !== \"commonmark\" && misreadTable(original)\n ? \"table delimiter row as its second line\"\n : startsSiteSyntax(original)\n ? \"site-generator syntax at the start of a line\"\n : lazyStart\n ? \"lazy first line\"\n : !/^[\\s>\\-*+\\d.[\\]xX)]*$/.test(prefix)\n ? \"unsupported container prefix\"\n : document.dialect === \"obsidian\" &&\n obsidianMarkers(source, node, start, end)\n ? \"Obsidian `==`, `[[`, or `]]` outside highlights and links\"\n : inline.unlocated\n ? \"inline syntax without a source position\"\n : undefined;\n const skipped =\n reason ??\n protections.reason ??\n (document.dialect === \"gitea\" && giteaPyParagraph(source, node, start, end)\n ? \"Gitea `_.py` emphasis exception\"\n : undefined);\n if (skipped) {\n reportSkipped(skipped);\n return;\n }\n // Collect the words line by line, without the container prefixes. A line\n // ending between words, or in the text of emphasis or a link, separates\n // words like a space. One inside an atom joins its lines with the space\n // that it renders as, or keeps the paragraph as written.\n const words: string[] = [];\n let failure: string | undefined;\n const pieces = original.split(/(\\r\\n|\\r|\\n)/);\n let at = start;\n let lineEnd = start;\n for (let i = 0; i < pieces.length && !failure; i += 2) {\n let line = pieces[i]!;\n let lineAt = at;\n at += line.length + (pieces[i + 1]?.length ?? 0);\n if (i > 0) {\n if (continuation && line.startsWith(continuation)) {\n line = line.slice(continuation.length);\n lineAt += continuation.length;\n } else if (continuation && /^[\\s>]/.test(line)) {\n failure = \"unsupported continuation\";\n break;\n }\n const last = words.at(-1);\n let joining = protection.has(lineEnd)\n ? (atomAt(inline.atoms, lineEnd)?.joining ?? { reason: \"line break in inline syntax\" })\n : undefined;\n if (joining && typeof joining === \"object\" && \"within\" in joining)\n joining = atomAt(joining.within, lineEnd)?.joining ?? \"description\";\n if (!joining) words.push(\" \");\n else if (last === undefined || /^[ \\t]+$/.test(last))\n failure = \"line break in inline syntax\";\n else if (joining === \"code\" || joining === \"description\") {\n // In an image description, two spaces or a backslash before the\n // line ending make a hard break, and other spaces collapse; in a\n // code span, the spaces before it are code. The spaces and tabs\n // after it go, as `codeSpanText` reads the span, also the\n // indentation below a task item's checkbox, which the parser\n // keeps. A lazy line, which keeps them, is not supported above.\n if (joining === \"description\" && /(?: {2}|\\\\)$/.test(last)) failure = \"hard line break\";\n const trimmed = line.replace(/^[ \\t]+/, \"\");\n lineAt += line.length - trimmed.length;\n line = trimmed;\n words[words.length - 1] = `${joining === \"code\" ? last : last.trimEnd()} `;\n } else failure = \"reason\" in joining ? joining.reason : \"line break in inline syntax\";\n }\n words.push(...protection.split(line, lineAt));\n lineEnd = lineAt + line.length;\n }\n if (failure) {\n reportSkipped(failure);\n return;\n }\n const atoms = wrappingAtoms(words, openers, dollars);\n if (!atoms.length) return;\n // The first line keeps the words after a first word that would open a\n // block alone on the line, until the line can no longer open one, and\n // below an alert's or callout's marker line, after a run of `=` or `-`\n // that would underline that line as a heading.\n while (\n atoms.length > 1 &&\n (firstWordAlone.test(atoms[0]!) ||\n (belowHeader && /^(?:=+|-+)$/.test(atoms[0]!)) ||\n (fenceStart.test(atoms[0]!) && !oneParagraph(atoms[0]!, document.dialect)))\n )\n atoms.splice(0, 2, `${atoms[0]} ${atoms[1]}`);\n /** Fill lines greedily, with the first `first` atoms on the first line. */\n const fill = (first: number): string[] => {\n const lines: string[] = [];\n let line = atoms.slice(0, first).join(\" \");\n let linePrefix = prefix;\n for (let i = first; i < atoms.length; i++) {\n const candidate = `${line} ${atoms[i]}`;\n if (lineWidth(linePrefix + candidate, measure) > width) {\n lines.push(line);\n line = atoms[i]!;\n linePrefix = continuation;\n } else line = candidate;\n }\n if (line) lines.push(line);\n return lines;\n };\n let output = fill(1);\n // A paragraph that starts like a link reference definition becomes one\n // when a line ends after the definition's destination or title. Keep\n // words on the first line until the lines read as one paragraph again.\n if (output.length > 1 && atoms[0]!.startsWith(\"[\") && definitionStart.test(atoms.join(\" \"))) {\n let first = atoms.findIndex((atom) => atom.includes(\"]:\")) + 1;\n while (output.length > 1 && !oneParagraph(output.join(\"\\n\"), document.dialect))\n output = fill(++first);\n }\n const replacement = output.join(newline + continuation);\n if (replacement !== original)\n findings.push({\n start,\n end,\n message: `Reflow paragraph to ${width} ${unit}.`,\n edit: { start, end, text: replacement },\n });\n if (\n options.reportUnbreakable === true &&\n (prefix + replacement).split(lineBreak).some((line) => lineWidth(line, measure) > width)\n )\n reportUnbreakable();\n });\n return findings;\n },\n};\n\nconst table: Rule = {\n description: \"Align or compact GFM table cells while preserving their inline source.\",\n kind: \"style\",\n phase: \"block\",\n schema: optionsSchema({ style: { enum: [\"aligned\", \"compact\"] } }),\n check({ document, options }) {\n const findings: Finding[] = [];\n // A compact table has one space around each cell and the shortest delimiters.\n const compact = options.style === \"compact\";\n const newline = lineEnding(document.source);\n walk(document.tree, \"table\", (node) => {\n const [start, end] = range(node);\n // Nested tables retain container prefixes until a dedicated container printer handles them.\n if (node.position!.start.column !== 1) return;\n const rows = node.children.map((row) =>\n row.children.map((cell) => {\n if (!cell.children.length) return \"\";\n const first = range(cell.children[0]!)[0];\n const last = range(cell.children.at(-1)!)[1];\n return document.source.slice(first, last);\n }),\n );\n const count = node.align?.length ?? rows[0]?.length ?? 0;\n if (rows.some((row) => row.length > count)) return;\n const widths = Array.from({ length: count }, (_, i) =>\n compact ? 3 : Math.max(3, ...rows.map((row) => stringWidth(row[i] ?? \"\"))),\n );\n const pad = (cell: string, i: number) =>\n compact ? cell : cell + \" \".repeat(widths[i]! - stringWidth(cell));\n // Keep each row's own cell count: adding cells to a short row changes the parsed table.\n const rendered = rows.map((row) => `| ${row.map(pad).join(\" | \")} |`);\n rendered.splice(\n 1,\n 0,\n `| ${widths\n .map((width, i) => {\n const align = node.align?.[i];\n return (\n (align === \"left\" || align === \"center\" ? \":\" : \"-\") +\n \"-\".repeat(width - 2) +\n (align === \"right\" || align === \"center\" ? \":\" : \"-\")\n );\n })\n .join(\" | \")} |`,\n );\n const replacement = rendered.join(newline);\n if (replacement !== document.source.slice(start, end))\n findings.push({\n start,\n end,\n message: compact ? \"Write the table compactly.\" : \"Align table cells.\",\n edit: { start, end, text: replacement },\n });\n });\n return findings;\n },\n};\n\n/** A line holding nothing but block quote markers and blank space. */\nconst blankLine = /^[ \\t>]*$/;\n/**\n * A list item or quote marker followed by another list marker on its line,\n * including the ones that cannot open a list there, such as `* * *`.\n */\nconst nestedListStart = /^[ \\t]*(?:[-+*]|\\d{1,9}[.)]|>)[ \\t>]*(?:[-+*]|\\d{1,9}[.)])(?:[ \\t]|$)/;\n/** The innermost last block of a container, where its text ends. */\nfunction lastBlock(node: RootContent): RootContent {\n while (\n [\"blockquote\", \"list\", \"listItem\", \"footnoteDefinition\"].includes(node.type) &&\n \"children\" in node &&\n node.children.length\n )\n node = node.children.at(-1) as RootContent;\n return node;\n}\n/**\n * Whether two neighboring blocks have to stay as they are, although one of\n * them is a heading or a list, because a blank line between them would change\n * what they mean or what a comment or callout applies to.\n */\nfunction together(\n document: Document,\n parent: Root | Blockquote,\n index: number,\n directiveLines: Set<number>,\n): boolean {\n const before = parent.children[index - 1]!;\n const after = parent.children[index]!;\n const { source } = document;\n const [beforeStart, beforeEnd] = range(before);\n const [afterStart, afterEnd] = range(after);\n // Front matter is not part of the document's text.\n if ([\"yaml\", \"toml\"].includes(before.type)) return true;\n // An unclosed HTML comment or block at the end of a list would take in the blank line.\n if (takesLines(before)) return true;\n // Other tools, too, read a comment as applying to the line below it, and\n // `mdtools-disable-next-line` does: a blank line would take that line's place.\n if (before.type === \"html\" && /^<!--[^]*-->$/.test(before.value.trim())) return true;\n if (directiveLines.has(after.position!.start.line - 1)) return true;\n // The line that opens a callout or alert stays with the body below it.\n if (\n index === 1 &&\n parent.type === \"blockquote\" &&\n before.type === \"paragraph\" &&\n before.position!.start.line === before.position!.end.line &&\n startsWithMarker(source.slice(beforeStart, beforeEnd), before)\n )\n return true;\n // Obsidian may attach a block identifier on its own line to the block above.\n const alone = document.dialect === \"obsidian\" ? blockIdentifier(source, after) : undefined;\n if (alone && source.slice(afterStart, afterEnd).trimEnd() === `^${alone.id}`) return true;\n // Directly below a table that ends inside a list or block quote, the parser\n // reads the next table as a paragraph, or as the text of a heading\n // underlined below it, while GitHub reads a table, and a blank line would\n // make it a table there as well.\n if (\n document.dialect !== \"commonmark\" &&\n (after.type === \"paragraph\" || after.type === \"heading\") &&\n misreadTable(source.slice(afterStart, afterEnd))\n )\n return true;\n // In a block quote, the parser counts a line of quote markers below a list\n // that ends in an empty footnote definition as part of the list item, which\n // makes the item loose.\n const last = lastBlock(before);\n if (\n parent.type === \"blockquote\" &&\n before.type === \"list\" &&\n last.type === \"footnoteDefinition\" &&\n !last.children.length\n )\n return true;\n // Directly below text or a link reference definition, the parser does not\n // start a list that would be empty or not start at 1, though it does below\n // a blank line: there, `- -` is a list item holding the text `-`, and `-`\n // underlined with `---` is a heading. Such a list could start on the first\n // line of a list or quote, and such a line could begin an underlined heading.\n if (![\"paragraph\", \"definition\"].includes(lastBlock(before).type)) return false;\n const firstLine = source.slice(afterStart, lineBounds(source, afterStart, afterStart)[1]);\n if (after.type === \"heading\") return !/^[ \\t]*#/.test(firstLine);\n return (after.type === \"list\" || after.type === \"blockquote\") && nestedListStart.test(firstLine);\n}\nconst blockSpacing: Rule = {\n description: \"Separate headings and lists from neighboring blocks with a blank line.\",\n kind: \"style\",\n phase: \"block\",\n schema: optionsSchema({}),\n check({ document }) {\n const { source } = document;\n const findings: Finding[] = [];\n const newline = lineEnding(source);\n const directiveLines = new Set<number>();\n if (source.includes(\"mdtools-\"))\n walk(document.tree, \"html\", (node) => {\n if (directive(node.value)?.kind === \"disable-next-line\")\n directiveLines.add(node.position!.end.line);\n });\n // Only the blocks of the document and of block quotes are compared. A\n // blank line between the blocks of a list item makes its list loose.\n walk(document.tree, (parent) => {\n if (parent.type !== \"root\" && parent.type !== \"blockquote\") return;\n for (let index = 1; index < parent.children.length; index++) {\n const before = parent.children[index - 1]!;\n const after = parent.children[index]!;\n const subject = [after, before].find(\n (node) => node.type === \"heading\" || node.type === \"list\",\n );\n // A plugin's syntax can add a node without a source position.\n const located = [before, after].every(\n ({ position }) =>\n position?.start.offset !== undefined && position.end.offset !== undefined,\n );\n if (!subject || !located || together(document, parent, index, directiveLines)) continue;\n const end = range(before)[1];\n const start = range(after)[0];\n const lineStart = lineBounds(source, start, start)[0];\n const breakStart = lineStart - (source.startsWith(\"\\r\\n\", lineStart - 2) ? 2 : 1);\n if (breakStart < end) continue;\n // A blank line, or one with only quote markers, already separates them.\n const previous = source.slice(lineBounds(source, breakStart, breakStart)[0], breakStart);\n if (blankLine.test(previous)) continue;\n // The block's own line holds the quote markers that the new line needs.\n const prefix = source.slice(lineStart, start);\n if (!blankLine.test(prefix)) continue;\n const kind = subject.type === \"heading\" ? \"heading\" : \"list\";\n findings.push({\n start: subject === after ? start : end,\n message: `Add a blank line ${subject === after ? \"before\" : \"after\"} the ${kind}.`,\n edit: {\n start: breakStart,\n end: lineStart,\n text: source.slice(breakStart, lineStart) + prefix.replace(/[ \\t]+$/, \"\") + newline,\n },\n });\n }\n });\n return findings;\n },\n};\n\nexport const styleRules: Record<string, Rule> = {\n \"style/wrap\": wrap,\n \"style/inline-code\": {\n description: \"Join multiline code spans using their CommonMark rendered value.\",\n kind: \"style\",\n phase: \"inline\",\n schema: optionsSchema({}),\n check({ document }) {\n const findings: Finding[] = [];\n const { source } = document;\n const forge = goldmarkForges[document.dialect] !== undefined;\n // In Obsidian, the inline nodes whose source joined lines cannot change.\n const opaque: Range[] = [];\n if (document.dialect === \"obsidian\")\n walk(document.tree, (node) => {\n if (obsidianOpaque.has(node.type) || node.type === \"obsidianComment\")\n opaque.push(range(node));\n });\n const titles = calloutTitles(document);\n let headingEnd = 0;\n let blockStart = 0;\n walk(document.tree, (node) => {\n if (node.type === \"heading\" && forge) headingEnd = range(node)[1];\n if (inlineBlocks.has(node.type)) blockStart = range(node)[0];\n if (node.type !== \"inlineCode\") return;\n const [start, end] = range(node);\n if (!/[\\r\\n]/.test(source.slice(start, end))) return;\n // Forgejo and Gitea look for a heading's attribute block on its last\n // text line, and Forgejo also builds the anchor from that line alone.\n // Joining lines would change what that line holds.\n if (start < headingEnd) return;\n // Joining keeps the spaces and tabs that start a lazy continuation line,\n // as GitHub shows them; commonmark.js drops them, and the other\n // dialects' renderers were not observed there.\n if (document.dialect !== \"github\" && lazyIndentation(node)) return;\n if (document.dialect === \"gitea\" && giteaPyLine(document, start, end)) return;\n // Joining lines could put a `\\(` and `\\)` on one line and turn them into math.\n if (forge) {\n const lines = document.source.slice(...lineBounds(document.source, start, end));\n if (lines.includes(\"\\\\(\") && lines.includes(\"\\\\)\")) return;\n }\n // Joining would move text onto the line of a callout's or alert's\n // marker, which holds an Obsidian callout's title.\n if (titles.some(([a, b]) => start >= a && start < b)) return;\n if (document.dialect === \"obsidian\") {\n // Obsidian reads highlights and wikilinks only within a line. Once\n // the lines are one, an `==` or `[[` left as text could open one that\n // runs to the next `==` or `]]`, even inside this or another span.\n const [from, to] = lineBounds(source, start, end);\n const lines = source.slice(from, to);\n let text = \"\";\n let cursor = from;\n for (const [a, b] of opaque) {\n if (b <= cursor || a >= to) continue;\n // A space keeps the text on both sides from forming a marker.\n text += source.slice(cursor, Math.max(cursor, a)) + \" \";\n cursor = Math.min(b, to);\n }\n text += source.slice(cursor, to);\n if (\n (text.includes(\"==\") && (lines.match(/==/g) ?? []).length > 1) ||\n (text.includes(\"[[\") && lines.includes(\"]]\"))\n )\n return;\n }\n // The joined span holds the text that GitHub shows. A space at each end\n // keeps a backtick there from joining the fence, or spaces there from\n // being taken off.\n const value = codeSpanText(node);\n const longest = Math.max(0, ...(value.match(/`+/g) ?? []).map((run) => run.length));\n const marker = \"`\".repeat(longest + 1);\n // An earlier run of the new backticks that the parser left as text, or\n // that lies in a link destination, would pair with the new opening one.\n // The span's own backticks cannot have such a run before them.\n if (marker.length !== /^`+/.exec(source.slice(start, end))![0].length) {\n const before = source.slice(blockStart, start);\n for (const run of before.matchAll(/`+/g)) {\n const length = run[0].length;\n if (\n length === marker.length ||\n (escaped(before, run.index) && length - 1 === marker.length)\n )\n return;\n }\n }\n const pad = /^`|`$/.test(value) || (/^ .* $/.test(value) && /[^ ]/.test(value)) ? \" \" : \"\";\n findings.push({\n start,\n end,\n message: \"Join the code span onto one line.\",\n edit: { start, end, text: `${marker}${pad}${value}${pad}${marker}` },\n });\n });\n return findings;\n },\n },\n \"style/emphasis\": markerRule(\"emphasis\", \"_\"),\n \"style/strong\": markerRule(\"strong\", \"*\"),\n \"style/table\": table,\n \"style/final-newline\": {\n description: \"End nonempty documents with a newline.\",\n kind: \"style\",\n phase: \"document\",\n schema: optionsSchema({}),\n check({ document }) {\n const { source } = document;\n // An unclosed block at the end, such as an HTML comment, would take in the line ending.\n if (!source || /[\\r\\n]$/.test(source) || takesFinalLineEnding(document)) return [];\n return [\n {\n start: source.length,\n message: \"Add a final newline.\",\n edit: { start: source.length, end: source.length, text: lineEnding(source) },\n },\n ];\n },\n },\n \"style/heading\": {\n description: \"Use ATX or Setext headings, without closing sequences.\",\n kind: \"style\",\n phase: \"block\",\n schema: optionsSchema({\n style: { enum: [\"atx\", \"setext\", \"consistent\"] },\n closing: { enum: [\"remove\", \"keep\"] },\n }),\n check({ document, options }) {\n const findings: Finding[] = [];\n const { source } = document;\n // Only levels 1 and 2 can be underlined; deeper headings keep their `#`.\n const underlined = underlinedHeadings(document, options.style);\n walk(document.tree, \"heading\", (node) => {\n const [headingStart, end] = range(node);\n const first = node.children[0];\n const last = node.children.at(-1);\n // An ATX heading is one line, a Setext heading also has its underline.\n if (!/[\\r\\n]/.test(source.slice(headingStart, end))) {\n const edit = underlined ? underlineEdit(document, node) : undefined;\n if (edit) {\n findings.push({\n start: edit.start,\n end: edit.end,\n message: \"Use an underlined heading.\",\n edit,\n });\n return;\n }\n if (options.closing === \"keep\") return;\n const textEnd = last\n ? range(last)[1]\n : headingStart + /^#*/.exec(source.slice(headingStart))![0].length;\n const lineEnd = lineBounds(source, textEnd, textEnd)[1];\n if (!/^[ \\t]+#+[ \\t]*$/.test(source.slice(textEnd, lineEnd))) return;\n // Gitea before 1.26 reads an attribute block that a closing sequence\n // follows, and Forgejo and later Gitea versions do not.\n if (\n goldmarkForges[document.dialect] &&\n first &&\n headingAttributeBlock(source.slice(range(first)[0], textEnd))\n )\n return;\n findings.push({\n start: textEnd,\n end: lineEnd,\n message: \"Remove the closing # sequence.\",\n edit: { start: textEnd, end: lineEnd, text: \"\" },\n });\n return;\n }\n if (underlined || !first || !last) return;\n // Below link reference definitions, the heading's position starts at\n // the first definition; its own text starts on a later line. Headings\n // that are indented or inside lists or block quotes are left as written.\n const start = range(first)[0];\n if (lineBounds(source, start, start)[0] !== start) return;\n let text = source.slice(start, range(last)[1]);\n if (/[\\r\\n]/.test(text)) return;\n // A trailing run of # after whitespace would become an ATX closing\n // sequence and disappear from the heading; escape its first character.\n text = text.replace(/(^|\\s)(#+)$/, \"$1\\\\$2\");\n // Forgejo and Gitea also take such a run for a closing sequence when\n // their attribute block follows it, and would drop it from the heading.\n const block = goldmarkForges[document.dialect] ? headingAttributeBlock(text) : undefined;\n if (block)\n text =\n text.slice(0, block.start).replace(/(^|\\s)(#+)(\\s*)$/, \"$1\\\\$2$3\") +\n text.slice(block.start);\n findings.push({\n start,\n end,\n message: \"Use an ATX heading.\",\n edit: { start, end, text: `${\"#\".repeat(node.depth)} ${text}` },\n });\n });\n return findings;\n },\n },\n \"style/block-spacing\": blockSpacing,\n};\n\n/** Collect source-positioned nodes for rule/plugin consumers. */\nexport function nodesOfType(\n document: { tree: import(\"mdast\").Root },\n type: Nodes[\"type\"],\n): Nodes[] {\n const result: Nodes[] = [];\n walk(document.tree, (node) => {\n if (node.type === type) result.push(node);\n });\n return result;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"style.js","sourceRoot":"","sources":["../../src/rules/style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,WAAW,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,KAAK,EACL,KAAK,EACL,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAChG,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAElG,MAAM,UAAU,aAAa,CAAC,UAAmC;IAC/D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;AACrE,CAAC;AACD,oEAAoE;AACpE,MAAM,SAAS,GAAG,YAAY,CAAC;AAC/B,mEAAmE;AACnE,SAAS,UAAU,CAAC,MAAc;IAChC,OAAO,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AAC7C,CAAC;AACD,qEAAqE;AACrE,SAAS,UAAU,CAAC,MAAc,EAAE,KAAa,EAAE,GAA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\";\nimport stringWidth from \"string-width\";\nimport type { Blockquote, Nodes, Paragraph, Parents, Root, RootContent } from \"mdast\";\nimport { directive } from \"../core/directives.js\";\nimport type { Dialect, Document, Finding, Rule } from \"../core/types.js\";\nimport { blockIdentifier } from \"../syntax/block-identifier.js\";\nimport {\n codeSpanText,\n labelEnd,\n lazyIndentation,\n parse,\n range,\n startsWithMarker,\n} from \"../syntax/parse.js\";\nimport { changesForgeHeading, headingAttributeBlock } from \"../workspace/heading-attributes.js\";\nimport { takesFinalLineEnding, takesLines, underlinedHeadings, underlineEdit } from \"./blocks.js\";\n\nexport function optionsSchema(properties: Record<string, unknown>) {\n return { type: \"object\", properties, additionalProperties: false };\n}\n/** Any CommonMark line ending, including a lone carriage return. */\nconst lineBreak = /\\r\\n|\\r|\\n/;\n/** The document's line ending, taken from its first line break. */\nfunction lineEnding(source: string): string {\n return lineBreak.exec(source)?.[0] ?? \"\\n\";\n}\n/** Start and end of the physical lines containing a source range. */\nfunction lineBounds(source: string, start: number, end: number): [number, number] {\n let lineStart = start;\n while (lineStart > 0 && !/[\\r\\n]/.test(source[lineStart - 1]!)) lineStart--;\n let lineEnd = end;\n while (lineEnd < source.length && !/[\\r\\n]/.test(source[lineEnd]!)) lineEnd++;\n return [lineStart, lineEnd];\n}\n/**\n * Where a document's line breaks are, and where the strings that rules look\n * for on a line occur, all sorted. Rules ask about the line of every emphasis\n * or code span; searching the line itself each time took time that grows with\n * the square of a long line's length.\n */\ninterface LineIndex {\n breaks: number[];\n found: Map<string, number[]>;\n}\nconst lineIndexes = new WeakMap<Document, LineIndex>();\nfunction lineIndex(document: Document): LineIndex {\n let index = lineIndexes.get(document);\n if (!index) {\n const breaks: number[] = [];\n for (let at = 0; at < document.source.length; at++)\n if (document.source[at] === \"\\r\" || document.source[at] === \"\\n\") breaks.push(at);\n lineIndexes.set(document, (index = { breaks, found: new Map() }));\n }\n return index;\n}\n/** The number of values in the sorted `values` that are less than `limit`. */\nfunction countBelow(values: number[], limit: number): number {\n let low = 0;\n let high = values.length;\n while (low < high) {\n const middle = (low + high) >> 1;\n if (values[middle]! < limit) low = middle + 1;\n else high = middle;\n }\n return low;\n}\n/** `lineBounds` for a document, from its line index. */\nfunction indexedLineBounds(document: Document, start: number, end: number): [number, number] {\n const { breaks } = lineIndex(document);\n const before = countBelow(breaks, start);\n const after = countBelow(breaks, end);\n return [before ? breaks[before - 1]! + 1 : 0, breaks[after] ?? document.source.length];\n}\n/**\n * Where `text` occurs in the document between `from` and `to`, wholly: the\n * last occurrence, or -1 for none.\n */\nfunction lastWithin(document: Document, text: string, from: number, to: number): number {\n const { found } = lineIndex(document);\n let positions = found.get(text);\n if (!positions) {\n positions = [];\n for (\n let at = document.source.indexOf(text);\n at >= 0;\n at = document.source.indexOf(text, at + 1)\n )\n positions.push(at);\n found.set(text, positions);\n }\n const last = positions[countBelow(positions, to - text.length + 1) - 1];\n return last !== undefined && last >= from ? last : -1;\n}\n/**\n * Gitea does not parse a `_` run as an emphasis delimiter when the next `_` on\n * its physical line starts `_.py`, or when the run itself does and no `_`\n * follows, so `__init__.py` stays literal. The outcome depends on everything\n * else on the line, code spans included: a line containing `_.py` before or\n * after an edit can gain or lose emphasis when markers change or lines join.\n */\nexport function giteaPyLine(document: Document, start: number, end: number): boolean {\n return lastWithin(document, \"_.py\", ...indexedLineBounds(document, start, end)) >= 0;\n}\n/** Forgejo and its upstream Gitea build on goldmark with shared extensions. */\nconst goldmarkForges: Partial<Record<Dialect, string>> = { forgejo: \"Forgejo\", gitea: \"Gitea\" };\n/**\n * Whether a range lies between `\\(` and `\\)` on its line, which Forgejo, and\n * Gitea where enabled, render as math. GFM parses emphasis and code spans\n * there, and changing them would change the formula.\n */\nexport function inForgeMath(document: Document, start: number, end: number): boolean {\n const [lineStart, lineEnd] = indexedLineBounds(document, start, end);\n return (\n lastWithin(document, \"\\\\(\", lineStart, start) > lastWithin(document, \"\\\\)\", lineStart, start) &&\n lastWithin(document, \"\\\\)\", end, lineEnd) >= 0\n );\n}\n/** The blocks whose inline content the parser reads, and pairs delimiters in, as a whole. */\nconst inlineBlocks = new Set([\"paragraph\", \"heading\", \"tableCell\"]);\n/** Whether the character at `index` is escaped by an odd number of backslashes before it. */\nfunction escaped(source: string, index: number): boolean {\n let count = 0;\n while (source[index - count - 1] === \"\\\\\") count++;\n return count % 2 === 1;\n}\n/**\n * How micromark classifies a character next to a delimiter run: 1 for\n * whitespace and for the start or end of the text, 2 for punctuation and\n * symbols, and 0 for anything else. It looks at UTF-16 code units, so half of\n * a surrogate pair counts as anything else.\n */\nfunction characterGroup(character: string | undefined): 0 | 1 | 2 {\n if (character === undefined || /\\s/.test(character)) return 1;\n return /\\p{P}|\\p{S}/u.test(character) ? 2 : 0;\n}\n/** A run of `*` or `_` that micromark reads as one delimiter sequence. */\ninterface DelimiterRun {\n marker: string;\n /** The part of the run that has not paired yet. */\n start: number;\n end: number;\n open: boolean;\n close: boolean;\n}\n/**\n * Whether the installed micromark lets a run of `*` or `_` next to the other\n * marker open and close whatever else surrounds it, as\n * micromark-core-commonmark did before 2.0.4. It is read from the parse of\n * `*_c_*a`, whose last `*` then closes emphasis.\n */\nlet markersLoosen: boolean | undefined;\nfunction markersLoosenRuns(): boolean {\n markersLoosen ??= parse(\"*_c_*a\", \"commonmark\").tree.children.some(\n (block) => block.type === \"paragraph\" && block.children[0]?.type === \"emphasis\",\n );\n return markersLoosen;\n}\n/**\n * The delimiter runs at `positions`, sorted, with the characters that `at`\n * gives. Whether a run can open or close follows micromark, which also lets a\n * run next to a `~` in GFM do both, and in some versions one next to another\n * `*` or `_`; with `commonmark`, it follows CommonMark, where those characters\n * are punctuation. Container markers such as `>` count as punctuation here,\n * while micromark sees the line ending before them; the caller compares the\n * result with the parse.\n */\nfunction delimiterRuns(\n positions: number[],\n at: (index: number) => string | undefined,\n gfm: boolean,\n commonmark = false,\n): DelimiterRun[] {\n const runs: DelimiterRun[] = [];\n for (const position of positions) {\n const last = runs.at(-1);\n if (last && last.end === position && at(position) === last.marker) last.end++;\n else\n runs.push({\n marker: at(position)!,\n start: position,\n end: position + 1,\n open: false,\n close: false,\n });\n }\n const loosen = !commonmark && markersLoosenRuns();\n const attention = (character: string | undefined) =>\n (!commonmark && gfm && character === \"~\") ||\n (loosen && (character === \"*\" || character === \"_\"));\n for (const run of runs) {\n const previous = at(run.start - 1);\n const next = at(run.end);\n const before = characterGroup(previous);\n const after = characterGroup(next);\n const open = after === 0 || (after === 2 && before !== 0) || attention(next);\n const close = before === 0 || (before === 2 && after !== 0) || attention(previous);\n run.open = run.marker === \"*\" ? open : open && (before !== 0 || !close);\n run.close = run.marker === \"*\" ? close : close && (after !== 0 || !open);\n }\n return runs;\n}\n/**\n * The emphasis and strong emphasis that micromark makes of `runs`, as\n * `start:end:size` strings: each closing run, in order, pairs with the nearest\n * opening run of its marker before it, except where the rule of three forbids\n * it, and the runs between them become text. micromark applies the rule to the\n * parts of two runs that are left; with `whole`, it counts the whole runs, as\n * CommonMark, GitHub, and the reference parsers do (issue #323).\n */\nfunction pairings(runs: DelimiterRun[], whole = false): string[] {\n const left = runs.map((run) => ({ ...run, size: run.end - run.start }));\n const pairs: string[] = [];\n for (let index = 0; index < left.length; index++) {\n const closer = left[index]!;\n while (closer.close && closer.end > closer.start) {\n const closeSize = whole ? closer.size : closer.end - closer.start;\n let found = index - 1;\n for (; found >= 0; found--) {\n const opener = left[found]!;\n if (!opener.open || opener.end === opener.start || opener.marker !== closer.marker)\n continue;\n const openSize = whole ? opener.size : opener.end - opener.start;\n if ((opener.close || closer.open) && closeSize % 3 && !((openSize + closeSize) % 3))\n continue;\n break;\n }\n if (found < 0) break;\n const opener = left[found]!;\n const use = opener.end - opener.start > 1 && closer.end - closer.start > 1 ? 2 : 1;\n opener.end -= use;\n closer.start += use;\n pairs.push(`${opener.end}:${closer.start}:${use}`);\n for (let between = found + 1; between < index; between++)\n left[between]!.end = left[between]!.start;\n }\n }\n return pairs.sort();\n}\n/**\n * The `*` and `_` characters that micromark reads as delimiters in the text of\n * `scope`, a block or a link whose text it pairs delimiters in on its own: the\n * markers of emphasis, and unescaped characters left as text. Also the\n * emphasis there, as `start:end:size` strings, and whether changing markers\n * could change how they pair: when a character left as text could open or\n * close emphasis, as in `*a _b* c_`, or when one run holds the markers of two\n * emphases, or a marker and text, as in `***a***` or `*****a***`.\n */\nfunction scopeDelimiters(\n source: string,\n scope: Nodes,\n): { positions: number[]; emphasis: string[]; suspicious: boolean } {\n const positions: number[] = [];\n const markers = new Set<string>();\n const emphasis: string[] = [];\n const literal = new Set<number>();\n const visit = (node: Nodes) => {\n if (node !== scope && (node.type === \"link\" || node.type === \"linkReference\")) return;\n if (node.type === \"emphasis\" || node.type === \"strong\") {\n const [a, b] = range(node);\n const size = node.type === \"strong\" ? 2 : 1;\n emphasis.push(`${a}:${b}:${size}`);\n markers.add(`${a}:${a + size}`).add(`${b - size}:${b}`);\n for (let i = 0; i < size; i++) positions.push(a + i, b - size + i);\n } else if (node.type === \"text\") {\n const [a, b] = range(node);\n for (let i = a; i < b; i++)\n if ((source[i] === \"*\" || source[i] === \"_\") && !escaped(source, i)) {\n positions.push(i);\n literal.add(i);\n }\n }\n if (\"children\" in node) for (const child of node.children) visit(child);\n };\n visit(scope);\n positions.sort((a, b) => a - b);\n const suspicious = delimiterRuns(positions, (index) => source[index], true).some((run) => {\n if (markers.has(`${run.start}:${run.end}`)) return false;\n for (let index = run.start; index < run.end; index++)\n if (literal.has(index)) return run.open || run.close;\n return true;\n });\n return { positions, emphasis: emphasis.sort(), suspicious };\n}\n/** A link label as CommonMark compares labels: whitespace collapsed and case folded. */\nconst normalizedLabel = (label: string) =>\n label\n .replace(/[\\t\\n\\r ]+/g, \" \")\n .trim()\n .toLowerCase()\n .toUpperCase();\n/** The labels of the document's definitions and footnotes that hold `*` or `_`, normalized. */\nfunction markerLabels(tree: Root): string[] {\n const labels: string[] = [];\n walk(tree, (node) => {\n if (\n (node.type === \"definition\" || node.type === \"footnoteDefinition\") &&\n node.label &&\n /[*_]/.test(node.label)\n )\n labels.push(normalizedLabel(node.label));\n });\n return labels;\n}\n/**\n * The first lines of the document's Obsidian callouts and GitHub, Forgejo, or\n * Gitea alerts, from the marker on, which hold an Obsidian callout's title and\n * an alert's marker on its own.\n */\nfunction calloutTitles(document: Document): Range[] {\n const titles: Range[] = [];\n if (document.dialect !== \"commonmark\")\n walk(document.tree, \"blockquote\", (quote) => {\n const first = quote.children[0];\n if (first?.type !== \"paragraph\") return;\n const [start] = range(first);\n const end = lineBounds(document.source, start, start)[1];\n if (startsWithMarker(document.source.slice(start, end), first)) titles.push([start, end]);\n });\n return titles;\n}\n/**\n * Visit the nodes of `type` with their scope: the innermost link, whose text\n * micromark pairs delimiters in on its own, or else the block that holds them.\n */\nfunction eachInline<T extends \"emphasis\" | \"strong\">(\n tree: Root,\n type: T,\n visitor: (node: Extract<Nodes, { type: T }>, scope: Nodes) => void,\n): void {\n const step = (node: Nodes, scope: Nodes) => {\n if (inlineBlocks.has(node.type) || node.type === \"link\" || node.type === \"linkReference\")\n scope = node;\n if (node.type === type) visitor(node as Extract<Nodes, { type: T }>, scope);\n if (\"children\" in node) for (const child of node.children) step(child, scope);\n };\n step(tree, tree);\n}\n/**\n * Whether the text in `node`, outside code and other literal nodes, holds an\n * unescaped run of tildes that could mark strikethrough in `dialect`, one or\n * two tildes or in Obsidian two, while `scope`, where such runs pair, holds\n * another.\n */\nfunction holdsStrikethroughRun(\n node: Nodes,\n scope: Nodes,\n source: string,\n dialect: Dialect,\n): boolean {\n const pattern = dialect === \"obsidian\" ? \"(?<![\\\\\\\\~])~~(?!~)\" : \"(?<![\\\\\\\\~])~{1,2}(?!~)\";\n const runs = located(scope) ? source.slice(...range(scope)).match(new RegExp(pattern, \"g\")) : [];\n if (located(scope) && (runs?.length ?? 0) < 2) return false;\n const run = new RegExp(pattern);\n let found = false;\n walk(node, \"text\", (text) => {\n if (!found && located(text) && run.test(source.slice(...range(text)))) found = true;\n });\n return found;\n}\nfunction markerRule(type: \"emphasis\" | \"strong\", fallback: string): Rule {\n return {\n description: `Choose ${type} delimiters without reprinting their contents.`,\n kind: \"style\",\n phase: \"inline\",\n schema: optionsSchema({ marker: { enum: [\"*\", \"_\"] } }),\n check({ document, options }) {\n const findings: Finding[] = [];\n const { source } = document;\n const gfm = document.dialect !== \"commonmark\";\n const size = type === \"strong\" ? 2 : 1;\n const marker = String(options.marker ?? fallback).repeat(size);\n const labels = markerLabels(document.tree);\n const titles = calloutTitles(document);\n /** The ranges of the emphasis to change, by the scope that holds them. */\n const candidates = new Map<Nodes, Range[]>();\n eachInline(document.tree, type, (node, scope) => {\n const [start, end] = range(node);\n const original = source.slice(start, end);\n if (original.startsWith(marker)) return;\n // Underscores cannot delimit intraword emphasis. Preserve these valid forms.\n if (\n marker.startsWith(\"_\") &&\n (/\\p{L}|\\p{N}/u.test(document.source[start - 1] ?? \"\") ||\n /\\p{L}|\\p{N}/u.test(document.source[end] ?? \"\"))\n )\n return;\n // A new marker touching the same character, outside or inside the\n // node, would merge into one delimiter run and change the parse.\n const neighbours = [start - 1, end, start + size, end - size - 1].map(\n (index) => document.source[index],\n );\n if (neighbours.includes(marker[0]!)) return;\n if (goldmarkForges[document.dialect] && inForgeMath(document, start, end)) return;\n // Forgejo, and Gitea before 1.26, build a heading's anchor from its last\n // line as written, keeping `_` and dropping `*`, and both read a trailing\n // `{...}` block as attributes before they parse emphasis.\n if (changesForgeHeading(document, start, end)) return;\n if (\n document.dialect === \"gitea\" &&\n (giteaPyLine(document, start, end) ||\n document.source.startsWith(\".py\", end) ||\n document.source.startsWith(\".py\", start + size))\n )\n return;\n // GitHub, Forgejo, and Gitea end dollar math only at dollars that no\n // `_` follows, so a marker after a `$` can decide where math ends.\n if (\n gfm &&\n document.dialect !== \"obsidian\" &&\n (source[start - 1] === \"$\" || source[end - size - 1] === \"$\")\n )\n return;\n // Emphasis that begins on the line of a callout's or alert's marker\n // and ends below it is text on that line, whose markers would change.\n if (\n titles.length &&\n /[\\r\\n]/.test(original) &&\n titles.some(([a, b]) => start >= a && start < b && end > b)\n )\n return;\n // The text of a collapsed or shortcut reference, such as `[*Title*][]`\n // or `[*Title*]`, is also its label, which would no longer match the\n // definition's.\n if (scope.type === \"linkReference\" && scope.referenceType !== \"full\") return;\n // Text in brackets that would match a definition with the new markers\n // would become a reference.\n if (labels.length) {\n const rewritten = normalizedLabel(marker + original.slice(size, -size) + marker);\n if (labels.some((label) => label.includes(rewritten))) return;\n }\n // micromark lets a run next to a `~` open and close, so a new marker\n // that a `~` separates from another `*` or `_` like it could pair with it.\n const reaches = (index: number, step: number) => {\n while (source[index] === \"~\") index += step;\n return source[index] === marker[0];\n };\n if (\n gfm &&\n (reaches(start - 1, -1) ||\n reaches(end, 1) ||\n reaches(start + size, 1) ||\n reaches(end - size - 1, -1))\n )\n return;\n // micromark pairs emphasis and strikethrough in separate passes, in the\n // order that their first delimiters appear in the paragraph, while\n // GitHub pairs whichever closes first. So emphasis whose text holds a\n // run of tildes that could mark strikethrough may be strikethrough and\n // text there, and its markers what GitHub shows (issue #320).\n if (gfm && holdsStrikethroughRun(node, scope, source, document.dialect)) return;\n // GitHub reads a `_` that a run of tildes separates from a letter or\n // digit as inside a word, where it neither opens nor closes, while the\n // parser reads emphasis there (issue #322).\n const tildesToWord = (index: number, step: number) => {\n if (source[index] !== \"~\") return false;\n while (source[index] === \"~\") index += step;\n return /[\\p{L}\\p{N}]/u.test(source[index] ?? \"\");\n };\n if (\n gfm &&\n (marker[0] === \"_\" || original[0] === \"_\") &&\n (tildesToWord(start - 1, -1) || tildesToWord(end, 1))\n )\n return;\n const list = candidates.get(scope) ?? [];\n list.push([start, end]);\n candidates.set(scope, list);\n });\n /** The positions of the markers of the emphasis in `ranges`. */\n const markers = (ranges: Range[]) => {\n const set = new Set<number>();\n for (const [start, end] of ranges)\n for (let i = 0; i < size; i++) set.add(start + i).add(end - size + i);\n return set;\n };\n for (const [scope, list] of candidates) {\n let accepted = list;\n // The parser's pairing of delimiter runs is modelled, and the markers\n // change where the model, which has to reproduce the parse, pairs the\n // same runs with the new markers: all of them, or else those that can\n // be added one at a time. Where the model cannot be used, markers\n // change only when no run could pair differently, which it could when\n // a `*` or `_` in the same text did not pair, or when two emphases\n // share a run of markers, as in `***a***` or `*a****c***`.\n const { positions, emphasis, suspicious } = scopeDelimiters(source, scope);\n const expected = emphasis.join(\" \");\n // micromark's pairing, or with `commonmark` CommonMark's.\n const pairing = (changed: Set<number>, commonmark = false) =>\n pairings(\n delimiterRuns(\n positions,\n (at) => (changed.has(at) ? marker[0] : source[at]),\n gfm,\n commonmark,\n ),\n commonmark,\n ).join(\" \");\n // Both micromark's pairing and CommonMark's, which renderers follow,\n // have to stay the same with the new markers.\n const kept = (changed: Set<number>) =>\n pairing(changed) === expected && pairing(changed, true) === expected;\n // micromark pairs `~` in a pass of its own, which can come first, and\n // lets a run next to a `~` pair with one of the new marker, as in `_f~*a*e_`.\n const tilde = gfm && source.slice(...range(scope)).includes(\"~\");\n const modelled = !tilde && positions.length <= 500 && pairing(new Set()) === expected;\n if (!modelled)\n accepted =\n suspicious || (tilde && positions.some((at) => source[at] === marker[0])) ? [] : list;\n // Where CommonMark pairs the text as written differently, the parser\n // misread it, and renderers show other emphasis (issue #323).\n else if (pairing(new Set(), true) !== expected) accepted = [];\n else if (!kept(markers(list))) {\n accepted = [];\n let changed = new Set<number>();\n for (const item of list) {\n const trial = new Set([...changed, ...markers([item])]);\n if (!kept(trial)) continue;\n changed = trial;\n accepted.push(item);\n }\n }\n for (const [start, end] of accepted)\n for (const [a, b] of [\n [start, start + size],\n [end - size, end],\n ] as const) {\n findings.push({\n start: a,\n end: b,\n message: `Use ${JSON.stringify(marker)} for ${type}.`,\n edit: { start: a, end: b, text: marker },\n });\n }\n }\n return findings.sort((a, b) => a.start - b.start);\n },\n };\n}\n\n/**\n * Where dollar math could begin or end at the edge of a line although it does\n * not at a space: `start` when a dollar at the start of a line can end math\n * that a dollar before it began, and `end` for the words whose last dollar can\n * begin math at the end of a line, which a dollar after it could end.\n */\ninterface DollarEdges {\n start: boolean;\n end?: (atom: string) => boolean;\n}\n/**\n * Join words into the atoms that reflow puts on lines. Whitespace-only words\n * separate atoms; whitespace inside a word, such as in a code span, does not.\n */\nfunction wrappingAtoms(words: string[], openers: RegExp[], dollars?: DollarEdges): string[] {\n const separated: string[] = [];\n let current = \"\";\n for (const word of words) {\n if (/^[ \\t]+$/.test(word)) {\n if (current) separated.push(current);\n current = \"\";\n } else current += word;\n }\n if (current) separated.push(current);\n // Keep atoms that would open a block or underline a Setext heading at the\n // start of a line attached to the preceding atom, and so a dollar that\n // could end math there.\n const joined: string[] = [];\n let dollarBefore = false;\n for (const atom of separated) {\n if (\n joined.length &&\n (openers.some((opener) => opener.test(atom)) ||\n (dollars?.start && dollarBefore && atom.startsWith(\"$\")))\n )\n joined[joined.length - 1] += ` ${atom}`;\n else joined.push(atom);\n if (atom.includes(\"$\")) dollarBefore = true;\n }\n // An atom ending in an unescaped backslash would become a hard break at the\n // end of a line; keep it attached to the following atom, and so one ending\n // in a dollar that could begin math there.\n let lastDollar = -1;\n joined.forEach((atom, index) => {\n if (atom.includes(\"$\")) lastDollar = index;\n });\n const atoms: string[] = [];\n for (let i = 0; i < joined.length; i++) {\n let atom = joined[i]!;\n while (\n i < joined.length - 1 &&\n (/(?:^|[^\\\\])(?:\\\\\\\\)*\\\\$/.test(atom) || (i < lastDollar && dollars?.end?.(atom)))\n )\n atom += ` ${joined[++i]}`;\n atoms.push(atom);\n }\n return atoms;\n}\n/**\n * Words that open a block or underline a heading at the start of a line, the\n * way CommonMark does with them: as a whole word only. These are list markers,\n * ATX heading markers, and runs of the character of a thematic break or a\n * Setext underline, which a line of such words alone forms. A word that only\n * starts with those characters, such as `--config`, `*delta*`, `#tag`, or\n * `-5`, opens nothing.\n */\nconst wordOpener = /^(?:[-+*]|\\d{1,9}[.)]|#{1,6}|\\*+|-+|_+|=+)$/;\n/**\n * The words of a GFM table's delimiter row, which a line of them alone forms\n * below a line that then becomes the table's header row.\n */\nconst delimiterRowWord = /^[|:-]*[|-][|:-]*$/;\n/**\n * Word starts that open a block whatever follows them on the line: block\n * quotes, fences, math, Obsidian comments, HTML blocks, and footnote\n * definitions.\n */\nconst prefixOpener = /^(?:>|~{3,}|`{3,}|\\$\\$|%%|<[!?/A-Za-z]|\\[\\^[^\\]]+\\]:)/;\n/** A word that ends in an unescaped dollar, which can begin dollar math at the end of a line. */\nconst dollarEnd = /(?:^|[^\\\\])(?:\\\\\\\\)*\\$$/;\n/**\n * A paragraph's first word that would open a thematic break or TOML front\n * matter alone on the first line. The paragraph's first line holds more than\n * this word, so it opened neither there.\n */\nconst firstWordAlone = /^(?:(?:\\*[ \\t]*){3,}|(?:-[ \\t]*){3,}|(?:_[ \\t]*){3,}|\\+\\+\\+)$/;\n/**\n * The start of a fence or of display math, which the first line of a\n * paragraph can start with when what follows on the line, such as a backtick\n * after a backtick fence, keeps it from opening one.\n */\nconst fenceStart = /^(?:`{3,}|~{3,}|\\$\\$)/;\n/** A link reference definition's label and colon, which a paragraph can start with. */\nconst definitionStart = /^\\[(?:[^[\\]\\\\]|\\\\[^])+\\]:/;\n/** A GFM table's delimiter row, such as `| --- | :-: |`, after any container markers. */\nconst delimiterRow = /^[ \\t>]*\\|?[ \\t]*:?-+:?[ \\t]*(?:\\|[ \\t]*:?-+:?[ \\t]*)*\\|?[ \\t]*$/;\n/**\n * Whether text that the parser read as a paragraph or a heading's text has a\n * table delimiter row as its second line. GitHub reads a table there, and so\n * does the parser, except directly below a table that ends in a list item or\n * block quote, where it reads the lines as text (issue #283). Joining the lines\n * or adding a blank line above them would change what GitHub or the parser\n * reads.\n */\nfunction misreadTable(text: string): boolean {\n const second = text.split(lineBreak, 2)[1];\n return second !== undefined && second.includes(\"|\") && delimiterRow.test(second);\n}\n// Forgejo and Gitea additionally open display math with `\\[` and definition\n// descriptions with `:` followed by at least one space or tab, so only a bare\n// `:` atom could open one at the start of a reflowed line.\nconst forgeLineOpener = /^(?::$|\\\\\\[)/;\n/**\n * Site-generator syntax at the start of a line: a container such as\n * Docusaurus's `:::note`, or a template tag such as Liquid's `{% tab %}` or\n * `{{ title }}`. Site generators read it by line, and no dialect gives it\n * meaning, so a paragraph with a line that starts with it keeps its lines, and\n * a word that starts with it stays on the line before it (issue #296).\n */\nconst siteSyntax = /^(?::::|\\{%|\\{\\{)/;\n/**\n * The template tags in `text`, which starts at offset `base`, that each lie on\n * one line, such as Liquid's `{% data x %}` or `{{ page.title }}`: wrapping\n * keeps them whole.\n */\nfunction templateTags(text: string, base: number): Range[] {\n const ranges: Range[] = [];\n if (!text.includes(\"{%\") && !text.includes(\"{{\")) return ranges;\n let at = base;\n for (const line of text.split(/(?<=\\n|\\r(?!\\n))/)) {\n for (const [open, close] of [\n [\"{%\", \"%}\"],\n [\"{{\", \"}}\"],\n ] as const)\n for (let from = 0; ;) {\n const opener = line.indexOf(open, from);\n const closer = opener < 0 ? -1 : line.indexOf(close, opener + open.length);\n if (closer < 0) break;\n ranges.push([at + opener, at + closer + close.length]);\n from = closer + close.length;\n }\n at += line.length;\n }\n return ranges;\n}\n/** Whether a line of a paragraph, after its container markers, starts with `siteSyntax`. */\nfunction startsSiteSyntax(text: string): boolean {\n return text\n .split(lineBreak)\n .some((line, index) => siteSyntax.test(index ? line.replace(/^[ \\t>]+/, \"\") : line));\n}\n/**\n * A list, heading, or block quote marker as the whole first word of a\n * paragraph, with more words after it. Directly below text, the parser reads\n * a marker that would open an empty list item there, such as the second `-` of\n * `- -`, as text, and the paragraph can continue on the next line. Joining the\n * next word to the marker would open the block. On Forgejo and Gitea, a bare\n * `:` joined to the next word would turn a paragraph above it into the term of\n * a definition list.\n */\nconst leadingMarker = /^(?:[-+*]|\\d{1,9}[.)]|#{1,6}|>)[ \\t\\r\\n]/;\n\ntype Range = [number, number];\n/**\n * The positions of a paragraph's source where whitespace is not a wrapping\n * opportunity: those strictly inside a protected source range.\n */\nclass Protection {\n private readonly mask: Uint8Array;\n constructor(\n private readonly start: number,\n end: number,\n ) {\n this.mask = new Uint8Array(Math.max(0, end - start));\n }\n add(from: number, to: number) {\n this.mask.fill(1, Math.max(0, from + 1 - this.start), Math.max(0, to - this.start));\n }\n has(at: number): boolean {\n return this.mask[at - this.start] === 1;\n }\n /** Split text that starts at offset `base` at whitespace outside protected ranges. */\n split(text: string, base: number): string[] {\n const words: string[] = [];\n let cursor = 0;\n for (const match of text.matchAll(/[ \\t]+/g)) {\n if (this.has(base + match.index)) continue;\n if (match.index > cursor) words.push(text.slice(cursor, match.index));\n words.push(match[0]);\n cursor = match.index + match[0].length;\n }\n if (cursor < text.length) words.push(text.slice(cursor));\n return words;\n }\n}\n/**\n * What reflow does with a line ending inside an inline node that it keeps\n * whole: in a code span it becomes the space that it renders as, and so it\n * does in an image description; elsewhere it keeps the paragraph as written,\n * for the reason given. In the text of a link kept whole, it does what the\n * atom `within` it there does, and otherwise what it does in a description.\n */\ntype Joining = \"code\" | \"description\" | { reason: string } | { within: InlineAtom[] };\ninterface InlineAtom {\n from: number;\n to: number;\n joining: Joining;\n}\n/**\n * Inline containers whose text reflow wraps like the paragraph's own: a line\n * ending in them renders as a space, like one between words. Their delimiters,\n * and a link's destination, title, or reference label, stay attached to the\n * neighboring words.\n */\nconst wrappable = new Set<string>([\"emphasis\", \"strong\", \"delete\", \"link\", \"linkReference\"]);\nconst lineBreakIn: Record<string, string> = {\n html: \"inline HTML\",\n inlineMath: \"math\",\n obsidianComment: \"an Obsidian comment\",\n};\nfunction located(node: Nodes): boolean {\n return node.position?.start.offset !== undefined && node.position.end.offset !== undefined;\n}\nfunction holds(node: Nodes, type: string): boolean {\n let found = false;\n walk(node, (child) => {\n if (child.type === type) found = true;\n });\n return found;\n}\n/**\n * The inline nodes of a paragraph, from `start` on, that reflow keeps whole,\n * sorted by position, and the hard line breaks anywhere in it. A container\n * that holds inline HTML is kept whole too, because HTML can make the\n * whitespace inside it significant. With `wholeLinks`, the text of a link is\n * kept whole as an image's description is: Obsidian's Live Preview shows a\n * link whose text spans lines as Markdown source (issue #306).\n */\nfunction inlineAtoms(\n paragraph: Paragraph,\n start: number,\n wholeLinks: boolean,\n): { atoms: InlineAtom[]; breaks: Range[]; unlocated: boolean } {\n const atoms: InlineAtom[] = [];\n const breaks: Range[] = [];\n let unlocated = false;\n const destination = { reason: \"line break in a link destination or title\" };\n const visit = (parent: Parents) => {\n for (const child of parent.children) {\n if (child.type === \"text\") continue;\n if (!located(child)) {\n unlocated = true;\n continue;\n }\n const [a, b] = range(child);\n if (b <= start) continue;\n if (child.type === \"break\") breaks.push([a, b]);\n else if (\n wholeLinks &&\n (child.type === \"link\" || child.type === \"linkReference\") &&\n child.children.length &&\n labelEnd(child) &&\n !holds(child, \"html\")\n ) {\n // The code spans, images, and other atoms in the text keep their own\n // joining; between them, a line ending joins with the space that it\n // renders as, as in an image's description.\n const close = labelEnd(child)!;\n const inner = atoms.length;\n visit(child);\n const within = atoms.splice(inner).sort((x, y) => x.from - y.from);\n atoms.push({ from: a, to: close, joining: { within } });\n atoms.push({ from: close, to: b, joining: destination });\n } else if (\n wrappable.has(child.type) &&\n \"children\" in child &&\n child.children.length &&\n !holds(child, \"html\")\n ) {\n if (child.type === \"link\" || child.type === \"linkReference\") {\n const close = labelEnd(child) ?? range(child.children.at(-1)!)[1];\n atoms.push({ from: close, to: b, joining: destination });\n }\n visit(child);\n } else if (child.type === \"inlineCode\") atoms.push({ from: a, to: b, joining: \"code\" });\n else if ((child.type === \"image\" || child.type === \"imageReference\") && labelEnd(child)) {\n const close = labelEnd(child)!;\n atoms.push({ from: a, to: close, joining: \"description\" });\n atoms.push({ from: close, to: b, joining: destination });\n } else {\n const name = lineBreakIn[child.type] ?? (holds(child, \"html\") ? \"inline HTML\" : undefined);\n const reason = `line break in ${name ?? \"inline syntax\"}`;\n atoms.push({ from: a, to: b, joining: { reason } });\n }\n }\n };\n visit(paragraph);\n atoms.sort((x, y) => x.from - y.from);\n return { atoms, breaks, unlocated };\n}\n/** The atom whose source holds `at`, among atoms sorted by position. */\nfunction atomAt(atoms: InlineAtom[], at: number): InlineAtom | undefined {\n let low = 0;\n let high = atoms.length - 1;\n while (low <= high) {\n const middle = (low + high) >> 1;\n const atom = atoms[middle]!;\n if (at <= atom.from) high = middle - 1;\n else if (at >= atom.to) low = middle + 1;\n else return atom;\n }\n return undefined;\n}\n/**\n * The width of a line or line prefix, with a tab advancing to the next\n * multiple of four columns, the tab stop that CommonMark uses for indentation.\n */\nfunction lineWidth(text: string, measure: (text: string) => number): number {\n if (!text.includes(\"\\t\")) return measure(text);\n let width = 0;\n for (const part of text.split(/(\\t)/)) width += part === \"\\t\" ? 4 - (width % 4) : measure(part);\n return width;\n}\n/** Whether text parses as a single paragraph. */\nfunction oneParagraph(text: string, dialect: Dialect): boolean {\n const { children } = parse(text, dialect).tree;\n return children.length === 1 && children[0]!.type === \"paragraph\";\n}\n/**\n * Syntax that Forgejo and Gitea render but GFM parses as prose. A line starting\n * with `:` and a space turns the preceding lines into a definition list and `\\[`\n * opens display math, so such paragraphs keep their lines. `\\(...\\)` math and\n * `[[...]]` shortlinks are recognized within one physical line: a pair on one\n * line becomes an unbreakable atom, and a pair split across lines, which reflow\n * could join, protects the whole paragraph. Gitea parses the backslash math\n * delimiters only where an administrator enables them, which a document does\n * not reveal, so they are protected there too.\n */\nfunction forgeProtections(\n source: string,\n start: number,\n end: number,\n forge: string,\n): { ranges: Range[]; reason?: string } {\n const ranges: Range[] = [];\n for (const line of source.slice(start, end).split(lineBreak)) {\n const content = line.replace(/^[ \\t>]+/, \"\");\n if (/^:[ \\t]/.test(content)) return { ranges, reason: `${forge} definition list` };\n if (content.startsWith(\"\\\\[\")) return { ranges, reason: `${forge} display math` };\n }\n for (const [open, close] of [\n [\"\\\\(\", \"\\\\)\"],\n [\"[[\", \"]]\"],\n ] as const) {\n let from = start;\n for (;;) {\n const opener = source.indexOf(open, from);\n if (opener < 0 || opener >= end) break;\n const closer = source.indexOf(close, opener + open.length);\n if (closer < 0 || closer >= end) break;\n if (lineBreak.test(source.slice(opener, closer)))\n return { ranges, reason: `${forge} ${open}...${close} syntax spanning lines` };\n ranges.push([opener, closer + close.length]);\n from = closer + close.length;\n }\n }\n return { ranges };\n}\n/**\n * Whether reflow could change Gitea emphasis under its `_.py` exception: the\n * paragraph contains `_.py` and an underscore that Gitea's parser could treat\n * as a delimiter. Underscores inside code spans are safe only without `$` or\n * `\\(` math, which can consume a backtick that GFM reads as opening a code span.\n */\nfunction giteaPyParagraph(source: string, node: Paragraph, start: number, end: number): boolean {\n const text = source.slice(start, end);\n if (!text.includes(\"_.py\")) return false;\n if (/\\$|\\\\\\(/.test(text)) return true;\n const code: Range[] = [];\n walk(node, \"inlineCode\", (child) => {\n code.push(range(child));\n });\n for (let at = text.indexOf(\"_\"); at >= 0; at = text.indexOf(\"_\", at + 1)) {\n if (!code.some(([a, b]) => start + at >= a && start + at < b)) return true;\n }\n return false;\n}\n/** Inline nodes whose source joined lines cannot change. */\nconst obsidianOpaque = new Set([\"inlineCode\", \"inlineMath\", \"wikiLink\", \"obsidianHighlight\"]);\n/**\n * Whether joining an Obsidian paragraph's lines could create a highlight or a\n * wikilink. The parser reads neither across a line break, so `==` and `[[` or\n * `]]` that it left as text, outside code, math, and the highlights and links\n * that it did read, could pair up once two lines become one.\n */\nfunction obsidianMarkers(source: string, node: Paragraph, start: number, end: number): boolean {\n if (!/==|\\[\\[|\\]\\]/.test(source.slice(start, end))) return false;\n const opaque: Range[] = [];\n walk(node, (child) => {\n if (obsidianOpaque.has(child.type)) opaque.push(range(child));\n });\n let text = \"\";\n let cursor = start;\n for (const [a, b] of opaque.sort((x, y) => x[0] - y[0])) {\n if (b <= cursor) continue;\n // A space keeps the text on both sides from forming a marker.\n text += source.slice(cursor, Math.max(cursor, a)) + \" \";\n cursor = Math.min(Math.max(cursor, b), end);\n }\n text += source.slice(cursor, end);\n return /==|\\[\\[|\\]\\]/.test(text);\n}\n/** A line's container prefix, with list item markers and checkboxes made blank. */\nfunction continuationOf(prefix: string): string {\n return prefix.replace(/(?:[-+*]|\\d+[.)]|\\[[xX ]\\])(?=\\s)/g, (value) => \" \".repeat(value.length));\n}\n\nconst wrap: Rule = {\n description: \"Reflow paragraphs using configurable width and protected inline atoms.\",\n kind: \"style\",\n phase: \"block\",\n schema: optionsSchema({\n width: { type: \"integer\", minimum: 20, maximum: 500 },\n measure: { enum: [\"columns\", \"codepoints\"] },\n reportUnreflowed: { type: \"boolean\" },\n reportUnbreakable: { type: \"boolean\" },\n }),\n check({ document, options, workspace }) {\n if (document.dialect === \"obsidian\" && workspace?.strictLineBreaks !== true) return [];\n const findings: Finding[] = [];\n const width = Number(options.width ?? 80);\n const measure =\n options.measure === \"codepoints\" ? (text: string) => [...text].length : stringWidth;\n const unit = options.measure === \"codepoints\" ? \"code points\" : \"columns\";\n // Detect the line ending once; scanning the whole source per paragraph is quadratic.\n const newline = lineEnding(document.source);\n walk(document.tree, \"paragraph\", (node, index, parent) => {\n const [paragraphStart, end] = range(node);\n let start = paragraphStart;\n let children = node.children;\n // A task item's paragraph range can begin at the checkbox, and its first\n // text node can begin with the separator. Wrap only the content after them.\n if (children[0]) {\n start = Math.max(start, range(children[0])[0]);\n while (start < end && /[ \\t]/.test(document.source[start]!)) start++;\n }\n let original = document.source.slice(start, end);\n const forge = goldmarkForges[document.dialect];\n // An Obsidian callout or a GitHub, Forgejo, or Gitea alert keeps the line\n // with its marker, and its title in Obsidian, as written. On Forgejo and\n // Gitea, a marker written as `\\[!NOTE]` starts like display math, and\n // its paragraph stays as written.\n let calloutHeader =\n document.dialect !== \"commonmark\" &&\n parent?.type === \"blockquote\" &&\n index === 0 &&\n startsWithMarker(original, node) &&\n !(forge && original.startsWith(\"\\\\[\"));\n /** Whether the lines to wrap are the body below that line, in the same paragraph. */\n let belowHeader = false;\n let lineStart = start;\n while (lineStart > 0 && !/[\\r\\n]/.test(document.source[lineStart - 1]!)) lineStart--;\n let prefix = document.source.slice(lineStart, start);\n const continuation = continuationOf(prefix);\n // Directly below a link reference definition, a paragraph can start with\n // a lazy continuation line, which lacks some of the container markers of\n // the lines around it. The later lines' prefixes cannot be told from it.\n const above = index ? parent?.children[index - 1] : undefined;\n let lazyStart = false;\n if (\n above?.type === \"definition\" &&\n above.position!.end.line === node.position!.start.line - 1\n ) {\n const [definitionStart] = range(above);\n const definitionLine = lineBounds(document.source, definitionStart, definitionStart)[0];\n lazyStart =\n continuationOf(document.source.slice(definitionLine, definitionStart)) !== continuation;\n }\n if (calloutHeader) {\n const headerBreak = lineBreak.exec(original);\n const headerEnd = headerBreak ? start + headerBreak.index : end;\n const header = document.source.slice(start, headerEnd);\n const bodyStart = headerEnd + (headerBreak?.[0].length ?? 0) + continuation.length;\n const bodyLines = headerBreak\n ? original.slice(headerBreak.index + headerBreak[0].length).split(lineBreak)\n : [];\n const supported =\n bodyLines.every((line) => line.startsWith(continuation)) &&\n !children.some((child) => {\n const [a, b] = range(child);\n return child.type !== \"text\" && a < bodyStart && b > bodyStart;\n });\n // Keep unusual continuations and inline syntax spanning the boundary untouched.\n if (supported) {\n if (options.reportUnbreakable === true && lineWidth(prefix + header, measure) > width)\n findings.push({\n start,\n end: start + header.length,\n message: `Paragraph exceeds ${width} ${unit} because of an unbreakable atom.`,\n });\n if (!headerBreak) return;\n start = bodyStart;\n original = document.source.slice(start, end);\n children = children.filter((child) => range(child)[1] > start);\n prefix = continuation;\n calloutHeader = false;\n belowHeader = true;\n }\n }\n const openers = [wordOpener, prefixOpener, siteSyntax];\n if (document.dialect !== \"commonmark\") openers.push(delimiterRowWord);\n if (forge) openers.push(forgeLineOpener);\n const { source } = document;\n // GitHub and Obsidian end dollar math at a single dollar after a line\n // ending, but not after a space, so a word that starts with `$` stays on\n // the line of the word before it when a dollar comes before it. Obsidian\n // also begins math at a single dollar before a line ending, but not\n // before a space, so a word that ends in a dollar of its text, such as a\n // lone `$`, stays on the line of the word after it when a dollar comes\n // after it. Forgejo and Gitea have neither condition.\n const maths: string[] = [];\n if (document.dialect === \"obsidian\")\n walk(node, \"inlineMath\", (math) => {\n maths.push(source.slice(...range(math)));\n });\n const dollars: DollarEdges = {\n start: document.dialect === \"github\" || document.dialect === \"obsidian\",\n ...(document.dialect === \"obsidian\"\n ? {\n end: (atom: string) =>\n dollarEnd.test(atom) && !maths.some((math) => atom.endsWith(math)),\n }\n : {}),\n };\n const inline = inlineAtoms(node, start, document.dialect === \"obsidian\");\n const protection = new Protection(start, end);\n for (const atom of inline.atoms) protection.add(atom.from, atom.to);\n // Forgejo and Gitea protections apply before paragraphs are skipped, so\n // that diagnostics still count one-line math and shortlinks as atoms.\n const protections = forge\n ? forgeProtections(source, start, end, forge)\n : { ranges: [] as Range[] };\n for (const [from, to] of protections.ranges) protection.add(from, to);\n for (const [from, to] of templateTags(source.slice(start, end), start))\n protection.add(from, to);\n const reportUnbreakable = () =>\n findings.push({\n start,\n end,\n message: `Paragraph exceeds ${width} ${unit} because of an unbreakable atom.`,\n });\n const reportSkipped = (reason: string) => {\n if (options.reportUnreflowed !== true && options.reportUnbreakable !== true) return;\n let breakable = false;\n let unbreakable = false;\n let offset = start;\n for (const line of original.split(/(?<=\\n|\\r(?!\\n))/)) {\n const content = line.replace(/(?:\\r\\n|\\r|\\n)$/, \"\");\n const container =\n offset === start\n ? \"\"\n : continuation && content.startsWith(continuation)\n ? continuation\n : (content.match(/^[ \\t>]+/)?.[0] ?? \"\");\n const linePrefix = offset === start ? prefix : container;\n // An Obsidian title occupies one physical line, even when it contains spaces.\n if (calloutHeader && offset === start) {\n if (lineWidth(prefix + content, measure) > width) unbreakable = true;\n offset += line.length;\n continue;\n }\n // Hard-break markers do not count toward the width.\n let contentEnd = offset + content.length;\n for (const [a] of inline.breaks) if (a >= offset && a < contentEnd) contentEnd = a;\n const from = offset + container.length;\n const words = protection.split(source.slice(from, contentEnd), from);\n const atoms = wrappingAtoms(words, openers, dollars);\n const available = width - lineWidth(linePrefix, measure);\n if (measure(words.join(\"\").trimEnd()) > available) {\n if (atoms.length > 1) breakable = true;\n if (atoms.some((atom) => measure(atom) > available)) unbreakable = true;\n }\n offset += line.length;\n }\n if (options.reportUnreflowed === true && breakable)\n findings.push({\n start,\n end,\n message: `Paragraph not reflowed: ${reason} (width ${width} ${unit}).`,\n });\n if (options.reportUnbreakable === true && unbreakable) reportUnbreakable();\n };\n // Only the first paragraph of a block quote can be a callout, so a\n // paragraph elsewhere that starts with a linked image, `[![`, is wrapped.\n // Below the line of a marker, the paragraph's text no longer starts the\n // lines to wrap.\n const markerLike = /^\\[![^\\]]+\\]/;\n const startsLikeMarker =\n parent?.type === \"blockquote\" &&\n index === 0 &&\n (belowHeader ? markerLike.test(original) : startsWithMarker(original, node, markerLike));\n const reason = inline.breaks.length\n ? \"hard line break\"\n : children.some((child) => child.type === \"html\")\n ? \"inline HTML\"\n : startsLikeMarker\n ? \"callout header\"\n : blockIdentifier(document.source, node)\n ? \"block identifier\"\n : leadingMarker.test(original) || (forge && /^:(?:\\r|\\n)/.test(original))\n ? \"leading block marker\"\n : document.dialect !== \"commonmark\" && misreadTable(original)\n ? \"table delimiter row as its second line\"\n : startsSiteSyntax(original)\n ? \"site-generator syntax at the start of a line\"\n : lazyStart\n ? \"lazy first line\"\n : !/^[\\s>\\-*+\\d.[\\]xX)]*$/.test(prefix)\n ? \"unsupported container prefix\"\n : document.dialect === \"obsidian\" &&\n obsidianMarkers(source, node, start, end)\n ? \"Obsidian `==`, `[[`, or `]]` outside highlights and links\"\n : inline.unlocated\n ? \"inline syntax without a source position\"\n : undefined;\n const skipped =\n reason ??\n protections.reason ??\n (document.dialect === \"gitea\" && giteaPyParagraph(source, node, start, end)\n ? \"Gitea `_.py` emphasis exception\"\n : undefined);\n if (skipped) {\n reportSkipped(skipped);\n return;\n }\n // Collect the words line by line, without the container prefixes. A line\n // ending between words, or in the text of emphasis or a link, separates\n // words like a space. One inside an atom joins its lines with the space\n // that it renders as, or keeps the paragraph as written.\n const words: string[] = [];\n let failure: string | undefined;\n const pieces = original.split(/(\\r\\n|\\r|\\n)/);\n let at = start;\n let lineEnd = start;\n for (let i = 0; i < pieces.length && !failure; i += 2) {\n let line = pieces[i]!;\n let lineAt = at;\n at += line.length + (pieces[i + 1]?.length ?? 0);\n if (i > 0) {\n if (continuation && line.startsWith(continuation)) {\n line = line.slice(continuation.length);\n lineAt += continuation.length;\n } else if (continuation && /^[\\s>]/.test(line)) {\n failure = \"unsupported continuation\";\n break;\n }\n const last = words.at(-1);\n let joining = protection.has(lineEnd)\n ? (atomAt(inline.atoms, lineEnd)?.joining ?? { reason: \"line break in inline syntax\" })\n : undefined;\n if (joining && typeof joining === \"object\" && \"within\" in joining)\n joining = atomAt(joining.within, lineEnd)?.joining ?? \"description\";\n if (!joining) words.push(\" \");\n else if (last === undefined || /^[ \\t]+$/.test(last))\n failure = \"line break in inline syntax\";\n else if (joining === \"code\" || joining === \"description\") {\n // In an image description, two spaces or a backslash before the\n // line ending make a hard break, and other spaces collapse; in a\n // code span, the spaces before it are code. The spaces and tabs\n // after it go, as `codeSpanText` reads the span, also the\n // indentation below a task item's checkbox, which the parser\n // keeps. A lazy line, which keeps them, is not supported above.\n if (joining === \"description\" && /(?: {2}|\\\\)$/.test(last)) failure = \"hard line break\";\n const trimmed = line.replace(/^[ \\t]+/, \"\");\n lineAt += line.length - trimmed.length;\n line = trimmed;\n words[words.length - 1] = `${joining === \"code\" ? last : last.trimEnd()} `;\n } else failure = \"reason\" in joining ? joining.reason : \"line break in inline syntax\";\n }\n words.push(...protection.split(line, lineAt));\n lineEnd = lineAt + line.length;\n }\n if (failure) {\n reportSkipped(failure);\n return;\n }\n const atoms = wrappingAtoms(words, openers, dollars);\n if (!atoms.length) return;\n // The first line keeps the words after a first word that would open a\n // block alone on the line, until the line can no longer open one, and\n // below an alert's or callout's marker line, after a run of `=` or `-`\n // that would underline that line as a heading.\n while (\n atoms.length > 1 &&\n (firstWordAlone.test(atoms[0]!) ||\n (belowHeader && /^(?:=+|-+)$/.test(atoms[0]!)) ||\n (fenceStart.test(atoms[0]!) && !oneParagraph(atoms[0]!, document.dialect)))\n )\n atoms.splice(0, 2, `${atoms[0]} ${atoms[1]}`);\n /** Fill lines greedily, with the first `first` atoms on the first line. */\n const fill = (first: number): string[] => {\n const lines: string[] = [];\n let line = atoms.slice(0, first).join(\" \");\n let linePrefix = prefix;\n for (let i = first; i < atoms.length; i++) {\n const candidate = `${line} ${atoms[i]}`;\n if (lineWidth(linePrefix + candidate, measure) > width) {\n lines.push(line);\n line = atoms[i]!;\n linePrefix = continuation;\n } else line = candidate;\n }\n if (line) lines.push(line);\n return lines;\n };\n let output = fill(1);\n // A paragraph that starts like a link reference definition becomes one\n // when a line ends after the definition's destination or title. Keep\n // words on the first line until the lines read as one paragraph again.\n if (output.length > 1 && atoms[0]!.startsWith(\"[\") && definitionStart.test(atoms.join(\" \"))) {\n let first = atoms.findIndex((atom) => atom.includes(\"]:\")) + 1;\n while (output.length > 1 && !oneParagraph(output.join(\"\\n\"), document.dialect))\n output = fill(++first);\n }\n const replacement = output.join(newline + continuation);\n if (replacement !== original)\n findings.push({\n start,\n end,\n message: `Reflow paragraph to ${width} ${unit}.`,\n edit: { start, end, text: replacement },\n });\n if (\n options.reportUnbreakable === true &&\n (prefix + replacement).split(lineBreak).some((line) => lineWidth(line, measure) > width)\n )\n reportUnbreakable();\n });\n return findings;\n },\n};\n\nconst table: Rule = {\n description: \"Align or compact GFM table cells while preserving their inline source.\",\n kind: \"style\",\n phase: \"block\",\n schema: optionsSchema({ style: { enum: [\"aligned\", \"compact\"] } }),\n check({ document, options }) {\n const findings: Finding[] = [];\n // A compact table has one space around each cell and the shortest delimiters.\n const compact = options.style === \"compact\";\n const newline = lineEnding(document.source);\n walk(document.tree, \"table\", (node) => {\n const [start, end] = range(node);\n // Nested tables retain container prefixes until a dedicated container printer handles them.\n if (node.position!.start.column !== 1) return;\n const rows = node.children.map((row) =>\n row.children.map((cell) => {\n if (!cell.children.length) return \"\";\n const first = range(cell.children[0]!)[0];\n const last = range(cell.children.at(-1)!)[1];\n return document.source.slice(first, last);\n }),\n );\n const count = node.align?.length ?? rows[0]?.length ?? 0;\n if (rows.some((row) => row.length > count)) return;\n const widths = Array.from({ length: count }, (_, i) =>\n compact ? 3 : Math.max(3, ...rows.map((row) => stringWidth(row[i] ?? \"\"))),\n );\n const pad = (cell: string, i: number) =>\n compact ? cell : cell + \" \".repeat(widths[i]! - stringWidth(cell));\n // Keep each row's own cell count: adding cells to a short row changes the parsed table.\n const rendered = rows.map((row) => `| ${row.map(pad).join(\" | \")} |`);\n rendered.splice(\n 1,\n 0,\n `| ${widths\n .map((width, i) => {\n const align = node.align?.[i];\n return (\n (align === \"left\" || align === \"center\" ? \":\" : \"-\") +\n \"-\".repeat(width - 2) +\n (align === \"right\" || align === \"center\" ? \":\" : \"-\")\n );\n })\n .join(\" | \")} |`,\n );\n const replacement = rendered.join(newline);\n if (replacement !== document.source.slice(start, end))\n findings.push({\n start,\n end,\n message: compact ? \"Write the table compactly.\" : \"Align table cells.\",\n edit: { start, end, text: replacement },\n });\n });\n return findings;\n },\n};\n\n/** A line holding nothing but block quote markers and blank space. */\nconst blankLine = /^[ \\t>]*$/;\n/**\n * A list item or quote marker followed by another list marker on its line,\n * including the ones that cannot open a list there, such as `* * *`.\n */\nconst nestedListStart = /^[ \\t]*(?:[-+*]|\\d{1,9}[.)]|>)[ \\t>]*(?:[-+*]|\\d{1,9}[.)])(?:[ \\t]|$)/;\n/** The innermost last block of a container, where its text ends. */\nfunction lastBlock(node: RootContent): RootContent {\n while (\n [\"blockquote\", \"list\", \"listItem\", \"footnoteDefinition\"].includes(node.type) &&\n \"children\" in node &&\n node.children.length\n )\n node = node.children.at(-1) as RootContent;\n return node;\n}\n/**\n * Whether two neighboring blocks have to stay as they are, although one of\n * them is a heading or a list, because a blank line between them would change\n * what they mean or what a comment or callout applies to.\n */\nfunction together(\n document: Document,\n parent: Root | Blockquote,\n index: number,\n directiveLines: Set<number>,\n): boolean {\n const before = parent.children[index - 1]!;\n const after = parent.children[index]!;\n const { source } = document;\n const [beforeStart, beforeEnd] = range(before);\n const [afterStart, afterEnd] = range(after);\n // Front matter is not part of the document's text.\n if ([\"yaml\", \"toml\"].includes(before.type)) return true;\n // An unclosed HTML comment or block at the end of a list would take in the blank line.\n if (takesLines(before)) return true;\n // Other tools, too, read a comment as applying to the line below it, and\n // `mdtools-disable-next-line` does: a blank line would take that line's place.\n if (before.type === \"html\" && /^<!--[^]*-->$/.test(before.value.trim())) return true;\n if (directiveLines.has(after.position!.start.line - 1)) return true;\n // The line that opens a callout or alert stays with the body below it.\n if (\n index === 1 &&\n parent.type === \"blockquote\" &&\n before.type === \"paragraph\" &&\n before.position!.start.line === before.position!.end.line &&\n startsWithMarker(source.slice(beforeStart, beforeEnd), before)\n )\n return true;\n // Obsidian may attach a block identifier on its own line to the block above.\n const alone = document.dialect === \"obsidian\" ? blockIdentifier(source, after) : undefined;\n if (alone && source.slice(afterStart, afterEnd).trimEnd() === `^${alone.id}`) return true;\n // Directly below a table that ends inside a list or block quote, the parser\n // reads the next table as a paragraph, or as the text of a heading\n // underlined below it, while GitHub reads a table, and a blank line would\n // make it a table there as well.\n if (\n document.dialect !== \"commonmark\" &&\n (after.type === \"paragraph\" || after.type === \"heading\") &&\n misreadTable(source.slice(afterStart, afterEnd))\n )\n return true;\n // In a block quote, the parser counts a line of quote markers below a list\n // that ends in an empty footnote definition as part of the list item, which\n // makes the item loose.\n const last = lastBlock(before);\n if (\n parent.type === \"blockquote\" &&\n before.type === \"list\" &&\n last.type === \"footnoteDefinition\" &&\n !last.children.length\n )\n return true;\n // Directly below text or a link reference definition, the parser does not\n // start a list that would be empty or not start at 1, though it does below\n // a blank line: there, `- -` is a list item holding the text `-`, and `-`\n // underlined with `---` is a heading. Such a list could start on the first\n // line of a list or quote, and such a line could begin an underlined heading.\n if (![\"paragraph\", \"definition\"].includes(lastBlock(before).type)) return false;\n const firstLine = source.slice(afterStart, lineBounds(source, afterStart, afterStart)[1]);\n if (after.type === \"heading\") return !/^[ \\t]*#/.test(firstLine);\n return (after.type === \"list\" || after.type === \"blockquote\") && nestedListStart.test(firstLine);\n}\nconst blockSpacing: Rule = {\n description: \"Separate headings and lists from neighboring blocks with a blank line.\",\n kind: \"style\",\n phase: \"block\",\n schema: optionsSchema({}),\n check({ document }) {\n const { source } = document;\n const findings: Finding[] = [];\n const newline = lineEnding(source);\n const directiveLines = new Set<number>();\n if (source.includes(\"mdtools-\"))\n walk(document.tree, \"html\", (node) => {\n if (directive(node.value)?.kind === \"disable-next-line\")\n directiveLines.add(node.position!.end.line);\n });\n // Only the blocks of the document and of block quotes are compared. A\n // blank line between the blocks of a list item makes its list loose.\n walk(document.tree, (parent) => {\n if (parent.type !== \"root\" && parent.type !== \"blockquote\") return;\n for (let index = 1; index < parent.children.length; index++) {\n const before = parent.children[index - 1]!;\n const after = parent.children[index]!;\n const subject = [after, before].find(\n (node) => node.type === \"heading\" || node.type === \"list\",\n );\n // A plugin's syntax can add a node without a source position.\n const located = [before, after].every(\n ({ position }) =>\n position?.start.offset !== undefined && position.end.offset !== undefined,\n );\n if (!subject || !located || together(document, parent, index, directiveLines)) continue;\n const end = range(before)[1];\n const start = range(after)[0];\n const lineStart = lineBounds(source, start, start)[0];\n const breakStart = lineStart - (source.startsWith(\"\\r\\n\", lineStart - 2) ? 2 : 1);\n if (breakStart < end) continue;\n // A blank line, or one with only quote markers, already separates them.\n const previous = source.slice(lineBounds(source, breakStart, breakStart)[0], breakStart);\n if (blankLine.test(previous)) continue;\n // The block's own line holds the quote markers that the new line needs.\n const prefix = source.slice(lineStart, start);\n if (!blankLine.test(prefix)) continue;\n const kind = subject.type === \"heading\" ? \"heading\" : \"list\";\n findings.push({\n start: subject === after ? start : end,\n message: `Add a blank line ${subject === after ? \"before\" : \"after\"} the ${kind}.`,\n edit: {\n start: breakStart,\n end: lineStart,\n text: source.slice(breakStart, lineStart) + prefix.replace(/[ \\t]+$/, \"\") + newline,\n },\n });\n }\n });\n return findings;\n },\n};\n\nexport const styleRules: Record<string, Rule> = {\n \"style/wrap\": wrap,\n \"style/inline-code\": {\n description: \"Join multiline code spans using their CommonMark rendered value.\",\n kind: \"style\",\n phase: \"inline\",\n schema: optionsSchema({}),\n check({ document }) {\n const findings: Finding[] = [];\n const { source } = document;\n const forge = goldmarkForges[document.dialect] !== undefined;\n // In Obsidian, the inline nodes whose source joined lines cannot change.\n const opaque: Range[] = [];\n if (document.dialect === \"obsidian\")\n walk(document.tree, (node) => {\n if (obsidianOpaque.has(node.type) || node.type === \"obsidianComment\")\n opaque.push(range(node));\n });\n const titles = calloutTitles(document);\n let headingEnd = 0;\n let blockStart = 0;\n walk(document.tree, (node) => {\n if (node.type === \"heading\" && forge) headingEnd = range(node)[1];\n if (inlineBlocks.has(node.type)) blockStart = range(node)[0];\n if (node.type !== \"inlineCode\") return;\n const [start, end] = range(node);\n if (!/[\\r\\n]/.test(source.slice(start, end))) return;\n // Forgejo and Gitea look for a heading's attribute block on its last\n // text line, and Forgejo also builds the anchor from that line alone.\n // Joining lines would change what that line holds.\n if (start < headingEnd) return;\n // Joining keeps the spaces and tabs that start a lazy continuation line,\n // as GitHub shows them; commonmark.js drops them, and the other\n // dialects' renderers were not observed there.\n if (document.dialect !== \"github\" && lazyIndentation(node)) return;\n if (document.dialect === \"gitea\" && giteaPyLine(document, start, end)) return;\n // Joining lines could put a `\\(` and `\\)` on one line and turn them into math.\n if (forge) {\n const lines = document.source.slice(...lineBounds(document.source, start, end));\n if (lines.includes(\"\\\\(\") && lines.includes(\"\\\\)\")) return;\n }\n // Joining would move text onto the line of a callout's or alert's\n // marker, which holds an Obsidian callout's title.\n if (titles.some(([a, b]) => start >= a && start < b)) return;\n if (document.dialect === \"obsidian\") {\n // Obsidian reads highlights and wikilinks only within a line. Once\n // the lines are one, an `==` or `[[` left as text could open one that\n // runs to the next `==` or `]]`, even inside this or another span.\n const [from, to] = lineBounds(source, start, end);\n const lines = source.slice(from, to);\n let text = \"\";\n let cursor = from;\n for (const [a, b] of opaque) {\n if (b <= cursor || a >= to) continue;\n // A space keeps the text on both sides from forming a marker.\n text += source.slice(cursor, Math.max(cursor, a)) + \" \";\n cursor = Math.min(b, to);\n }\n text += source.slice(cursor, to);\n if (\n (text.includes(\"==\") && (lines.match(/==/g) ?? []).length > 1) ||\n (text.includes(\"[[\") && lines.includes(\"]]\"))\n )\n return;\n }\n // The joined span holds the text that GitHub shows. A space at each end\n // keeps a backtick there from joining the fence, or spaces there from\n // being taken off.\n const value = codeSpanText(node);\n const longest = Math.max(0, ...(value.match(/`+/g) ?? []).map((run) => run.length));\n const marker = \"`\".repeat(longest + 1);\n // An earlier run of the new backticks that the parser left as text, or\n // that lies in a link destination, would pair with the new opening one.\n // The span's own backticks cannot have such a run before them.\n if (marker.length !== /^`+/.exec(source.slice(start, end))![0].length) {\n const before = source.slice(blockStart, start);\n for (const run of before.matchAll(/`+/g)) {\n const length = run[0].length;\n if (\n length === marker.length ||\n (escaped(before, run.index) && length - 1 === marker.length)\n )\n return;\n }\n }\n const pad = /^`|`$/.test(value) || (/^ .* $/.test(value) && /[^ ]/.test(value)) ? \" \" : \"\";\n findings.push({\n start,\n end,\n message: \"Join the code span onto one line.\",\n edit: { start, end, text: `${marker}${pad}${value}${pad}${marker}` },\n });\n });\n return findings;\n },\n },\n \"style/emphasis\": markerRule(\"emphasis\", \"_\"),\n \"style/strong\": markerRule(\"strong\", \"*\"),\n \"style/table\": table,\n \"style/final-newline\": {\n description: \"End nonempty documents with a newline.\",\n kind: \"style\",\n phase: \"document\",\n schema: optionsSchema({}),\n check({ document }) {\n const { source } = document;\n // An unclosed block at the end, such as an HTML comment, would take in the line ending.\n if (!source || /[\\r\\n]$/.test(source) || takesFinalLineEnding(document)) return [];\n return [\n {\n start: source.length,\n message: \"Add a final newline.\",\n edit: { start: source.length, end: source.length, text: lineEnding(source) },\n },\n ];\n },\n },\n \"style/heading\": {\n description: \"Use ATX or Setext headings, without closing sequences.\",\n kind: \"style\",\n phase: \"block\",\n schema: optionsSchema({\n style: { enum: [\"atx\", \"setext\", \"consistent\"] },\n closing: { enum: [\"remove\", \"keep\"] },\n }),\n check({ document, options }) {\n const findings: Finding[] = [];\n const { source } = document;\n // Only levels 1 and 2 can be underlined; deeper headings keep their `#`.\n const underlined = underlinedHeadings(document, options.style);\n walk(document.tree, \"heading\", (node) => {\n const [headingStart, end] = range(node);\n const first = node.children[0];\n const last = node.children.at(-1);\n // An ATX heading is one line, a Setext heading also has its underline.\n if (!/[\\r\\n]/.test(source.slice(headingStart, end))) {\n const edit = underlined ? underlineEdit(document, node) : undefined;\n if (edit) {\n findings.push({\n start: edit.start,\n end: edit.end,\n message: \"Use an underlined heading.\",\n edit,\n });\n return;\n }\n if (options.closing === \"keep\") return;\n const textEnd = last\n ? range(last)[1]\n : headingStart + /^#*/.exec(source.slice(headingStart))![0].length;\n const lineEnd = lineBounds(source, textEnd, textEnd)[1];\n if (!/^[ \\t]+#+[ \\t]*$/.test(source.slice(textEnd, lineEnd))) return;\n // Gitea before 1.26 reads an attribute block that a closing sequence\n // follows, and Forgejo and later Gitea versions do not.\n if (\n goldmarkForges[document.dialect] &&\n first &&\n headingAttributeBlock(source.slice(range(first)[0], textEnd))\n )\n return;\n findings.push({\n start: textEnd,\n end: lineEnd,\n message: \"Remove the closing # sequence.\",\n edit: { start: textEnd, end: lineEnd, text: \"\" },\n });\n return;\n }\n if (underlined || !first || !last) return;\n // Below link reference definitions, the heading's position starts at\n // the first definition; its own text starts on a later line. Headings\n // that are indented or inside lists or block quotes are left as written.\n const start = range(first)[0];\n if (lineBounds(source, start, start)[0] !== start) return;\n let text = source.slice(start, range(last)[1]);\n if (/[\\r\\n]/.test(text)) return;\n // A trailing run of # after whitespace would become an ATX closing\n // sequence and disappear from the heading; escape its first character.\n text = text.replace(/(^|\\s)(#+)$/, \"$1\\\\$2\");\n // Forgejo and Gitea also take such a run for a closing sequence when\n // their attribute block follows it, and would drop it from the heading.\n const block = goldmarkForges[document.dialect] ? headingAttributeBlock(text) : undefined;\n if (block)\n text =\n text.slice(0, block.start).replace(/(^|\\s)(#+)(\\s*)$/, \"$1\\\\$2$3\") +\n text.slice(block.start);\n findings.push({\n start,\n end,\n message: \"Use an ATX heading.\",\n edit: { start, end, text: `${\"#\".repeat(node.depth)} ${text}` },\n });\n });\n return findings;\n },\n },\n \"style/block-spacing\": blockSpacing,\n};\n\n/** Collect source-positioned nodes for rule/plugin consumers. */\nexport function nodesOfType(\n document: { tree: import(\"mdast\").Root },\n type: Nodes[\"type\"],\n): Nodes[] {\n const result: Nodes[] = [];\n walk(document.tree, (node) => {\n if (node.type === type) result.push(node);\n });\n return result;\n}\n"]}
|
package/dist/syntax/parse.js
CHANGED
|
@@ -216,7 +216,9 @@ export function parse(source, dialect, path = "document.md", plugins = []) {
|
|
|
216
216
|
// footnotes, autolinks, and dollar math. Forgejo and Gitea syntax beyond
|
|
217
217
|
// that is protected by rules rather than parsed.
|
|
218
218
|
if (read !== "commonmark") {
|
|
219
|
-
|
|
219
|
+
// Obsidian marks strikethrough with two tildes only; `~a~` is text there
|
|
220
|
+
// (issue #319).
|
|
221
|
+
extensions.push(gfm({ singleTilde: read !== "obsidian" }), math(mathConditions[read]));
|
|
220
222
|
mdastExtensions.push(...gfmTree, mathFromMarkdown());
|
|
221
223
|
}
|
|
222
224
|
if (read === "obsidian") {
|
package/dist/syntax/parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/syntax/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGxD,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGnD,OA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AAC,IAAI,CAAC,CAAC;IAC1D,IAAI,OAAO,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC;IACvC,IAAI,UAAU,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACvE,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import { fromMarkdown } from \"mdast-util-from-markdown\";\nimport type { Extension as TreeExtension } from \"mdast-util-from-markdown\";\nimport type { Extension as SyntaxExtension } from \"micromark-util-types\";\nimport { gfm } from \"micromark-extension-gfm\";\nimport { gfmFromMarkdown } from \"mdast-util-gfm\";\nimport { frontmatter } from \"micromark-extension-frontmatter\";\nimport { frontmatterFromMarkdown } from \"mdast-util-frontmatter\";\nimport { mathFromMarkdown } from \"mdast-util-math\";\nimport type { InlineCode, Nodes, Paragraph, Root } from \"mdast\";\nimport type { Dialect, DialectName, Document, Plugin } from \"../core/types.js\";\nimport { knownDialect } from \"../config/resolve.js\";\nimport { math } from \"./math.js\";\nimport type { MathConditions } from \"./math.js\";\nimport { obsidianSyntax, obsidianTree } from \"./obsidian.js\";\n\n// GFM's tree transform performs GitHub's second, transform-time autolink pass\n// (`[www.example.com]` or a Forgejo shortlink's `|https://` in files), but its\n// nodes carry no source positions, which made the engine refuse whole documents.\n// No built-in rule acts on literal autolinks, so output is unchanged without it;\n// plugins inspecting link nodes do not see those autolinks.\nconst gfmTree = gfmFromMarkdown().map((extension) => {\n const copy = { ...extension };\n delete copy.transforms;\n return copy;\n});\n\n/** The offset of the `]` that closes the text of each link and image, by node. */\nconst labelEnds = new WeakMap<Nodes, number>();\n/**\n * Record where the text of a link or image ends. The tree keeps an image's\n * description only as plain text, so its source positions are otherwise lost.\n */\nconst labelEndTree: TreeExtension = {\n exit: {\n // A label has an opening and a closing marker; the closing one comes last.\n labelMarker(token) {\n // The label's fragment is on top of the stack, and the link or image below it.\n const node = this.stack[this.stack.length - 2];\n if (node?.type === \"link\" || node?.type === \"image\") labelEnds.set(node, token.start.offset);\n },\n },\n};\n/**\n * Where the text of a link or the description of an image ends in the source:\n * the offset of its closing `]`. Undefined for other nodes and for nodes that\n * `parse` did not make.\n */\nexport function labelEnd(node: Nodes): number | undefined {\n return labelEnds.get(node);\n}\n/**\n * What the value of a code span in the tree leaves out, by node: the space or\n * line ending that the parser took off each end, and which lines of the\n * document are lazy continuation lines.\n */\nconst codeSpanSources = new WeakMap<\n InlineCode,\n { padding: string[]; lazy: Record<number, boolean> }\n>();\n/**\n * The extensions of one parse that record what code spans leave out. The\n * parser knows which lines are lazy once it has read the document's blocks, and\n * a construct at a backtick, which never matches, reads that from it before a\n * code span is read there.\n */\nfunction codeSpanRecording(): { syntax: SyntaxExtension; tree: TreeExtension } {\n let lazy: Record<number, boolean> = {};\n return {\n syntax: {\n text: {\n [0x60]: {\n // The text tokenizer asks each construct at a backtick whether the\n // character before allows it, and tries them all if one does. This\n // one never does, so the parse is the same as without it.\n previous() {\n lazy = this.parser.lazy;\n return false;\n },\n tokenize(_effects, _ok, nok) {\n lazy = this.parser.lazy;\n return nok;\n },\n },\n },\n },\n tree: {\n exit: {\n // The span's value is collected in a fragment on top of the stack, with\n // the span's node below it.\n codeTextSequence() {\n const node = this.stack[this.stack.length - 2];\n if (node?.type === \"inlineCode\" && !codeSpanSources.has(node))\n codeSpanSources.set(node, { padding: [], lazy });\n },\n codeTextPadding(token) {\n const node = this.stack[this.stack.length - 2];\n if (node?.type === \"inlineCode\")\n codeSpanSources.get(node)?.padding.push(this.sliceSerialize(token));\n },\n },\n },\n };\n}\n/**\n * The text of a code span as GitHub shows it, read in CommonMark's order: the\n * spaces and tabs that start each line after the first are dropped, as from\n * every line of a paragraph, but kept on a lazy continuation line, one that\n * lacks its block quote's `>` or its list item's indentation; then each line\n * ending becomes a space; then one space comes off each end when both ends\n * have one and the span is not only spaces. The parser keeps the spaces and\n * tabs in the span's value, and takes a space or line ending off each end\n * before line endings become spaces (issues #276 and #290). A node that\n * `parse` did not make is read as if its value were all of its content.\n */\nexport function codeSpanText(node: InlineCode): string {\n const { padding = [], lazy = {} } = codeSpanSources.get(node) ?? {};\n let line = node.position?.start.line ?? 0;\n const content = `${padding[0] ?? \"\"}${node.value}${padding[1] ?? \"\"}`.replace(\n /(?:\\r\\n|\\r|\\n)([ \\t]*)/g,\n (_, indentation: string) => (lazy[++line] ? ` ${indentation}` : \" \"),\n );\n return /^ [^]* $/.test(content) && /[^ ]/.test(content) ? content.slice(1, -1) : content;\n}\n/**\n * Whether a code span goes on in a lazy continuation line that starts with\n * spaces or tabs. GitHub keeps them in the span, as `codeSpanText` does, and\n * commonmark.js drops them, so renderers show such a span differently.\n */\nexport function lazyIndentation(node: InlineCode): boolean {\n const { padding = [], lazy = {} } = codeSpanSources.get(node) ?? {};\n let line = node.position?.start.line ?? 0;\n const content = `${padding[0] ?? \"\"}${node.value}${padding[1] ?? \"\"}`;\n for (const [, indentation] of content.matchAll(/(?:\\r\\n|\\r|\\n)([ \\t]*)/g))\n if (lazy[++line] && indentation) return true;\n return false;\n}\n\n/**\n * Whose conditions for `$…$` in running text each dialect follows, as observed\n * on GitHub's file view, on Forgejo 16 and Gitea 1.25 and 28, and in Obsidian's\n * Reading view and Live Preview. CommonMark has no math.\n */\nconst mathConditions: Record<Exclude<Dialect, \"commonmark\">, MathConditions> = {\n github: \"github\",\n forgejo: \"forge\",\n gitea: \"forge\",\n obsidian: \"obsidian\",\n};\n\n/**\n * The byte order marks that `source` starts with, and the text after them.\n * Some editors write a mark at the start of a UTF-8 file, and a program that\n * adds one without looking can leave two. The parser skips one mark at the\n * start of what it is given.\n */\nexport function splitByteOrderMark(source: string): [string, string] {\n let end = 0;\n while (source.charCodeAt(end) === 0xfeff) end++;\n return [source.slice(0, end), source.slice(end)];\n}\n\n/**\n * The reading with front matter of a document that `parse` read without it,\n * by the tree of the reading without it.\n */\nconst frontMatterReadings = new WeakMap<Root, Root>();\n/**\n * The document read with front matter, where `parse` read it without front\n * matter because its front matter would end inside a code block, an HTML\n * block, or display math. Site generators read front matter there, and so does\n * GitHub's file view when it is a YAML mapping; GitHub's comments and\n * renderers without front matter read the block. Undefined for other trees.\n */\nexport function frontMatterReading(tree: Root): Root | undefined {\n return frontMatterReadings.get(tree);\n}\n/**\n * A line of front matter that could open a block whose content is literal: a\n * code fence, display math, or an HTML block.\n */\nconst literalOpener = /^ {0,3}(?:`{3,}|~{3,}|\\$\\$|<)/m;\n/** Blocks in which a `---` or `+++` line is content, not a closing line. */\nconst literalBlocks = new Set([\"code\", \"html\", \"math\"]);\n/**\n * The fence, `---` or `+++`, of front matter that the first line of `source`\n * opens and no line closes. The front matter extension opens front matter at a\n * first line of `---` or `+++` followed only by spaces or tabs, and closes it\n * at the next line of the same fence, also followed only by spaces or tabs.\n * Without a closing line the document has no front matter, but the extension\n * then reads the lists and block quotes below as paragraphs (issue #278,\n * micromark/micromark-extension-frontmatter#5). An edit that writes such a line\n * below makes front matter of everything above it.\n */\nexport function unclosedFrontMatter(source: string): \"---\" | \"+++\" | undefined {\n const opening = /^(---|\\+\\+\\+)[ \\t]*(?:\\r\\n|\\r|\\n)/.exec(source);\n if (!opening) return undefined;\n const fence = opening[1] as \"---\" | \"+++\";\n const closing = new RegExp(`(?:^|\\\\r|\\\\n)${fence.replaceAll(\"+\", \"\\\\+\")}[ \\\\t]*(?:\\\\r|\\\\n|$)`);\n return closing.test(source.slice(opening[0].length)) ? undefined : fence;\n}\n\n/**\n * Parse a document in `dialect`, or the dialect that an alias such as\n * `codeberg` stands for, which the result holds; an unknown dialect is an\n * error. Byte order marks at the start of `source` are not part of the\n * document: the document's source starts after them, as the positions in the\n * tree count. `path` is the document's path relative to the workspace root,\n * and `plugins` add their syntax extensions.\n *\n * Front matter whose `---` or `+++` closes it inside a code block, an HTML\n * block, or display math, opened by a line of the front matter, is read as\n * Markdown: the document is read without it (issue #295), and\n * `frontMatterReading` gives the other reading. A document whose first line\n * would open front matter that no line closes is read without the front matter\n * extension, as renderers read it (issue #278).\n */\nexport function parse(\n source: string,\n dialect: DialectName,\n path = \"document.md\",\n plugins: readonly Plugin[] = [],\n): Document {\n const read = knownDialect(dialect);\n source = splitByteOrderMark(source)[1];\n const tree = (withFrontMatter: boolean): Root => {\n const codeSpans = codeSpanRecording();\n const extensions = [codeSpans.syntax];\n const mdastExtensions = [labelEndTree, codeSpans.tree];\n if (withFrontMatter) {\n extensions.unshift(frontmatter([\"yaml\", \"toml\"]));\n mdastExtensions.unshift(frontmatterFromMarkdown([\"yaml\", \"toml\"]));\n }\n // GitHub, Forgejo, and Gitea share GFM tables, task lists, strikethrough,\n // footnotes, autolinks, and dollar math. Forgejo and Gitea syntax beyond\n // that is protected by rules rather than parsed.\n if (read !== \"commonmark\") {\n extensions.push(gfm(), math(mathConditions[read]));\n mdastExtensions.push(...gfmTree, mathFromMarkdown());\n }\n if (read === \"obsidian\") {\n extensions.push(obsidianSyntax);\n mdastExtensions.push(obsidianTree);\n }\n for (const plugin of plugins) {\n if (plugin.syntax) {\n extensions.push(plugin.syntax.micromark);\n mdastExtensions.push(plugin.syntax.mdast);\n }\n }\n return fromMarkdown(source, { extensions, mdastExtensions });\n };\n let result = tree(!unclosedFrontMatter(source));\n // The tree's types know YAML front matter only; the parser also reads TOML.\n const matter = result.children[0] as { type: string; value?: string } | undefined;\n // Only front matter with a line that could open such a block is read again.\n // It is given up only when the line that closes it is content of that block\n // in the other reading, which a multiline TOML string or a YAML block\n // scalar holding a fence does not decide by itself.\n if (\n (matter?.type === \"yaml\" || matter?.type === \"toml\") &&\n literalOpener.test(matter.value ?? \"\")\n ) {\n const closing = result.children[0]!.position!.end.line;\n const plain = tree(false);\n if (\n plain.children.some(\n (node) =>\n literalBlocks.has(node.type) &&\n node.position!.start.line < closing &&\n node.position!.end.line >= closing,\n )\n ) {\n frontMatterReadings.set(plain, result);\n result = plain;\n }\n }\n return { source, dialect: read, path, tree: result };\n}\n\n/**\n * The `[start, end]` offsets of a node of a parsed document in its `source`:\n * half-open, in UTF-16 code units. A node without a source position, such as\n * one that a plugin's tree extension built without one, is an error.\n */\nexport function range(node: Nodes): [number, number] {\n if (node.position?.start.offset === undefined || node.position.end.offset === undefined) {\n throw new Error(`Missing source position for ${node.type}`);\n }\n return [node.position.start.offset, node.position.end.offset];\n}\n/** An alert's or callout's marker, such as `[!NOTE]` or `[!tip]`. */\nconst calloutMarker = /^\\[![\\w-]+\\]/;\n/**\n * Whether a paragraph starts with text that `pattern` matches, by default an\n * alert's or callout's marker: in `written`, its source from its start, or in\n * its text as renderers read it, where a backslash escape or a character\n * reference stands for the character it writes. GitHub reads `\\[!NOTE]`,\n * `[!NOTE]`, and `[!NOTE]` as alerts too (issue #294).\n */\nexport function startsWithMarker(\n written: string,\n paragraph: Paragraph,\n pattern: RegExp = calloutMarker,\n): boolean {\n const first = paragraph.children[0];\n return pattern.test(written) || (first?.type === \"text\" && pattern.test(first.value));\n}\n/**\n * A node's text as a reader sees it: the values of its text, code, and other\n * literal nodes, in order. A code span gives its text as `codeSpanText` reads\n * it, on one line, a wikilink its label, or else its target, and an Obsidian\n * comment nothing.\n */\nexport function textContent(node: Nodes): string {\n if (node.type === \"wikiLink\") return node.label ?? node.target;\n if (node.type === \"obsidianComment\") return \"\";\n if (node.type === \"inlineCode\") return codeSpanText(node);\n if (\"value\" in node) return node.value;\n if (\"children\" in node) return node.children.map(textContent).join(\"\");\n return \"\";\n}\n"]}
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/syntax/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGxD,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;A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CAAC;IAC/D,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB;QAAE,OAAO,EAAE,CAAC;IAC/C,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY;QAAE,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;IAC1D,IAAI,OAAO,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC;IACvC,IAAI,UAAU,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACvE,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import { fromMarkdown } from \"mdast-util-from-markdown\";\nimport type { Extension as TreeExtension } from \"mdast-util-from-markdown\";\nimport type { Extension as SyntaxExtension } from \"micromark-util-types\";\nimport { gfm } from \"micromark-extension-gfm\";\nimport { gfmFromMarkdown } from \"mdast-util-gfm\";\nimport { frontmatter } from \"micromark-extension-frontmatter\";\nimport { frontmatterFromMarkdown } from \"mdast-util-frontmatter\";\nimport { mathFromMarkdown } from \"mdast-util-math\";\nimport type { InlineCode, Nodes, Paragraph, Root } from \"mdast\";\nimport type { Dialect, DialectName, Document, Plugin } from \"../core/types.js\";\nimport { knownDialect } from \"../config/resolve.js\";\nimport { math } from \"./math.js\";\nimport type { MathConditions } from \"./math.js\";\nimport { obsidianSyntax, obsidianTree } from \"./obsidian.js\";\n\n// GFM's tree transform performs GitHub's second, transform-time autolink pass\n// (`[www.example.com]` or a Forgejo shortlink's `|https://` in files), but its\n// nodes carry no source positions, which made the engine refuse whole documents.\n// No built-in rule acts on literal autolinks, so output is unchanged without it;\n// plugins inspecting link nodes do not see those autolinks.\nconst gfmTree = gfmFromMarkdown().map((extension) => {\n const copy = { ...extension };\n delete copy.transforms;\n return copy;\n});\n\n/** The offset of the `]` that closes the text of each link and image, by node. */\nconst labelEnds = new WeakMap<Nodes, number>();\n/**\n * Record where the text of a link or image ends. The tree keeps an image's\n * description only as plain text, so its source positions are otherwise lost.\n */\nconst labelEndTree: TreeExtension = {\n exit: {\n // A label has an opening and a closing marker; the closing one comes last.\n labelMarker(token) {\n // The label's fragment is on top of the stack, and the link or image below it.\n const node = this.stack[this.stack.length - 2];\n if (node?.type === \"link\" || node?.type === \"image\") labelEnds.set(node, token.start.offset);\n },\n },\n};\n/**\n * Where the text of a link or the description of an image ends in the source:\n * the offset of its closing `]`. Undefined for other nodes and for nodes that\n * `parse` did not make.\n */\nexport function labelEnd(node: Nodes): number | undefined {\n return labelEnds.get(node);\n}\n/**\n * What the value of a code span in the tree leaves out, by node: the space or\n * line ending that the parser took off each end, and which lines of the\n * document are lazy continuation lines.\n */\nconst codeSpanSources = new WeakMap<\n InlineCode,\n { padding: string[]; lazy: Record<number, boolean> }\n>();\n/**\n * The extensions of one parse that record what code spans leave out. The\n * parser knows which lines are lazy once it has read the document's blocks, and\n * a construct at a backtick, which never matches, reads that from it before a\n * code span is read there.\n */\nfunction codeSpanRecording(): { syntax: SyntaxExtension; tree: TreeExtension } {\n let lazy: Record<number, boolean> = {};\n return {\n syntax: {\n text: {\n [0x60]: {\n // The text tokenizer asks each construct at a backtick whether the\n // character before allows it, and tries them all if one does. This\n // one never does, so the parse is the same as without it.\n previous() {\n lazy = this.parser.lazy;\n return false;\n },\n tokenize(_effects, _ok, nok) {\n lazy = this.parser.lazy;\n return nok;\n },\n },\n },\n },\n tree: {\n exit: {\n // The span's value is collected in a fragment on top of the stack, with\n // the span's node below it.\n codeTextSequence() {\n const node = this.stack[this.stack.length - 2];\n if (node?.type === \"inlineCode\" && !codeSpanSources.has(node))\n codeSpanSources.set(node, { padding: [], lazy });\n },\n codeTextPadding(token) {\n const node = this.stack[this.stack.length - 2];\n if (node?.type === \"inlineCode\")\n codeSpanSources.get(node)?.padding.push(this.sliceSerialize(token));\n },\n },\n },\n };\n}\n/**\n * The text of a code span as GitHub shows it, read in CommonMark's order: the\n * spaces and tabs that start each line after the first are dropped, as from\n * every line of a paragraph, but kept on a lazy continuation line, one that\n * lacks its block quote's `>` or its list item's indentation; then each line\n * ending becomes a space; then one space comes off each end when both ends\n * have one and the span is not only spaces. The parser keeps the spaces and\n * tabs in the span's value, and takes a space or line ending off each end\n * before line endings become spaces (issues #276 and #290). A node that\n * `parse` did not make is read as if its value were all of its content.\n */\nexport function codeSpanText(node: InlineCode): string {\n const { padding = [], lazy = {} } = codeSpanSources.get(node) ?? {};\n let line = node.position?.start.line ?? 0;\n const content = `${padding[0] ?? \"\"}${node.value}${padding[1] ?? \"\"}`.replace(\n /(?:\\r\\n|\\r|\\n)([ \\t]*)/g,\n (_, indentation: string) => (lazy[++line] ? ` ${indentation}` : \" \"),\n );\n return /^ [^]* $/.test(content) && /[^ ]/.test(content) ? content.slice(1, -1) : content;\n}\n/**\n * Whether a code span goes on in a lazy continuation line that starts with\n * spaces or tabs. GitHub keeps them in the span, as `codeSpanText` does, and\n * commonmark.js drops them, so renderers show such a span differently.\n */\nexport function lazyIndentation(node: InlineCode): boolean {\n const { padding = [], lazy = {} } = codeSpanSources.get(node) ?? {};\n let line = node.position?.start.line ?? 0;\n const content = `${padding[0] ?? \"\"}${node.value}${padding[1] ?? \"\"}`;\n for (const [, indentation] of content.matchAll(/(?:\\r\\n|\\r|\\n)([ \\t]*)/g))\n if (lazy[++line] && indentation) return true;\n return false;\n}\n\n/**\n * Whose conditions for `$…$` in running text each dialect follows, as observed\n * on GitHub's file view, on Forgejo 16 and Gitea 1.25 and 28, and in Obsidian's\n * Reading view and Live Preview. CommonMark has no math.\n */\nconst mathConditions: Record<Exclude<Dialect, \"commonmark\">, MathConditions> = {\n github: \"github\",\n forgejo: \"forge\",\n gitea: \"forge\",\n obsidian: \"obsidian\",\n};\n\n/**\n * The byte order marks that `source` starts with, and the text after them.\n * Some editors write a mark at the start of a UTF-8 file, and a program that\n * adds one without looking can leave two. The parser skips one mark at the\n * start of what it is given.\n */\nexport function splitByteOrderMark(source: string): [string, string] {\n let end = 0;\n while (source.charCodeAt(end) === 0xfeff) end++;\n return [source.slice(0, end), source.slice(end)];\n}\n\n/**\n * The reading with front matter of a document that `parse` read without it,\n * by the tree of the reading without it.\n */\nconst frontMatterReadings = new WeakMap<Root, Root>();\n/**\n * The document read with front matter, where `parse` read it without front\n * matter because its front matter would end inside a code block, an HTML\n * block, or display math. Site generators read front matter there, and so does\n * GitHub's file view when it is a YAML mapping; GitHub's comments and\n * renderers without front matter read the block. Undefined for other trees.\n */\nexport function frontMatterReading(tree: Root): Root | undefined {\n return frontMatterReadings.get(tree);\n}\n/**\n * A line of front matter that could open a block whose content is literal: a\n * code fence, display math, or an HTML block.\n */\nconst literalOpener = /^ {0,3}(?:`{3,}|~{3,}|\\$\\$|<)/m;\n/** Blocks in which a `---` or `+++` line is content, not a closing line. */\nconst literalBlocks = new Set([\"code\", \"html\", \"math\"]);\n/**\n * The fence, `---` or `+++`, of front matter that the first line of `source`\n * opens and no line closes. The front matter extension opens front matter at a\n * first line of `---` or `+++` followed only by spaces or tabs, and closes it\n * at the next line of the same fence, also followed only by spaces or tabs.\n * Without a closing line the document has no front matter, but the extension\n * then reads the lists and block quotes below as paragraphs (issue #278,\n * micromark/micromark-extension-frontmatter#5). An edit that writes such a line\n * below makes front matter of everything above it.\n */\nexport function unclosedFrontMatter(source: string): \"---\" | \"+++\" | undefined {\n const opening = /^(---|\\+\\+\\+)[ \\t]*(?:\\r\\n|\\r|\\n)/.exec(source);\n if (!opening) return undefined;\n const fence = opening[1] as \"---\" | \"+++\";\n const closing = new RegExp(`(?:^|\\\\r|\\\\n)${fence.replaceAll(\"+\", \"\\\\+\")}[ \\\\t]*(?:\\\\r|\\\\n|$)`);\n return closing.test(source.slice(opening[0].length)) ? undefined : fence;\n}\n\n/**\n * Parse a document in `dialect`, or the dialect that an alias such as\n * `codeberg` stands for, which the result holds; an unknown dialect is an\n * error. Byte order marks at the start of `source` are not part of the\n * document: the document's source starts after them, as the positions in the\n * tree count. `path` is the document's path relative to the workspace root,\n * and `plugins` add their syntax extensions.\n *\n * Front matter whose `---` or `+++` closes it inside a code block, an HTML\n * block, or display math, opened by a line of the front matter, is read as\n * Markdown: the document is read without it (issue #295), and\n * `frontMatterReading` gives the other reading. A document whose first line\n * would open front matter that no line closes is read without the front matter\n * extension, as renderers read it (issue #278).\n */\nexport function parse(\n source: string,\n dialect: DialectName,\n path = \"document.md\",\n plugins: readonly Plugin[] = [],\n): Document {\n const read = knownDialect(dialect);\n source = splitByteOrderMark(source)[1];\n const tree = (withFrontMatter: boolean): Root => {\n const codeSpans = codeSpanRecording();\n const extensions = [codeSpans.syntax];\n const mdastExtensions = [labelEndTree, codeSpans.tree];\n if (withFrontMatter) {\n extensions.unshift(frontmatter([\"yaml\", \"toml\"]));\n mdastExtensions.unshift(frontmatterFromMarkdown([\"yaml\", \"toml\"]));\n }\n // GitHub, Forgejo, and Gitea share GFM tables, task lists, strikethrough,\n // footnotes, autolinks, and dollar math. Forgejo and Gitea syntax beyond\n // that is protected by rules rather than parsed.\n if (read !== \"commonmark\") {\n // Obsidian marks strikethrough with two tildes only; `~a~` is text there\n // (issue #319).\n extensions.push(gfm({ singleTilde: read !== \"obsidian\" }), math(mathConditions[read]));\n mdastExtensions.push(...gfmTree, mathFromMarkdown());\n }\n if (read === \"obsidian\") {\n extensions.push(obsidianSyntax);\n mdastExtensions.push(obsidianTree);\n }\n for (const plugin of plugins) {\n if (plugin.syntax) {\n extensions.push(plugin.syntax.micromark);\n mdastExtensions.push(plugin.syntax.mdast);\n }\n }\n return fromMarkdown(source, { extensions, mdastExtensions });\n };\n let result = tree(!unclosedFrontMatter(source));\n // The tree's types know YAML front matter only; the parser also reads TOML.\n const matter = result.children[0] as { type: string; value?: string } | undefined;\n // Only front matter with a line that could open such a block is read again.\n // It is given up only when the line that closes it is content of that block\n // in the other reading, which a multiline TOML string or a YAML block\n // scalar holding a fence does not decide by itself.\n if (\n (matter?.type === \"yaml\" || matter?.type === \"toml\") &&\n literalOpener.test(matter.value ?? \"\")\n ) {\n const closing = result.children[0]!.position!.end.line;\n const plain = tree(false);\n if (\n plain.children.some(\n (node) =>\n literalBlocks.has(node.type) &&\n node.position!.start.line < closing &&\n node.position!.end.line >= closing,\n )\n ) {\n frontMatterReadings.set(plain, result);\n result = plain;\n }\n }\n return { source, dialect: read, path, tree: result };\n}\n\n/**\n * The `[start, end]` offsets of a node of a parsed document in its `source`:\n * half-open, in UTF-16 code units. A node without a source position, such as\n * one that a plugin's tree extension built without one, is an error.\n */\nexport function range(node: Nodes): [number, number] {\n if (node.position?.start.offset === undefined || node.position.end.offset === undefined) {\n throw new Error(`Missing source position for ${node.type}`);\n }\n return [node.position.start.offset, node.position.end.offset];\n}\n/** An alert's or callout's marker, such as `[!NOTE]` or `[!tip]`. */\nconst calloutMarker = /^\\[![\\w-]+\\]/;\n/**\n * Whether a paragraph starts with text that `pattern` matches, by default an\n * alert's or callout's marker: in `written`, its source from its start, or in\n * its text as renderers read it, where a backslash escape or a character\n * reference stands for the character it writes. GitHub reads `\\[!NOTE]`,\n * `[!NOTE]`, and `[!NOTE]` as alerts too (issue #294).\n */\nexport function startsWithMarker(\n written: string,\n paragraph: Paragraph,\n pattern: RegExp = calloutMarker,\n): boolean {\n const first = paragraph.children[0];\n return pattern.test(written) || (first?.type === \"text\" && pattern.test(first.value));\n}\n/**\n * A node's text as a reader sees it: the values of its text, code, and other\n * literal nodes, in order. A code span gives its text as `codeSpanText` reads\n * it, on one line, a wikilink its label, or else its target, and an Obsidian\n * comment nothing.\n */\nexport function textContent(node: Nodes): string {\n if (node.type === \"wikiLink\") return node.label ?? node.target;\n if (node.type === \"obsidianComment\") return \"\";\n if (node.type === \"inlineCode\") return codeSpanText(node);\n if (\"value\" in node) return node.value;\n if (\"children\" in node) return node.children.map(textContent).join(\"\");\n return \"\";\n}\n"]}
|
package/docs/dialects.md
CHANGED
|
@@ -20,7 +20,8 @@ what is text, and so what formatting has to leave alone. Choose it in the
|
|
|
20
20
|
| Wikilinks, embeds, highlights (`==…==`), comments (`%%…%%`), `^block-ids` | No | No | No | No | Yes |
|
|
21
21
|
|
|
22
22
|
GitHub's syntax is the common base of the Forgejo, Gitea, and Obsidian dialects,
|
|
23
|
-
and the rules for GitHub Markdown apply to all three.
|
|
23
|
+
and the rules for GitHub Markdown apply to all three. Obsidian marks
|
|
24
|
+
strikethrough with two tildes only, so `~a~` is text there. The syntax that only
|
|
24
25
|
Forgejo and Gitea have is protected from formatting rather than parsed; see
|
|
25
26
|
[Forgejo and Gitea](#forgejo-and-gitea). Syntax that no dialect knows, such as
|
|
26
27
|
an Obsidian plugin's, is read as text: use a suppression comment or an `ignore`
|
package/docs/quick-start.md
CHANGED
package/docs/rules.md
CHANGED
|
@@ -761,6 +761,13 @@ so are the exceptions of [Forgejo and Gitea](dialects.md#forgejo-and-gitea):
|
|
|
761
761
|
the dollar decides whether dollar math ends there.
|
|
762
762
|
- Emphasis that begins on the line of an alert's or a callout's marker and ends
|
|
763
763
|
below it.
|
|
764
|
+
- Emphasis whose text holds a run of tildes that could mark strikethrough, one
|
|
765
|
+
or two tildes or in Obsidian two, while the paragraph holds another: GitHub
|
|
766
|
+
can read strikethrough there and the markers as text.
|
|
767
|
+
- A `_`, old or new, that only tildes separate from a letter or digit, as in
|
|
768
|
+
`x~~_b_~~`, which GitHub reads as inside a word.
|
|
769
|
+
- Text whose markers CommonMark pairs otherwise than the parser, as in
|
|
770
|
+
`xab***a* a*y`: GitHub follows CommonMark, so the parser misread the text.
|
|
764
771
|
|
|
765
772
|
## `style/final-newline`
|
|
766
773
|
|