mdrefine 0.2.3 → 0.2.5
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 +65 -0
- package/CONTRIBUTING.md +21 -1
- package/README.md +1 -1
- package/dist/core/engine.js +14 -3
- package/dist/core/engine.js.map +1 -1
- package/dist/rules/blocks.js +39 -4
- package/dist/rules/blocks.js.map +1 -1
- package/dist/rules/dialects.js +11 -0
- package/dist/rules/dialects.js.map +1 -1
- package/dist/rules/links.js +9 -2
- package/dist/rules/links.js.map +1 -1
- package/dist/rules/style.js +78 -1
- package/dist/rules/style.js.map +1 -1
- package/dist/syntax/misread-lists.d.ts +59 -8
- package/dist/syntax/misread-lists.js +273 -5
- package/dist/syntax/misread-lists.js.map +1 -1
- package/dist/syntax/obsidian.js +10 -2
- package/dist/syntax/obsidian.js.map +1 -1
- package/docs/design.md +7 -4
- package/docs/dialects.md +5 -2
- package/docs/obsidian.md +32 -0
- package/docs/quick-start.md +1 -1
- package/docs/rules.md +28 -14
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,71 @@ 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.5 - 2026-10-19
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- In the Obsidian dialect, no rule changes a paragraph with a later line that
|
|
16
|
+
Obsidian reads as starting a list item where CommonMark reads text: a number
|
|
17
|
+
other than 1 with text after it, which Live Preview reads as a list item, and
|
|
18
|
+
an empty item such as `*` or `- `, which Reading view reads as one, nor the
|
|
19
|
+
blocks indented below it. Before, `style/wrap` joined such a line into the
|
|
20
|
+
paragraph and `style/heading` wrote `Text` with `- ` below it as `## Text`
|
|
21
|
+
([#384](https://github.com/viell-dev/slop-markdown-tools/pull/384)).
|
|
22
|
+
- In the Obsidian dialect, `style/blank-lines` and `style/trailing-space` leave
|
|
23
|
+
a line of blank space that holds a tab, or that lies directly below an HTML
|
|
24
|
+
block, as written. Obsidian's Reading view reads such a line as more of the
|
|
25
|
+
paragraph or HTML block above it, so emptying or removing it split a
|
|
26
|
+
paragraph, or made a heading below an HTML block render. No rule changes the
|
|
27
|
+
blocks below such a line that Reading view shows as more of the HTML block, up
|
|
28
|
+
to an empty line
|
|
29
|
+
([#373](https://github.com/viell-dev/slop-markdown-tools/pull/373)).
|
|
30
|
+
- In the Obsidian dialect, no rule changes a paragraph, heading, or table cell
|
|
31
|
+
with a backtick that no run of backticks closes, also in a highlight, an
|
|
32
|
+
inline comment, or the text of a link or image. Live Preview shows the text
|
|
33
|
+
after it as code, at least to the end of its line, and Reading view pairs a
|
|
34
|
+
longer run with a later, shorter one, so the rules changed text that Obsidian
|
|
35
|
+
shows as code. After a run of three or more, the blocks that Live Preview
|
|
36
|
+
shows as code below it stay as written too
|
|
37
|
+
([#374](https://github.com/viell-dev/slop-markdown-tools/pull/374)).
|
|
38
|
+
- In the Obsidian dialect, `style/wrap` keeps an inline footnote, `^[…]`, on one
|
|
39
|
+
line, and keeps the lines of a paragraph with one that spans lines. Live
|
|
40
|
+
Preview shows an inline footnote whose text spans lines as Markdown source,
|
|
41
|
+
and the rule broke lines inside it
|
|
42
|
+
([#371](https://github.com/viell-dev/slop-markdown-tools/pull/371)).
|
|
43
|
+
- In the Obsidian dialect, a `%%` comment at the start of a line below a
|
|
44
|
+
paragraph, or one that text follows on the line where it closes, is part of
|
|
45
|
+
the paragraph, as Obsidian reads it. Before, it was read as a block of its
|
|
46
|
+
own, so `style/trailing-space` removed a hard break above it, `style/wrap`
|
|
47
|
+
kept it apart, and no rule saw the text after it. An empty comment, `%%%%`, in
|
|
48
|
+
a paragraph is now a comment too, which Obsidian hides
|
|
49
|
+
([#370](https://github.com/viell-dev/slop-markdown-tools/pull/370)).
|
|
50
|
+
- `obsidian/callout-marker` leaves a marker that Obsidian shows as text, because
|
|
51
|
+
more than one space or a tab separates it from the quote's `>`, as in
|
|
52
|
+
`> [!NOTE]`. Before, it lowercased the visible text
|
|
53
|
+
([#372](https://github.com/viell-dev/slop-markdown-tools/pull/372)).
|
|
54
|
+
- In the Obsidian dialect, `style/emphasis` and `style/strong` keep the markers
|
|
55
|
+
of a paragraph, heading, or table cell whose text holds a `*` or `_` that is
|
|
56
|
+
not a marker, as in `snake_case` or `5 * 3`. Obsidian's Reading view pairs
|
|
57
|
+
such a character with a later one: after `snake_case and *em*` became
|
|
58
|
+
`snake_case and _em_`, Reading view showed `case and _em` as emphasis
|
|
59
|
+
([#368](https://github.com/viell-dev/slop-markdown-tools/pull/368)).
|
|
60
|
+
- `links/path` with `leadingDot` keeps `./` before a name that starts with a
|
|
61
|
+
dot, such as `./.gitignore` or `./.github/`, and adds it there. Before, it
|
|
62
|
+
took such a path for one that already started with `./` and removed the `./`
|
|
63
|
+
([#365](https://github.com/viell-dev/slop-markdown-tools/pull/365)).
|
|
64
|
+
|
|
65
|
+
## 0.2.4 - 2026-10-19
|
|
66
|
+
|
|
67
|
+
### Fixed
|
|
68
|
+
|
|
69
|
+
- In the Forgejo and Gitea dialects, no rule changes a definition description
|
|
70
|
+
any more, a line starting with `: ` below its term, or the blocks indented
|
|
71
|
+
below it. Forgejo and Gitea read the description as blocks, where the parser
|
|
72
|
+
reads text: `style/emphasis` changed code in a fenced block there and the
|
|
73
|
+
anchor of a heading, and the list rules moved a list out of the description
|
|
74
|
+
([#354](https://github.com/viell-dev/slop-markdown-tools/pull/354)).
|
|
75
|
+
|
|
11
76
|
## 0.2.3 - 2026-10-19
|
|
12
77
|
|
|
13
78
|
### Fixed
|
package/CONTRIBUTING.md
CHANGED
|
@@ -127,6 +127,25 @@ repeat a run's new seed, or locally after a build with
|
|
|
127
127
|
`node scripts/github-rendering.mjs`, which needs an authenticated `gh` and takes
|
|
128
128
|
ten to fifteen minutes; its first lines say what it compares.
|
|
129
129
|
|
|
130
|
+
HTML renderers cannot stand in for Obsidian, whose Live Preview editor and
|
|
131
|
+
Reading view read some Markdown otherwise. `npm run check:obsidian` builds the
|
|
132
|
+
repository, runs Obsidian in Docker, formats the documents of
|
|
133
|
+
`scripts/obsidian/fixtures.mjs` and generated documents in the Obsidian dialect,
|
|
134
|
+
and compares what both views show before and after. Docker must be running. The
|
|
135
|
+
image, from `scripts/obsidian/Dockerfile`, holds a virtual display and
|
|
136
|
+
WebdriverIO with `wdio-obsidian-service`, which downloads Obsidian at run time
|
|
137
|
+
into the `mdrefine-obsidian-cache` volume, because Obsidian's terms do not allow
|
|
138
|
+
redistributing it; the check keeps its own dependencies in
|
|
139
|
+
`scripts/obsidian/package.json`. It writes `artifacts/obsidian/report.json`,
|
|
140
|
+
with screenshots of the first differences. `SEED` repeats a run's generated
|
|
141
|
+
documents, `COUNT` sets how many there are (100), and `OBSIDIAN_VERSION` picks
|
|
142
|
+
Obsidian's version (`latest`). `REDUCE`, a comma-separated list of generated
|
|
143
|
+
documents from a report, shortens each to the lines that still show its
|
|
144
|
+
difference, and `PROBE`, a JSON array of documents, only shows each in Obsidian.
|
|
145
|
+
Live Preview is compared by its lines' text and styles, with the characters that
|
|
146
|
+
it shows as written left out where only the source differs, and Reading view by
|
|
147
|
+
its HTML. The check is started by hand and not in CI.
|
|
148
|
+
|
|
130
149
|
`tests/integration/` runs the built CLI as a child process in temporary
|
|
131
150
|
workspaces, and runs `examples/` and `benchmarks/` as they are, without the
|
|
132
151
|
machine's user and system Git settings, which would change what Git ignores. A
|
|
@@ -201,7 +220,8 @@ behavior; harassment and disclosure of private data are not acceptable.
|
|
|
201
220
|
minimal regression example.
|
|
202
221
|
- Update every document, example, and test that describes what you changed, in
|
|
203
222
|
the same pull request, and add the change to the `Unreleased` section of
|
|
204
|
-
[CHANGELOG.md](CHANGELOG.md).
|
|
223
|
+
[CHANGELOG.md](CHANGELOG.md). The first change after a release starts that
|
|
224
|
+
section above the newest version's, because a release renames it.
|
|
205
225
|
- A change to the command line, the configuration, the JSON report, or the
|
|
206
226
|
library that is not a defect fix waits for the next minor release; see the
|
|
207
227
|
[versioning
|
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.5
|
|
63
63
|
npx mdtools lint
|
|
64
64
|
npx mdtools format --diff
|
|
65
65
|
npx mdtools format --write
|
package/dist/core/engine.js
CHANGED
|
@@ -207,15 +207,26 @@ function findingsProblem(findings, length) {
|
|
|
207
207
|
* insert text between two of them. Renderers may read such text as list items
|
|
208
208
|
* or code, and the indentation of the blocks below it otherwise, which the
|
|
209
209
|
* safety check, comparing the parser's readings, cannot see: `_r_` for `*r*`
|
|
210
|
-
* in `- 0. *r*` below a paragraph changes code on GitHub.
|
|
211
|
-
*
|
|
210
|
+
* in `- 0. *r*` below a paragraph changes code on GitHub. The same goes for
|
|
211
|
+
* a definition description on Forgejo and Gitea and the blocks below it, which
|
|
212
|
+
* those renderers read as the description's blocks (issue #344), for a block
|
|
213
|
+
* in Obsidian with a backtick that no run closes, where Obsidian shows code
|
|
214
|
+
* that the parser does not (issue #362), and for the blocks that Obsidian reads
|
|
215
|
+
* as more of an HTML block above them (issue #358). Only the part of the edit
|
|
216
|
+
* that changes the text counts, so that an edit that copies such
|
|
212
217
|
* text, such as a list rule's, can still apply.
|
|
213
218
|
*/
|
|
214
219
|
function misreadEdits(document) {
|
|
215
220
|
const misread = misreadLists(document);
|
|
216
221
|
// The blocks can hold one another; their union, in order, is searched in O(log n).
|
|
217
222
|
const blocks = [];
|
|
218
|
-
for (const [start, end] of Array.from([
|
|
223
|
+
for (const [start, end] of Array.from([
|
|
224
|
+
...misread.text,
|
|
225
|
+
...misread.nested,
|
|
226
|
+
...misread.descriptions,
|
|
227
|
+
...misread.unclosedCode,
|
|
228
|
+
...misread.htmlText,
|
|
229
|
+
], (node) => range(node)).sort((a, b) => a[0] - b[0])) {
|
|
219
230
|
const last = blocks.at(-1);
|
|
220
231
|
if (last && start < last[1])
|
|
221
232
|
last[1] = Math.max(last[1], end);
|
package/dist/core/engine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/core/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,KAAK,EACL,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AACjG,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OA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AE,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;oBAC3E,OAAO,UAAU,CAAC,MAAM,EAAE,sBAAsB,EAAE,OAAO,EAAE;wBACzD,KAAK;wBACL,OAAO,EAAE,GAAG,IAAI,4CAA4C,IAAI,mCAAmC;qBACpG,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;gBACH,OAAO;oBACL,MAAM;oBACN,OAAO,EAAE,MAAM,KAAK,MAAM;oBAC1B,WAAW,EAAE,QAAQ,CAAC,CAAC,GAAG,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC;oBACrF,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC5B,CAAC;YACJ,CAAC;YACD,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;gBAClB,OAAO,SAAS,CACd,iBAAiB,MAAM,CAAC,OAAO,CAAC,+CAA+C,CAChF,CAAC;YACJ,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACnB,CAAC;QACD,OAAO,SAAS,CACd,iBAAiB,MAAM,CAAC,OAAO,CAAC,qEAAqE,CACtG,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;QAC1C,OAAO,SAAS,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC","sourcesContent":["import { Ajv } from \"ajv\";\nimport type { AnySchema, ValidateFunction } from \"ajv\";\nimport { deepFreeze } from \"./frozen.js\";\nimport type { Nodes } from \"mdast\";\nimport { resolveConfig, setting } from \"../config/resolve.js\";\nimport { optionErrors, shown } from \"../config/problems.js\";\nimport {\n codeSpanText,\n otherReading,\n parse,\n range,\n splitByteOrderMark,\n startsWithMarker,\n} from \"../syntax/parse.js\";\nimport { styleRules } from \"../rules/style.js\";\nimport { blockRules } from \"../rules/blocks.js\";\nimport { dialectRules } from \"../rules/dialects.js\";\nimport { structureRules } from \"../rules/structure.js\";\nimport { linkRules } from \"../rules/links.js\";\nimport { contentRules } from \"../rules/content.js\";\nimport { listRules } from \"../rules/lists.js\";\nimport { headingAnchorSource, headingAttributeSource } from \"../workspace/heading-attributes.js\";\nimport { misreadLists } from \"../syntax/misread-lists.js\";\nimport { suppressions } from \"./directives.js\";\nimport { checkRanges, covers, holds, moved, shifted, widen } from \"./scope.js\";\nimport type {\n Diagnostic,\n Document,\n Edit,\n Finding,\n FormatResult,\n JsonSchema,\n Plugin,\n ProcessOptions,\n ResolvedConfig,\n Rule,\n SourceRange,\n Workspace,\n} from \"./types.js\";\n\n/**\n * The built-in rules by rule ID. The table and the rules in it are frozen, so\n * that no caller can change what another one runs.\n */\nexport const builtInRules: Readonly<Record<string, Readonly<Rule>>> = deepFreeze({\n ...styleRules,\n ...blockRules,\n ...dialectRules,\n ...linkRules,\n ...structureRules,\n ...contentRules,\n ...listRules,\n});\nconst phases = [\"inline\", \"block\", \"document\"] as const;\n/** What is wrong with a plugin's rule, or undefined when it has the shape of a `Rule`. */\nfunction ruleProblem(rule: unknown): string | undefined {\n if (!rule || typeof rule !== \"object\") return `it is ${shown(rule)}, not an object`;\n const { check, kind, phase, description, schema } = rule as Record<string, unknown>;\n if (typeof check !== \"function\") return `its check is ${shown(check)}, not a function`;\n if (kind !== \"style\" && kind !== \"problem\")\n return `its kind is ${shown(kind)}, not \"style\" or \"problem\"`;\n if (phase !== undefined && !(phases as readonly unknown[]).includes(phase))\n return `its phase is ${shown(phase)}, not \"inline\", \"block\", or \"document\"`;\n if (typeof description !== \"string\")\n return `its description is ${shown(description)}, not a string`;\n if (\n schema !== undefined &&\n typeof schema !== \"boolean\" &&\n (!schema || typeof schema !== \"object\" || Array.isArray(schema))\n )\n return `its schema is ${shown(schema)}, not a JSON Schema`;\n // Options are checked before each run, synchronously; an asynchronous\n // check would come back after the run, too late to stop it.\n if (schema && typeof schema === \"object\" && (schema as { $async?: unknown }).$async === true)\n return \"its schema is asynchronous ($async), and options are checked synchronously\";\n return undefined;\n}\n/**\n * The prefix of the engine's own diagnostics, such as `engine/rule-error`. A\n * plugin of this name could report findings that pass for the engine's, which\n * concern the whole document and make the CLI exit with code 2.\n */\nexport const reservedPluginName = \"engine\";\n/**\n * The built-in rules and those of `plugins`, by rule ID, in a new table. A\n * plugin name that is invalid, reserved, or used twice, a rule ID that exists\n * already, and a plugin rule that does not have the shape of a `Rule` are\n * errors that name them.\n */\nexport function ruleRegistry(plugins: readonly Plugin[] = []): Record<string, Readonly<Rule>> {\n const rules = { ...builtInRules };\n const names = new Set<string>();\n for (const plugin of plugins) {\n if (plugin.name === reservedPluginName)\n throw new Error(\n `Invalid plugin name: ${reservedPluginName} is reserved for the engine's own diagnostics`,\n );\n if (!/^[a-z][a-z\\d-]*$/.test(plugin.name) || names.has(plugin.name))\n throw new Error(`Invalid or duplicate plugin name: ${plugin.name}`);\n names.add(plugin.name);\n for (const [name, rule] of Object.entries(plugin.rules ?? {})) {\n const id = `${plugin.name}/${name}`;\n if (Object.hasOwn(rules, id)) throw new Error(`Duplicate rule: ${id}`);\n const problem = ruleProblem(rule);\n if (problem) throw new Error(`Invalid rule ${id}: ${problem}.`);\n rules[id] = rule;\n }\n }\n return rules;\n}\n/** Checks the options of built-in rules, whose schemas have no `$id` that could collide. */\nconst ruleValidator = new Ajv({ allErrors: true });\nconst builtInSchemas = new Set(Object.values(builtInRules).map((rule) => rule.schema));\n/**\n * Each option schema compiled once, however many documents use it. A plugin\n * schema gets a validator of its own, because distinct plugins may\n * legitimately reuse an `$id` with different schemas.\n */\nconst compiledSchemas = new WeakMap<object, ValidateFunction>();\nfunction optionsValidator(name: string, schema: JsonSchema): ValidateFunction {\n // Ajv keeps compiled boolean schemas itself.\n if (typeof schema !== \"object\") return ruleValidator.compile(schema);\n let validate = compiledSchemas.get(schema);\n if (!validate) {\n try {\n validate = (\n builtInSchemas.has(schema) ? ruleValidator : new Ajv({ allErrors: true })\n ).compile(schema as AnySchema);\n } catch (error) {\n throw new Error(\n `Invalid rule ${name}: its schema cannot be compiled: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n // A schema can become asynchronous through one that it refers to.\n if ((validate as { $async?: unknown }).$async === true)\n throw new Error(\n `Invalid rule ${name}: its schema is asynchronous ($async), and options are checked synchronously`,\n );\n compiledSchemas.set(schema, validate);\n }\n return validate;\n}\nfunction prepare(options: ProcessOptions) {\n // Only these options, so that resolveConfig's check for the prereleases' form sees no others.\n const { config: given, path, plugins, defaultDialect } = options;\n const config = resolveConfig({ config: given, path, plugins, defaultDialect });\n const rules = ruleRegistry(options.plugins);\n for (const [name, value] of Object.entries(config.rules)) {\n // Names such as `toString` are found on every object; only defined rules count.\n if (!Object.hasOwn(rules, name)) throw new Error(`Unknown rule: ${name}`);\n const rule = rules[name]!;\n const enabled = setting(value);\n // A schema of `false` means that the rule takes no options. A setting that\n // gives none is checked as empty options, which `false` would refuse too.\n if (rule.schema === false && enabled.severity !== \"off\") {\n if (Object.keys(enabled.options).length)\n throw new Error(`Invalid options for ${name}: the rule takes no options`);\n } else if (rule.schema !== undefined && enabled.severity !== \"off\") {\n const validate = optionsValidator(name, rule.schema);\n if (!validate(enabled.options))\n throw new Error(\n `Invalid options for ${name}: ${optionErrors(validate.errors ?? [], enabled.options)}`,\n );\n }\n }\n return { config, rules };\n}\n/** CommonMark's line endings. */\nconst lineBreaks = /\\r\\n|\\r|\\n/g;\n/** Offsets where each line starts, computed once per source so findings locate in O(log lines). */\nfunction lineStarts(source: string): number[] {\n const starts = [0];\n for (const match of source.matchAll(lineBreaks)) starts.push(match.index + match[0].length);\n return starts;\n}\nfunction diagnostic(\n starts: number[],\n rule: string,\n severity: \"warn\" | \"error\",\n finding: Finding,\n): Diagnostic {\n let low = 0;\n let high = starts.length - 1;\n while (low < high) {\n const middle = (low + high + 1) >> 1;\n if (starts[middle]! <= finding.start) low = middle;\n else high = middle - 1;\n }\n return { ...finding, rule, severity, line: low + 1, column: finding.start - starts[low]! + 1 };\n}\nconst sortDiagnostics = (a: Diagnostic, b: Diagnostic) =>\n a.start - b.start || a.rule.localeCompare(b.rule);\n/** Diagnostics of the engine itself; they concern the whole document. */\nconst fromEngine = (item: Diagnostic) => item.rule.startsWith(\"engine/\");\n/** Why `value` is not an offset from `from` to `to`, or undefined when it is one. */\nfunction offsetProblem(what: string, value: unknown, from: number, to: number) {\n return Number.isInteger(value) && (value as number) >= from && (value as number) <= to\n ? undefined\n : `${what} is ${shown(value)}, not an offset from ${from} to ${to}`;\n}\n/**\n * What is wrong with the findings that a rule returned for a source of\n * `length` UTF-16 units, as the rest of a sentence about the rule, or\n * undefined when every finding can be reported and every edit applied.\n */\nfunction findingsProblem(findings: unknown, length: number): string | undefined {\n if (!Array.isArray(findings)) return `returned ${shown(findings)} instead of a list of findings`;\n for (const finding of findings as unknown[]) {\n if (!finding || typeof finding !== \"object\")\n return `returned a finding that is ${shown(finding)}, not an object`;\n const { message, start, end, edit } = finding as Record<string, unknown>;\n const problem =\n (typeof message === \"string\"\n ? undefined\n : `whose message is ${shown(message)}, not a string`) ??\n offsetProblem(\"whose start\", start, 0, length) ??\n (end === undefined ? undefined : offsetProblem(\"whose end\", end, start as number, length)) ??\n (edit === undefined || (edit && typeof edit === \"object\")\n ? undefined\n : `whose edit is ${shown(edit)}, not an object`);\n if (problem) return `returned a finding ${problem}`;\n if (edit === undefined) continue;\n const { start: from, end: to, text } = edit as Record<string, unknown>;\n const invalid =\n offsetProblem(\"whose start\", from, 0, length) ??\n offsetProblem(\"whose end\", to, from as number, length) ??\n (typeof text === \"string\" ? undefined : `whose text is ${shown(text)}, not a string`);\n if (invalid) return `returned an edit ${invalid}`;\n }\n return undefined;\n}\n/**\n * Whether an edit would change text that the parser read where renderers may\n * read a list, or a block indented below it, which renderers may read inside\n * that list (`misreadLists`, issue #191): replace some of their characters, or\n * insert text between two of them. Renderers may read such text as list items\n * or code, and the indentation of the blocks below it otherwise, which the\n * safety check, comparing the parser's readings, cannot see: `_r_` for `*r*`\n * in `- 0. *r*` below a paragraph changes code on GitHub. Only the part of\n * the edit that changes the text counts, so that an edit that copies such\n * text, such as a list rule's, can still apply.\n */\nfunction misreadEdits(document: Document): (edit: Edit) => boolean {\n const misread = misreadLists(document);\n // The blocks can hold one another; their union, in order, is searched in O(log n).\n const blocks: [number, number][] = [];\n for (const [start, end] of Array.from([...misread.text, ...misread.nested], (node) =>\n range(node),\n ).sort((a, b) => a[0] - b[0])) {\n const last = blocks.at(-1);\n if (last && start < last[1]) last[1] = Math.max(last[1], end);\n else blocks.push([start, end]);\n }\n if (!blocks.length) return () => false;\n const { source } = document;\n const within = (from: number, to: number) => {\n let low = 0;\n let high = blocks.length;\n while (low < high) {\n const middle = (low + high) >> 1;\n if (blocks[middle]![1] <= from) low = middle + 1;\n else high = middle;\n }\n const block = blocks[low];\n return block !== undefined && from < block[1] && to > block[0];\n };\n return (edit) => {\n if (!within(edit.start, edit.end)) return false;\n const before = source.slice(edit.start, edit.end);\n const { text } = edit;\n if (before === text) return false;\n const shorter = Math.min(before.length, text.length);\n let prefix = 0;\n while (prefix < shorter && before[prefix] === text[prefix]) prefix++;\n let suffix = 0;\n while (suffix < shorter - prefix && before.at(-1 - suffix) === text.at(-1 - suffix)) suffix++;\n return within(edit.start + prefix, edit.end - suffix);\n };\n}\n/**\n * The workspace of a run as the engine and its rules use it, and the errors\n * that it threw. Such an error is the host's, such as a file that could not be\n * read, and neither a rule's nor a refusal to format: it stops the run.\n */\ninterface Host {\n workspace?: Workspace;\n errors: Set<unknown>;\n}\nfunction host(workspace: Workspace | undefined): Host {\n const errors = new Set<unknown>();\n return workspace ? { workspace: guarded(workspace, errors), errors } : { errors };\n}\n/**\n * `workspace` as rules see it. What its `resolve` throws is added to `errors`:\n * such an error is the host's, such as a file that could not be read, and not\n * the rule's. Rules still see it as it was thrown.\n */\nfunction guarded(workspace: Workspace, errors: Set<unknown>): Workspace {\n const resolve: Workspace[\"resolve\"] = (...query) => {\n try {\n return workspace.resolve(...query);\n } catch (error) {\n errors.add(error);\n throw error;\n }\n };\n // Other members, such as a host's own, reach the workspace itself.\n return new Proxy(workspace, {\n get(target, key) {\n if (key === \"resolve\") return resolve;\n const value: unknown = Reflect.get(target, key);\n return typeof value === \"function\" ? (value as () => unknown).bind(target) : value;\n },\n });\n}\n/** A thrown value as text, without letting it throw again. */\nfunction failure(error: unknown): string {\n try {\n return error instanceof Error ? `${error.name}: ${error.message}` : String(error);\n } catch {\n return \"a value that cannot be shown\";\n }\n}\n/**\n * The diagnostics of the enabled rules that `include` selects. A rule that\n * throws, or returns something that is not a list of valid findings, is\n * skipped for the document and reported as `engine/rule-error` instead. An\n * error of the workspace itself, such as a file that could not be read, is\n * not the rule's and is thrown on. Suppressed findings are left out, and so\n * are findings whose edits would change text that the parser read in place of\n * a list, or the blocks that renderers read inside that list: the finding\n * describes what the parser read, and following it by hand would make the\n * change too.\n */\nfunction inspect(\n document: Document,\n config: ResolvedConfig,\n rules: Record<string, Rule>,\n { workspace, errors: hostErrors }: Host,\n include: (rule: Rule) => boolean = () => true,\n): Diagnostic[] {\n const result: Diagnostic[] = [];\n const suppressed = suppressions(document);\n const misread = misreadEdits(document);\n const starts = lineStarts(document.source);\n for (const [name, value] of Object.entries(config.rules)) {\n const enabled = setting(value);\n const rule = rules[name]!;\n if (enabled.severity === \"off\" || !include(rule)) continue;\n let findings: Finding[] = [];\n let problem: string | undefined;\n try {\n const returned: unknown = rule.check({\n document,\n options: enabled.options,\n ...(workspace ? { workspace } : {}),\n });\n problem = findingsProblem(returned, document.source.length);\n if (!problem) findings = returned as Finding[];\n } catch (error) {\n if (hostErrors.has(error)) throw error;\n problem = `failed (${failure(error)})`;\n }\n if (problem) {\n result.push(\n diagnostic([0], \"engine/rule-error\", \"error\", {\n start: 0,\n message: `Rule ${name} ${problem}; the rule was skipped for this document.`,\n }),\n );\n continue;\n }\n for (const finding of findings)\n if (!suppressed(name, finding) && !(finding.edit && misread(finding.edit)))\n result.push(diagnostic(starts, name, enabled.severity, finding));\n }\n return result.sort(sortDiagnostics);\n}\n/**\n * Locate diagnostics of a document that `parse` read without the byte order\n * marks it starts with in the text as given, so that their edits apply to that\n * text. Lines and columns stay as they are: the marks are invisible.\n */\nfunction located(diagnostics: Diagnostic[], mark: string): Diagnostic[] {\n if (!mark) return diagnostics;\n const by = mark.length;\n return diagnostics.map((item) => ({\n ...item,\n start: item.start + by,\n ...(item.end !== undefined ? { end: item.end + by } : {}),\n ...(item.edit\n ? { edit: { ...item.edit, start: item.edit.start + by, end: item.edit.end + by } }\n : {}),\n }));\n}\n/**\n * The diagnostics of the enabled rules for `source`, sorted by position. A rule\n * that fails is skipped and reported as `engine/rule-error`. An invalid\n * configuration, an unknown rule, invalid rule options, an invalid plugin, and\n * an error that the workspace throws are thrown.\n */\nexport function lint(source: string, options: ProcessOptions = {}): Diagnostic[] {\n if (options.ranges) checkRanges(options.ranges, source);\n const { config, rules } = prepare(options);\n const [mark, text] = splitByteOrderMark(source);\n const document = parse(text, config.dialect, options.path, options.plugins);\n const diagnostics = inspect(document, config, rules, host(options.workspace));\n // Ranges count the marks, and the document's positions do not.\n const scope =\n options.ranges && widen(document.tree, document.source, shifted(options.ranges, -mark.length));\n return located(\n scope\n ? diagnostics.filter((item) => fromEngine(item) || covers(scope, item.start))\n : diagnostics,\n mark,\n );\n}\n/**\n * `source` with `edits` applied, which are `{ start, end, text }` replacements\n * at UTF-16 offsets into it. Repeats of one edit count once; an edit outside\n * the source, or one that overlaps another, is an error.\n */\nexport function applyEdits(source: string, edits: readonly Edit[]): string {\n return splice(source, acceptedEdits(source, edits));\n}\n/** `source` with `edits`, which are sorted and do not overlap, applied. */\nfunction splice(source: string, edits: readonly Edit[]): string {\n // Assemble the result in one pass; rebuilding the string per edit is quadratic.\n const parts: string[] = [];\n let cursor = 0;\n for (const edit of edits) {\n parts.push(source.slice(cursor, edit.start), edit.text);\n cursor = edit.end;\n }\n parts.push(source.slice(cursor));\n return parts.join(\"\");\n}\n/**\n * The edits that `applyEdits` applies, sorted by position and without repeats\n * of the same edit. An edit outside the source, or overlapping another one, is\n * an error.\n */\nfunction acceptedEdits(source: string, edits: readonly Edit[]): Edit[] {\n const sorted = [...edits].sort((a, b) => a.start - b.start || a.end - b.end);\n let previous: Edit | undefined;\n const accepted: Edit[] = [];\n for (const edit of sorted) {\n if (\n !Number.isInteger(edit.start) ||\n !Number.isInteger(edit.end) ||\n edit.start < 0 ||\n edit.end < edit.start ||\n edit.end > source.length\n )\n throw new Error(\"Rule returned an invalid edit range.\");\n if (\n previous &&\n edit.start === previous.start &&\n edit.end === previous.end &&\n edit.text === previous.text\n )\n continue;\n if (previous && (edit.start < previous.end || edit.start === previous.start))\n throw new Error(\n \"Enabled rules proposed overlapping edits; disable one of the conflicting rules.\",\n );\n accepted.push(edit);\n previous = edit;\n }\n return accepted;\n}\n/**\n * The meaning of a parsed document as text, which `format` compares before and\n * after edits to refuse a change of meaning: its syntax tree without positions,\n * with runs of whitespace in text alike, and with each link's destination as\n * the workspace resolves it, so that two spellings of one target are the same.\n */\nexport function semanticFingerprint(document: Document, workspace?: Workspace): string {\n return JSON.stringify(semanticTree(document, workspace));\n}\n/**\n * The document's meaning as plain data whose keys are in sorted order. With\n * `origins`, each object of the result that stands for a node of the document\n * is mapped to that node.\n */\nfunction semanticTree(\n document: Document,\n workspace?: Workspace,\n origins?: Map<unknown, Nodes>,\n): unknown {\n const canonicalUrl = (url: string, wiki = false) => {\n const resolution = workspace?.resolve(document.path, url, document.dialect, wiki);\n // A target that is uncertain, because a directory could not be read, is not\n // an identity: only the same spelling is known to name the same note.\n return resolution?.status === \"resolved\" && !resolution.unreadable\n ? `${resolution.target}#${resolution.fragment ?? \"\"}`\n : url;\n };\n // Keys are emitted in sorted order so the JSON text is canonical without a replacer.\n function normalize(node: Nodes, calloutHeader = false): unknown {\n if (node.type === \"wikiLink\") {\n const link = node.embed\n ? { label: node.label, type: \"embed\", url: canonicalUrl(node.target, true) }\n : {\n children: [{ type: \"text\", value: node.label ?? node.target }],\n title: null,\n type: \"link\",\n url: canonicalUrl(node.target, true),\n };\n origins?.set(link, node);\n return link;\n }\n const result: Record<string, unknown> = {};\n // Forgejo and Gitea read a heading's trailing `{...}` block as attributes,\n // character for character, where the tree holds ordinary inline content,\n // and generate the anchor from the heading's last line as written.\n if (node.type === \"heading\") {\n const attributes = headingAttributeSource(document, node);\n if (attributes !== undefined) result.attributes = attributes;\n const anchors = headingAnchorSource(document, node);\n if (anchors !== undefined) result.anchors = anchors;\n }\n if (calloutHeader && document.dialect !== \"commonmark\" && node.type === \"paragraph\") {\n const [start, end] = range(node);\n const header = document.source.slice(start, end).split(/\\r\\n|\\r|\\n/, 1)[0]!;\n if (startsWithMarker(header, node)) {\n // CommonMark merges an Obsidian callout's title, or the line of a\n // GitHub alert's marker, and the body into one paragraph. Preserve\n // their boundary too, also for a marker written as `\\[!NOTE]`.\n const title = header.replace(\n /^\\[!([\\w-]+)\\]/,\n (_, marker: string) => `[!${marker.toLowerCase()}]`,\n );\n result.calloutTitle = normalize(parse(title, document.dialect, document.path).tree);\n }\n }\n for (const key of Object.keys(node).sort()) {\n const value = (node as unknown as Record<string, unknown>)[key];\n if (key === \"position\" || key === \"data\") continue;\n if (key === \"children\" && \"children\" in node) {\n result.children = node.children.map((child, index) =>\n normalize(child, index === 0 && (node.type === \"blockquote\" || calloutHeader)),\n );\n } else if (key === \"url\" && typeof value === \"string\") result[key] = canonicalUrl(value);\n else if (key === \"value\" && node.type === \"text\") {\n let text = node.value.replace(/[ \\t\\r\\n]+/g, \" \");\n if (calloutHeader && document.dialect !== \"commonmark\")\n text = text.replace(\n /^\\[!([\\w-]+)\\]/,\n (_, marker: string) => `[!${marker.toLowerCase()}]`,\n );\n result[key] = text;\n } else if (key === \"value\" && node.type === \"inlineCode\")\n // A code span is compared by the text that GitHub shows, which its\n // value in the tree does not hold where it spans lines.\n result[key] = codeSpanText(node);\n // An image's description renders as plain text, and a reference's label\n // matches its definition with whitespace collapsed.\n else if ((key === \"alt\" || key === \"label\") && typeof value === \"string\")\n result[key] = value.replace(/[ \\t\\r\\n]+/g, \" \");\n else result[key] = value;\n }\n origins?.set(result, node);\n return result;\n }\n const result = normalize(document.tree) as Record<string, unknown>;\n // Where front matter would end inside a code block, an HTML block, or\n // display math, the document is read without it, and renderers read TOML\n // front matter as a paragraph. An edit has to keep the meaning of both\n // readings.\n const reading = otherReading(document.tree);\n if (reading) result.otherReading = normalize(reading);\n return result;\n}\n/** A part of a semantic tree that has children. */\ntype Branch = Record<string, unknown> & { children: unknown[] };\nconst isBranch = (value: unknown): value is Branch =>\n typeof value === \"object\" && value !== null && Array.isArray((value as Branch).children);\n/**\n * Where the meaning of `after` first differs from that of `before`, as an\n * offset into `before`'s source: the start of the first node, in document\n * order, whose meaning is not the same, or the end of the node that `after`\n * gives more content.\n */\nfunction divergence(before: Document, after: Document, workspace?: Workspace): number {\n const origins = new Map<unknown, Nodes>();\n let a = semanticTree(before, workspace, origins);\n let b = semanticTree(after, workspace);\n // Where only the other reading differs, the place is in that reading, and\n // otherwise in the document's own.\n const reading = (value: unknown) => (value as { otherReading?: unknown }).otherReading;\n if (\n isBranch(a) &&\n isBranch(b) &&\n isBranch(reading(a)) &&\n isBranch(reading(b)) &&\n JSON.stringify(a.children) === JSON.stringify(b.children)\n ) {\n a = reading(a);\n b = reading(b);\n }\n let offset = 0;\n for (;;) {\n const node = origins.get(a);\n // A node made up for the comparison, or one without a position, is placed at its parent.\n offset = node?.position?.start.offset ?? offset;\n if (!isBranch(a) || !isBranch(b)) return offset;\n const own = (value: Branch) =>\n JSON.stringify({ ...value, children: undefined, otherReading: undefined });\n if (own(a) !== own(b)) return offset;\n const { children } = b;\n const index = a.children.findIndex(\n (child, at) => JSON.stringify(child) !== JSON.stringify(children[at]),\n );\n if (index < 0) return node?.position?.end.offset ?? offset;\n a = a.children[index];\n b = children[index];\n }\n}\n/**\n * Format a document: apply the edits of the enabled style rules, in passes\n * until nothing changes, leaving out the edits of a rule that would change the\n * document's meaning. Byte order marks that it starts with stay in the output\n * and are not part of what the rules see. Errors are thrown as by `lint`.\n */\nexport function format(source: string, options: ProcessOptions = {}): FormatResult {\n if (options.ranges) checkRanges(options.ranges, source);\n const [mark, text] = splitByteOrderMark(source);\n // Ranges count the marks, and the document's positions do not.\n const result = formatText(text, options, options.ranges && shifted(options.ranges, -mark.length));\n return {\n output: mark + result.output,\n changed: result.changed,\n diagnostics: located(result.diagnostics, mark),\n ...(result.scope ? { scope: shifted(result.scope, mark.length) } : {}),\n };\n}\n/** An edit that a rule proposed, with the rule's ID. */\ninterface Proposal extends Edit {\n rule: string;\n}\nconst byPosition = (a: Edit, b: Edit) => a.start - b.start || a.end - b.end;\n/**\n * The proposals to apply together, in the order of the source. An edit that\n * overlaps one before it, or repeats it, is left out; the next pass, which\n * runs the rules again on the changed text, reconsiders it.\n */\nfunction compatible(proposals: readonly Proposal[]): Proposal[] {\n const result: Proposal[] = [];\n let previous: Proposal | undefined;\n for (const edit of [...proposals].sort(byPosition)) {\n if (previous && (edit.start < previous.end || edit.start === previous.start)) continue;\n result.push(edit);\n previous = edit;\n }\n return result;\n}\n/** Rule IDs as a list in prose. */\nfunction listed(names: Iterable<string>): string {\n const items = [...names];\n return items.length < 3\n ? items.join(\" and \")\n : `${items.slice(0, -1).join(\", \")}, and ${items.at(-1)}`;\n}\n/**\n * Format a document without byte order marks, limited to `ranges` in its\n * positions. Each phase applies the edits of its rules together when the\n * result means what the original document means. Otherwise it adds the rules'\n * edits one rule at a time and leaves out the edits of each rule that would\n * change the meaning; the result reports each such rule with the place where\n * the meaning would first differ. Passes repeat until one changes nothing;\n * formatting that does not settle leaves the whole document unchanged.\n */\nfunction formatText(\n source: string,\n options: ProcessOptions,\n ranges: SourceRange[] | undefined,\n): FormatResult {\n const { config, rules } = prepare(options);\n // What the workspace throws stops formatting, as it stops `lint`.\n const hosted = host(options.workspace);\n const { workspace } = hosted;\n let output = source;\n let document = parse(source, config.dialect, options.path, options.plugins);\n // Where edits may apply, in the positions of the current output.\n const initial = ranges && widen(document.tree, source, ranges);\n let scope = initial;\n // Engine findings concern the whole document and are always reported.\n const reported = (items: Diagnostic[]) =>\n scope ? items.filter((item) => fromEngine(item) || covers(scope!, item.start)) : items;\n const unchanged = (message: string): FormatResult => ({\n output: source,\n changed: false,\n diagnostics: [diagnostic([0], \"engine/unsafe-format\", \"error\", { start: 0, message })],\n ...(initial ? { scope: initial } : {}),\n });\n // The original fingerprint is only needed once an edit produces a candidate.\n let fingerprint: string | undefined;\n /** `candidate` parsed, and whether it means what the original document means. */\n const check = (candidate: string) => {\n const parsed = parse(candidate, config.dialect, options.path, options.plugins);\n // Every document accepted so far means what the original means, so the current one serves.\n fingerprint ??= semanticFingerprint(document, workspace);\n return {\n document: parsed,\n safe: semanticFingerprint(parsed, workspace) === fingerprint,\n };\n };\n const seen = new Set([source]);\n /** The rules whose edits changed the document in the latest pass. */\n let applied = new Set<string>();\n try {\n for (let pass = 0; pass < 8; pass++) {\n const before = output;\n const findings: Diagnostic[] = [];\n applied = new Set();\n /** The rules whose edits this pass left out, with the document before and after them. */\n const refused: { rule: string; before: Document; after: Document }[] = [];\n const accept = (edits: Proposal[], text: string, parsed: Document) => {\n output = text;\n // Rules consume the document without mutating it. Reuse the validated\n // tree until another phase changes its source, including final diagnostics.\n document = parsed;\n if (scope) scope = moved(scope, edits);\n for (const edit of edits) applied.add(edit.rule);\n };\n for (const phase of phases) {\n const diagnostics = inspect(\n document,\n config,\n rules,\n hosted,\n (rule) => rule.kind === \"style\" && (rule.phase ?? \"inline\") === phase,\n );\n findings.push(...diagnostics);\n // With ranges, an edit that reaches outside them is not applied. One\n // that changes nothing need not be tried, and must not hold others back.\n const proposals: Proposal[] = [];\n for (const { edit, rule } of diagnostics)\n if (\n edit &&\n (!scope || holds(scope, edit)) &&\n output.slice(edit.start, edit.end) !== edit.text\n )\n proposals.push({ start: edit.start, end: edit.end, text: edit.text, rule });\n // The rules of this phase whose edits would change the meaning.\n const excluded = new Set<string>();\n for (;;) {\n const edits = compatible(proposals.filter((edit) => !excluded.has(edit.rule)));\n if (!edits.length) break;\n const candidate = splice(output, edits);\n if (candidate === output) break;\n const tried = check(candidate);\n if (tried.safe) {\n accept(edits, candidate, tried.document);\n break;\n }\n // Taken only when a phase fails, so the usual path parses each candidate once.\n let kept: Proposal[] = [];\n let keptOutput = output;\n let keptDocument = document;\n for (const rule of new Set(edits.map((edit) => edit.rule))) {\n const trial = [...kept, ...edits.filter((edit) => edit.rule === rule)].sort(byPosition);\n // All the edits together are already known to fail.\n const whole = trial.length === edits.length;\n const text = whole ? candidate : splice(output, trial);\n const result = whole ? tried : check(text);\n if (result.safe) {\n kept = trial;\n keptOutput = text;\n keptDocument = result.document;\n } else {\n excluded.add(rule);\n refused.push({ rule, before: document, after: result.document });\n }\n }\n if (keptOutput !== output) {\n accept(kept, keptOutput, keptDocument);\n break;\n }\n // Nothing was kept: the edits that overlapped refused ones get their turn.\n }\n }\n if (output === before) {\n // No phase changed the document, so every style finding of this pass\n // describes the final document; only the non-style rules still need to run.\n const remaining = inspect(document, config, rules, hosted, (rule) => rule.kind !== \"style\");\n // A refusal of this pass was tried on the final text, unless one\n // phase undid what an earlier one did.\n const starts = refused.length ? lineStarts(output) : [];\n const refusals = refused.map(({ rule, before: tried, after }) => {\n const start = tried.source === output ? divergence(tried, after, workspace) : 0;\n const { line } = diagnostic(starts, rule, \"error\", { start, message: \"\" });\n return diagnostic(starts, \"engine/unsafe-format\", \"error\", {\n start,\n message: `${rule} would change the parsed meaning at line ${line}; none of its edits were applied.`,\n });\n });\n return {\n output,\n changed: output !== source,\n diagnostics: reported([...findings, ...remaining, ...refusals]).sort(sortDiagnostics),\n ...(scope ? { scope } : {}),\n };\n }\n if (seen.has(output))\n return unchanged(\n `Formatting by ${listed(applied)} oscillates; the document was left unchanged.`,\n );\n seen.add(output);\n }\n return unchanged(\n `Formatting by ${listed(applied)} did not converge in eight passes; the document was left unchanged.`,\n );\n } catch (error) {\n if (hosted.errors.has(error)) throw error;\n return unchanged(error instanceof Error ? error.message : String(error));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/core/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,KAAK,EACL,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AACjG,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,E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;IAC3E,CAAC;AACH,CAAC","sourcesContent":["import { Ajv } from \"ajv\";\nimport type { AnySchema, ValidateFunction } from \"ajv\";\nimport { deepFreeze } from \"./frozen.js\";\nimport type { Nodes } from \"mdast\";\nimport { resolveConfig, setting } from \"../config/resolve.js\";\nimport { optionErrors, shown } from \"../config/problems.js\";\nimport {\n codeSpanText,\n otherReading,\n parse,\n range,\n splitByteOrderMark,\n startsWithMarker,\n} from \"../syntax/parse.js\";\nimport { styleRules } from \"../rules/style.js\";\nimport { blockRules } from \"../rules/blocks.js\";\nimport { dialectRules } from \"../rules/dialects.js\";\nimport { structureRules } from \"../rules/structure.js\";\nimport { linkRules } from \"../rules/links.js\";\nimport { contentRules } from \"../rules/content.js\";\nimport { listRules } from \"../rules/lists.js\";\nimport { headingAnchorSource, headingAttributeSource } from \"../workspace/heading-attributes.js\";\nimport { misreadLists } from \"../syntax/misread-lists.js\";\nimport { suppressions } from \"./directives.js\";\nimport { checkRanges, covers, holds, moved, shifted, widen } from \"./scope.js\";\nimport type {\n Diagnostic,\n Document,\n Edit,\n Finding,\n FormatResult,\n JsonSchema,\n Plugin,\n ProcessOptions,\n ResolvedConfig,\n Rule,\n SourceRange,\n Workspace,\n} from \"./types.js\";\n\n/**\n * The built-in rules by rule ID. The table and the rules in it are frozen, so\n * that no caller can change what another one runs.\n */\nexport const builtInRules: Readonly<Record<string, Readonly<Rule>>> = deepFreeze({\n ...styleRules,\n ...blockRules,\n ...dialectRules,\n ...linkRules,\n ...structureRules,\n ...contentRules,\n ...listRules,\n});\nconst phases = [\"inline\", \"block\", \"document\"] as const;\n/** What is wrong with a plugin's rule, or undefined when it has the shape of a `Rule`. */\nfunction ruleProblem(rule: unknown): string | undefined {\n if (!rule || typeof rule !== \"object\") return `it is ${shown(rule)}, not an object`;\n const { check, kind, phase, description, schema } = rule as Record<string, unknown>;\n if (typeof check !== \"function\") return `its check is ${shown(check)}, not a function`;\n if (kind !== \"style\" && kind !== \"problem\")\n return `its kind is ${shown(kind)}, not \"style\" or \"problem\"`;\n if (phase !== undefined && !(phases as readonly unknown[]).includes(phase))\n return `its phase is ${shown(phase)}, not \"inline\", \"block\", or \"document\"`;\n if (typeof description !== \"string\")\n return `its description is ${shown(description)}, not a string`;\n if (\n schema !== undefined &&\n typeof schema !== \"boolean\" &&\n (!schema || typeof schema !== \"object\" || Array.isArray(schema))\n )\n return `its schema is ${shown(schema)}, not a JSON Schema`;\n // Options are checked before each run, synchronously; an asynchronous\n // check would come back after the run, too late to stop it.\n if (schema && typeof schema === \"object\" && (schema as { $async?: unknown }).$async === true)\n return \"its schema is asynchronous ($async), and options are checked synchronously\";\n return undefined;\n}\n/**\n * The prefix of the engine's own diagnostics, such as `engine/rule-error`. A\n * plugin of this name could report findings that pass for the engine's, which\n * concern the whole document and make the CLI exit with code 2.\n */\nexport const reservedPluginName = \"engine\";\n/**\n * The built-in rules and those of `plugins`, by rule ID, in a new table. A\n * plugin name that is invalid, reserved, or used twice, a rule ID that exists\n * already, and a plugin rule that does not have the shape of a `Rule` are\n * errors that name them.\n */\nexport function ruleRegistry(plugins: readonly Plugin[] = []): Record<string, Readonly<Rule>> {\n const rules = { ...builtInRules };\n const names = new Set<string>();\n for (const plugin of plugins) {\n if (plugin.name === reservedPluginName)\n throw new Error(\n `Invalid plugin name: ${reservedPluginName} is reserved for the engine's own diagnostics`,\n );\n if (!/^[a-z][a-z\\d-]*$/.test(plugin.name) || names.has(plugin.name))\n throw new Error(`Invalid or duplicate plugin name: ${plugin.name}`);\n names.add(plugin.name);\n for (const [name, rule] of Object.entries(plugin.rules ?? {})) {\n const id = `${plugin.name}/${name}`;\n if (Object.hasOwn(rules, id)) throw new Error(`Duplicate rule: ${id}`);\n const problem = ruleProblem(rule);\n if (problem) throw new Error(`Invalid rule ${id}: ${problem}.`);\n rules[id] = rule;\n }\n }\n return rules;\n}\n/** Checks the options of built-in rules, whose schemas have no `$id` that could collide. */\nconst ruleValidator = new Ajv({ allErrors: true });\nconst builtInSchemas = new Set(Object.values(builtInRules).map((rule) => rule.schema));\n/**\n * Each option schema compiled once, however many documents use it. A plugin\n * schema gets a validator of its own, because distinct plugins may\n * legitimately reuse an `$id` with different schemas.\n */\nconst compiledSchemas = new WeakMap<object, ValidateFunction>();\nfunction optionsValidator(name: string, schema: JsonSchema): ValidateFunction {\n // Ajv keeps compiled boolean schemas itself.\n if (typeof schema !== \"object\") return ruleValidator.compile(schema);\n let validate = compiledSchemas.get(schema);\n if (!validate) {\n try {\n validate = (\n builtInSchemas.has(schema) ? ruleValidator : new Ajv({ allErrors: true })\n ).compile(schema as AnySchema);\n } catch (error) {\n throw new Error(\n `Invalid rule ${name}: its schema cannot be compiled: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n // A schema can become asynchronous through one that it refers to.\n if ((validate as { $async?: unknown }).$async === true)\n throw new Error(\n `Invalid rule ${name}: its schema is asynchronous ($async), and options are checked synchronously`,\n );\n compiledSchemas.set(schema, validate);\n }\n return validate;\n}\nfunction prepare(options: ProcessOptions) {\n // Only these options, so that resolveConfig's check for the prereleases' form sees no others.\n const { config: given, path, plugins, defaultDialect } = options;\n const config = resolveConfig({ config: given, path, plugins, defaultDialect });\n const rules = ruleRegistry(options.plugins);\n for (const [name, value] of Object.entries(config.rules)) {\n // Names such as `toString` are found on every object; only defined rules count.\n if (!Object.hasOwn(rules, name)) throw new Error(`Unknown rule: ${name}`);\n const rule = rules[name]!;\n const enabled = setting(value);\n // A schema of `false` means that the rule takes no options. A setting that\n // gives none is checked as empty options, which `false` would refuse too.\n if (rule.schema === false && enabled.severity !== \"off\") {\n if (Object.keys(enabled.options).length)\n throw new Error(`Invalid options for ${name}: the rule takes no options`);\n } else if (rule.schema !== undefined && enabled.severity !== \"off\") {\n const validate = optionsValidator(name, rule.schema);\n if (!validate(enabled.options))\n throw new Error(\n `Invalid options for ${name}: ${optionErrors(validate.errors ?? [], enabled.options)}`,\n );\n }\n }\n return { config, rules };\n}\n/** CommonMark's line endings. */\nconst lineBreaks = /\\r\\n|\\r|\\n/g;\n/** Offsets where each line starts, computed once per source so findings locate in O(log lines). */\nfunction lineStarts(source: string): number[] {\n const starts = [0];\n for (const match of source.matchAll(lineBreaks)) starts.push(match.index + match[0].length);\n return starts;\n}\nfunction diagnostic(\n starts: number[],\n rule: string,\n severity: \"warn\" | \"error\",\n finding: Finding,\n): Diagnostic {\n let low = 0;\n let high = starts.length - 1;\n while (low < high) {\n const middle = (low + high + 1) >> 1;\n if (starts[middle]! <= finding.start) low = middle;\n else high = middle - 1;\n }\n return { ...finding, rule, severity, line: low + 1, column: finding.start - starts[low]! + 1 };\n}\nconst sortDiagnostics = (a: Diagnostic, b: Diagnostic) =>\n a.start - b.start || a.rule.localeCompare(b.rule);\n/** Diagnostics of the engine itself; they concern the whole document. */\nconst fromEngine = (item: Diagnostic) => item.rule.startsWith(\"engine/\");\n/** Why `value` is not an offset from `from` to `to`, or undefined when it is one. */\nfunction offsetProblem(what: string, value: unknown, from: number, to: number) {\n return Number.isInteger(value) && (value as number) >= from && (value as number) <= to\n ? undefined\n : `${what} is ${shown(value)}, not an offset from ${from} to ${to}`;\n}\n/**\n * What is wrong with the findings that a rule returned for a source of\n * `length` UTF-16 units, as the rest of a sentence about the rule, or\n * undefined when every finding can be reported and every edit applied.\n */\nfunction findingsProblem(findings: unknown, length: number): string | undefined {\n if (!Array.isArray(findings)) return `returned ${shown(findings)} instead of a list of findings`;\n for (const finding of findings as unknown[]) {\n if (!finding || typeof finding !== \"object\")\n return `returned a finding that is ${shown(finding)}, not an object`;\n const { message, start, end, edit } = finding as Record<string, unknown>;\n const problem =\n (typeof message === \"string\"\n ? undefined\n : `whose message is ${shown(message)}, not a string`) ??\n offsetProblem(\"whose start\", start, 0, length) ??\n (end === undefined ? undefined : offsetProblem(\"whose end\", end, start as number, length)) ??\n (edit === undefined || (edit && typeof edit === \"object\")\n ? undefined\n : `whose edit is ${shown(edit)}, not an object`);\n if (problem) return `returned a finding ${problem}`;\n if (edit === undefined) continue;\n const { start: from, end: to, text } = edit as Record<string, unknown>;\n const invalid =\n offsetProblem(\"whose start\", from, 0, length) ??\n offsetProblem(\"whose end\", to, from as number, length) ??\n (typeof text === \"string\" ? undefined : `whose text is ${shown(text)}, not a string`);\n if (invalid) return `returned an edit ${invalid}`;\n }\n return undefined;\n}\n/**\n * Whether an edit would change text that the parser read where renderers may\n * read a list, or a block indented below it, which renderers may read inside\n * that list (`misreadLists`, issue #191): replace some of their characters, or\n * insert text between two of them. Renderers may read such text as list items\n * or code, and the indentation of the blocks below it otherwise, which the\n * safety check, comparing the parser's readings, cannot see: `_r_` for `*r*`\n * in `- 0. *r*` below a paragraph changes code on GitHub. The same goes for\n * a definition description on Forgejo and Gitea and the blocks below it, which\n * those renderers read as the description's blocks (issue #344), for a block\n * in Obsidian with a backtick that no run closes, where Obsidian shows code\n * that the parser does not (issue #362), and for the blocks that Obsidian reads\n * as more of an HTML block above them (issue #358). Only the part of the edit\n * that changes the text counts, so that an edit that copies such\n * text, such as a list rule's, can still apply.\n */\nfunction misreadEdits(document: Document): (edit: Edit) => boolean {\n const misread = misreadLists(document);\n // The blocks can hold one another; their union, in order, is searched in O(log n).\n const blocks: [number, number][] = [];\n for (const [start, end] of Array.from(\n [\n ...misread.text,\n ...misread.nested,\n ...misread.descriptions,\n ...misread.unclosedCode,\n ...misread.htmlText,\n ],\n (node) => range(node),\n ).sort((a, b) => a[0] - b[0])) {\n const last = blocks.at(-1);\n if (last && start < last[1]) last[1] = Math.max(last[1], end);\n else blocks.push([start, end]);\n }\n if (!blocks.length) return () => false;\n const { source } = document;\n const within = (from: number, to: number) => {\n let low = 0;\n let high = blocks.length;\n while (low < high) {\n const middle = (low + high) >> 1;\n if (blocks[middle]![1] <= from) low = middle + 1;\n else high = middle;\n }\n const block = blocks[low];\n return block !== undefined && from < block[1] && to > block[0];\n };\n return (edit) => {\n if (!within(edit.start, edit.end)) return false;\n const before = source.slice(edit.start, edit.end);\n const { text } = edit;\n if (before === text) return false;\n const shorter = Math.min(before.length, text.length);\n let prefix = 0;\n while (prefix < shorter && before[prefix] === text[prefix]) prefix++;\n let suffix = 0;\n while (suffix < shorter - prefix && before.at(-1 - suffix) === text.at(-1 - suffix)) suffix++;\n return within(edit.start + prefix, edit.end - suffix);\n };\n}\n/**\n * The workspace of a run as the engine and its rules use it, and the errors\n * that it threw. Such an error is the host's, such as a file that could not be\n * read, and neither a rule's nor a refusal to format: it stops the run.\n */\ninterface Host {\n workspace?: Workspace;\n errors: Set<unknown>;\n}\nfunction host(workspace: Workspace | undefined): Host {\n const errors = new Set<unknown>();\n return workspace ? { workspace: guarded(workspace, errors), errors } : { errors };\n}\n/**\n * `workspace` as rules see it. What its `resolve` throws is added to `errors`:\n * such an error is the host's, such as a file that could not be read, and not\n * the rule's. Rules still see it as it was thrown.\n */\nfunction guarded(workspace: Workspace, errors: Set<unknown>): Workspace {\n const resolve: Workspace[\"resolve\"] = (...query) => {\n try {\n return workspace.resolve(...query);\n } catch (error) {\n errors.add(error);\n throw error;\n }\n };\n // Other members, such as a host's own, reach the workspace itself.\n return new Proxy(workspace, {\n get(target, key) {\n if (key === \"resolve\") return resolve;\n const value: unknown = Reflect.get(target, key);\n return typeof value === \"function\" ? (value as () => unknown).bind(target) : value;\n },\n });\n}\n/** A thrown value as text, without letting it throw again. */\nfunction failure(error: unknown): string {\n try {\n return error instanceof Error ? `${error.name}: ${error.message}` : String(error);\n } catch {\n return \"a value that cannot be shown\";\n }\n}\n/**\n * The diagnostics of the enabled rules that `include` selects. A rule that\n * throws, or returns something that is not a list of valid findings, is\n * skipped for the document and reported as `engine/rule-error` instead. An\n * error of the workspace itself, such as a file that could not be read, is\n * not the rule's and is thrown on. Suppressed findings are left out, and so\n * are findings whose edits would change text that the parser read in place of\n * a list, or the blocks that renderers read inside that list: the finding\n * describes what the parser read, and following it by hand would make the\n * change too.\n */\nfunction inspect(\n document: Document,\n config: ResolvedConfig,\n rules: Record<string, Rule>,\n { workspace, errors: hostErrors }: Host,\n include: (rule: Rule) => boolean = () => true,\n): Diagnostic[] {\n const result: Diagnostic[] = [];\n const suppressed = suppressions(document);\n const misread = misreadEdits(document);\n const starts = lineStarts(document.source);\n for (const [name, value] of Object.entries(config.rules)) {\n const enabled = setting(value);\n const rule = rules[name]!;\n if (enabled.severity === \"off\" || !include(rule)) continue;\n let findings: Finding[] = [];\n let problem: string | undefined;\n try {\n const returned: unknown = rule.check({\n document,\n options: enabled.options,\n ...(workspace ? { workspace } : {}),\n });\n problem = findingsProblem(returned, document.source.length);\n if (!problem) findings = returned as Finding[];\n } catch (error) {\n if (hostErrors.has(error)) throw error;\n problem = `failed (${failure(error)})`;\n }\n if (problem) {\n result.push(\n diagnostic([0], \"engine/rule-error\", \"error\", {\n start: 0,\n message: `Rule ${name} ${problem}; the rule was skipped for this document.`,\n }),\n );\n continue;\n }\n for (const finding of findings)\n if (!suppressed(name, finding) && !(finding.edit && misread(finding.edit)))\n result.push(diagnostic(starts, name, enabled.severity, finding));\n }\n return result.sort(sortDiagnostics);\n}\n/**\n * Locate diagnostics of a document that `parse` read without the byte order\n * marks it starts with in the text as given, so that their edits apply to that\n * text. Lines and columns stay as they are: the marks are invisible.\n */\nfunction located(diagnostics: Diagnostic[], mark: string): Diagnostic[] {\n if (!mark) return diagnostics;\n const by = mark.length;\n return diagnostics.map((item) => ({\n ...item,\n start: item.start + by,\n ...(item.end !== undefined ? { end: item.end + by } : {}),\n ...(item.edit\n ? { edit: { ...item.edit, start: item.edit.start + by, end: item.edit.end + by } }\n : {}),\n }));\n}\n/**\n * The diagnostics of the enabled rules for `source`, sorted by position. A rule\n * that fails is skipped and reported as `engine/rule-error`. An invalid\n * configuration, an unknown rule, invalid rule options, an invalid plugin, and\n * an error that the workspace throws are thrown.\n */\nexport function lint(source: string, options: ProcessOptions = {}): Diagnostic[] {\n if (options.ranges) checkRanges(options.ranges, source);\n const { config, rules } = prepare(options);\n const [mark, text] = splitByteOrderMark(source);\n const document = parse(text, config.dialect, options.path, options.plugins);\n const diagnostics = inspect(document, config, rules, host(options.workspace));\n // Ranges count the marks, and the document's positions do not.\n const scope =\n options.ranges && widen(document.tree, document.source, shifted(options.ranges, -mark.length));\n return located(\n scope\n ? diagnostics.filter((item) => fromEngine(item) || covers(scope, item.start))\n : diagnostics,\n mark,\n );\n}\n/**\n * `source` with `edits` applied, which are `{ start, end, text }` replacements\n * at UTF-16 offsets into it. Repeats of one edit count once; an edit outside\n * the source, or one that overlaps another, is an error.\n */\nexport function applyEdits(source: string, edits: readonly Edit[]): string {\n return splice(source, acceptedEdits(source, edits));\n}\n/** `source` with `edits`, which are sorted and do not overlap, applied. */\nfunction splice(source: string, edits: readonly Edit[]): string {\n // Assemble the result in one pass; rebuilding the string per edit is quadratic.\n const parts: string[] = [];\n let cursor = 0;\n for (const edit of edits) {\n parts.push(source.slice(cursor, edit.start), edit.text);\n cursor = edit.end;\n }\n parts.push(source.slice(cursor));\n return parts.join(\"\");\n}\n/**\n * The edits that `applyEdits` applies, sorted by position and without repeats\n * of the same edit. An edit outside the source, or overlapping another one, is\n * an error.\n */\nfunction acceptedEdits(source: string, edits: readonly Edit[]): Edit[] {\n const sorted = [...edits].sort((a, b) => a.start - b.start || a.end - b.end);\n let previous: Edit | undefined;\n const accepted: Edit[] = [];\n for (const edit of sorted) {\n if (\n !Number.isInteger(edit.start) ||\n !Number.isInteger(edit.end) ||\n edit.start < 0 ||\n edit.end < edit.start ||\n edit.end > source.length\n )\n throw new Error(\"Rule returned an invalid edit range.\");\n if (\n previous &&\n edit.start === previous.start &&\n edit.end === previous.end &&\n edit.text === previous.text\n )\n continue;\n if (previous && (edit.start < previous.end || edit.start === previous.start))\n throw new Error(\n \"Enabled rules proposed overlapping edits; disable one of the conflicting rules.\",\n );\n accepted.push(edit);\n previous = edit;\n }\n return accepted;\n}\n/**\n * The meaning of a parsed document as text, which `format` compares before and\n * after edits to refuse a change of meaning: its syntax tree without positions,\n * with runs of whitespace in text alike, and with each link's destination as\n * the workspace resolves it, so that two spellings of one target are the same.\n */\nexport function semanticFingerprint(document: Document, workspace?: Workspace): string {\n return JSON.stringify(semanticTree(document, workspace));\n}\n/**\n * The document's meaning as plain data whose keys are in sorted order. With\n * `origins`, each object of the result that stands for a node of the document\n * is mapped to that node.\n */\nfunction semanticTree(\n document: Document,\n workspace?: Workspace,\n origins?: Map<unknown, Nodes>,\n): unknown {\n const canonicalUrl = (url: string, wiki = false) => {\n const resolution = workspace?.resolve(document.path, url, document.dialect, wiki);\n // A target that is uncertain, because a directory could not be read, is not\n // an identity: only the same spelling is known to name the same note.\n return resolution?.status === \"resolved\" && !resolution.unreadable\n ? `${resolution.target}#${resolution.fragment ?? \"\"}`\n : url;\n };\n // Keys are emitted in sorted order so the JSON text is canonical without a replacer.\n function normalize(node: Nodes, calloutHeader = false): unknown {\n if (node.type === \"wikiLink\") {\n const link = node.embed\n ? { label: node.label, type: \"embed\", url: canonicalUrl(node.target, true) }\n : {\n children: [{ type: \"text\", value: node.label ?? node.target }],\n title: null,\n type: \"link\",\n url: canonicalUrl(node.target, true),\n };\n origins?.set(link, node);\n return link;\n }\n const result: Record<string, unknown> = {};\n // Forgejo and Gitea read a heading's trailing `{...}` block as attributes,\n // character for character, where the tree holds ordinary inline content,\n // and generate the anchor from the heading's last line as written.\n if (node.type === \"heading\") {\n const attributes = headingAttributeSource(document, node);\n if (attributes !== undefined) result.attributes = attributes;\n const anchors = headingAnchorSource(document, node);\n if (anchors !== undefined) result.anchors = anchors;\n }\n if (calloutHeader && document.dialect !== \"commonmark\" && node.type === \"paragraph\") {\n const [start, end] = range(node);\n const header = document.source.slice(start, end).split(/\\r\\n|\\r|\\n/, 1)[0]!;\n if (startsWithMarker(header, node)) {\n // CommonMark merges an Obsidian callout's title, or the line of a\n // GitHub alert's marker, and the body into one paragraph. Preserve\n // their boundary too, also for a marker written as `\\[!NOTE]`.\n const title = header.replace(\n /^\\[!([\\w-]+)\\]/,\n (_, marker: string) => `[!${marker.toLowerCase()}]`,\n );\n result.calloutTitle = normalize(parse(title, document.dialect, document.path).tree);\n }\n }\n for (const key of Object.keys(node).sort()) {\n const value = (node as unknown as Record<string, unknown>)[key];\n if (key === \"position\" || key === \"data\") continue;\n if (key === \"children\" && \"children\" in node) {\n result.children = node.children.map((child, index) =>\n normalize(child, index === 0 && (node.type === \"blockquote\" || calloutHeader)),\n );\n } else if (key === \"url\" && typeof value === \"string\") result[key] = canonicalUrl(value);\n else if (key === \"value\" && node.type === \"text\") {\n let text = node.value.replace(/[ \\t\\r\\n]+/g, \" \");\n if (calloutHeader && document.dialect !== \"commonmark\")\n text = text.replace(\n /^\\[!([\\w-]+)\\]/,\n (_, marker: string) => `[!${marker.toLowerCase()}]`,\n );\n result[key] = text;\n } else if (key === \"value\" && node.type === \"inlineCode\")\n // A code span is compared by the text that GitHub shows, which its\n // value in the tree does not hold where it spans lines.\n result[key] = codeSpanText(node);\n // An image's description renders as plain text, and a reference's label\n // matches its definition with whitespace collapsed.\n else if ((key === \"alt\" || key === \"label\") && typeof value === \"string\")\n result[key] = value.replace(/[ \\t\\r\\n]+/g, \" \");\n else result[key] = value;\n }\n origins?.set(result, node);\n return result;\n }\n const result = normalize(document.tree) as Record<string, unknown>;\n // Where front matter would end inside a code block, an HTML block, or\n // display math, the document is read without it, and renderers read TOML\n // front matter as a paragraph. An edit has to keep the meaning of both\n // readings.\n const reading = otherReading(document.tree);\n if (reading) result.otherReading = normalize(reading);\n return result;\n}\n/** A part of a semantic tree that has children. */\ntype Branch = Record<string, unknown> & { children: unknown[] };\nconst isBranch = (value: unknown): value is Branch =>\n typeof value === \"object\" && value !== null && Array.isArray((value as Branch).children);\n/**\n * Where the meaning of `after` first differs from that of `before`, as an\n * offset into `before`'s source: the start of the first node, in document\n * order, whose meaning is not the same, or the end of the node that `after`\n * gives more content.\n */\nfunction divergence(before: Document, after: Document, workspace?: Workspace): number {\n const origins = new Map<unknown, Nodes>();\n let a = semanticTree(before, workspace, origins);\n let b = semanticTree(after, workspace);\n // Where only the other reading differs, the place is in that reading, and\n // otherwise in the document's own.\n const reading = (value: unknown) => (value as { otherReading?: unknown }).otherReading;\n if (\n isBranch(a) &&\n isBranch(b) &&\n isBranch(reading(a)) &&\n isBranch(reading(b)) &&\n JSON.stringify(a.children) === JSON.stringify(b.children)\n ) {\n a = reading(a);\n b = reading(b);\n }\n let offset = 0;\n for (;;) {\n const node = origins.get(a);\n // A node made up for the comparison, or one without a position, is placed at its parent.\n offset = node?.position?.start.offset ?? offset;\n if (!isBranch(a) || !isBranch(b)) return offset;\n const own = (value: Branch) =>\n JSON.stringify({ ...value, children: undefined, otherReading: undefined });\n if (own(a) !== own(b)) return offset;\n const { children } = b;\n const index = a.children.findIndex(\n (child, at) => JSON.stringify(child) !== JSON.stringify(children[at]),\n );\n if (index < 0) return node?.position?.end.offset ?? offset;\n a = a.children[index];\n b = children[index];\n }\n}\n/**\n * Format a document: apply the edits of the enabled style rules, in passes\n * until nothing changes, leaving out the edits of a rule that would change the\n * document's meaning. Byte order marks that it starts with stay in the output\n * and are not part of what the rules see. Errors are thrown as by `lint`.\n */\nexport function format(source: string, options: ProcessOptions = {}): FormatResult {\n if (options.ranges) checkRanges(options.ranges, source);\n const [mark, text] = splitByteOrderMark(source);\n // Ranges count the marks, and the document's positions do not.\n const result = formatText(text, options, options.ranges && shifted(options.ranges, -mark.length));\n return {\n output: mark + result.output,\n changed: result.changed,\n diagnostics: located(result.diagnostics, mark),\n ...(result.scope ? { scope: shifted(result.scope, mark.length) } : {}),\n };\n}\n/** An edit that a rule proposed, with the rule's ID. */\ninterface Proposal extends Edit {\n rule: string;\n}\nconst byPosition = (a: Edit, b: Edit) => a.start - b.start || a.end - b.end;\n/**\n * The proposals to apply together, in the order of the source. An edit that\n * overlaps one before it, or repeats it, is left out; the next pass, which\n * runs the rules again on the changed text, reconsiders it.\n */\nfunction compatible(proposals: readonly Proposal[]): Proposal[] {\n const result: Proposal[] = [];\n let previous: Proposal | undefined;\n for (const edit of [...proposals].sort(byPosition)) {\n if (previous && (edit.start < previous.end || edit.start === previous.start)) continue;\n result.push(edit);\n previous = edit;\n }\n return result;\n}\n/** Rule IDs as a list in prose. */\nfunction listed(names: Iterable<string>): string {\n const items = [...names];\n return items.length < 3\n ? items.join(\" and \")\n : `${items.slice(0, -1).join(\", \")}, and ${items.at(-1)}`;\n}\n/**\n * Format a document without byte order marks, limited to `ranges` in its\n * positions. Each phase applies the edits of its rules together when the\n * result means what the original document means. Otherwise it adds the rules'\n * edits one rule at a time and leaves out the edits of each rule that would\n * change the meaning; the result reports each such rule with the place where\n * the meaning would first differ. Passes repeat until one changes nothing;\n * formatting that does not settle leaves the whole document unchanged.\n */\nfunction formatText(\n source: string,\n options: ProcessOptions,\n ranges: SourceRange[] | undefined,\n): FormatResult {\n const { config, rules } = prepare(options);\n // What the workspace throws stops formatting, as it stops `lint`.\n const hosted = host(options.workspace);\n const { workspace } = hosted;\n let output = source;\n let document = parse(source, config.dialect, options.path, options.plugins);\n // Where edits may apply, in the positions of the current output.\n const initial = ranges && widen(document.tree, source, ranges);\n let scope = initial;\n // Engine findings concern the whole document and are always reported.\n const reported = (items: Diagnostic[]) =>\n scope ? items.filter((item) => fromEngine(item) || covers(scope!, item.start)) : items;\n const unchanged = (message: string): FormatResult => ({\n output: source,\n changed: false,\n diagnostics: [diagnostic([0], \"engine/unsafe-format\", \"error\", { start: 0, message })],\n ...(initial ? { scope: initial } : {}),\n });\n // The original fingerprint is only needed once an edit produces a candidate.\n let fingerprint: string | undefined;\n /** `candidate` parsed, and whether it means what the original document means. */\n const check = (candidate: string) => {\n const parsed = parse(candidate, config.dialect, options.path, options.plugins);\n // Every document accepted so far means what the original means, so the current one serves.\n fingerprint ??= semanticFingerprint(document, workspace);\n return {\n document: parsed,\n safe: semanticFingerprint(parsed, workspace) === fingerprint,\n };\n };\n const seen = new Set([source]);\n /** The rules whose edits changed the document in the latest pass. */\n let applied = new Set<string>();\n try {\n for (let pass = 0; pass < 8; pass++) {\n const before = output;\n const findings: Diagnostic[] = [];\n applied = new Set();\n /** The rules whose edits this pass left out, with the document before and after them. */\n const refused: { rule: string; before: Document; after: Document }[] = [];\n const accept = (edits: Proposal[], text: string, parsed: Document) => {\n output = text;\n // Rules consume the document without mutating it. Reuse the validated\n // tree until another phase changes its source, including final diagnostics.\n document = parsed;\n if (scope) scope = moved(scope, edits);\n for (const edit of edits) applied.add(edit.rule);\n };\n for (const phase of phases) {\n const diagnostics = inspect(\n document,\n config,\n rules,\n hosted,\n (rule) => rule.kind === \"style\" && (rule.phase ?? \"inline\") === phase,\n );\n findings.push(...diagnostics);\n // With ranges, an edit that reaches outside them is not applied. One\n // that changes nothing need not be tried, and must not hold others back.\n const proposals: Proposal[] = [];\n for (const { edit, rule } of diagnostics)\n if (\n edit &&\n (!scope || holds(scope, edit)) &&\n output.slice(edit.start, edit.end) !== edit.text\n )\n proposals.push({ start: edit.start, end: edit.end, text: edit.text, rule });\n // The rules of this phase whose edits would change the meaning.\n const excluded = new Set<string>();\n for (;;) {\n const edits = compatible(proposals.filter((edit) => !excluded.has(edit.rule)));\n if (!edits.length) break;\n const candidate = splice(output, edits);\n if (candidate === output) break;\n const tried = check(candidate);\n if (tried.safe) {\n accept(edits, candidate, tried.document);\n break;\n }\n // Taken only when a phase fails, so the usual path parses each candidate once.\n let kept: Proposal[] = [];\n let keptOutput = output;\n let keptDocument = document;\n for (const rule of new Set(edits.map((edit) => edit.rule))) {\n const trial = [...kept, ...edits.filter((edit) => edit.rule === rule)].sort(byPosition);\n // All the edits together are already known to fail.\n const whole = trial.length === edits.length;\n const text = whole ? candidate : splice(output, trial);\n const result = whole ? tried : check(text);\n if (result.safe) {\n kept = trial;\n keptOutput = text;\n keptDocument = result.document;\n } else {\n excluded.add(rule);\n refused.push({ rule, before: document, after: result.document });\n }\n }\n if (keptOutput !== output) {\n accept(kept, keptOutput, keptDocument);\n break;\n }\n // Nothing was kept: the edits that overlapped refused ones get their turn.\n }\n }\n if (output === before) {\n // No phase changed the document, so every style finding of this pass\n // describes the final document; only the non-style rules still need to run.\n const remaining = inspect(document, config, rules, hosted, (rule) => rule.kind !== \"style\");\n // A refusal of this pass was tried on the final text, unless one\n // phase undid what an earlier one did.\n const starts = refused.length ? lineStarts(output) : [];\n const refusals = refused.map(({ rule, before: tried, after }) => {\n const start = tried.source === output ? divergence(tried, after, workspace) : 0;\n const { line } = diagnostic(starts, rule, \"error\", { start, message: \"\" });\n return diagnostic(starts, \"engine/unsafe-format\", \"error\", {\n start,\n message: `${rule} would change the parsed meaning at line ${line}; none of its edits were applied.`,\n });\n });\n return {\n output,\n changed: output !== source,\n diagnostics: reported([...findings, ...remaining, ...refusals]).sort(sortDiagnostics),\n ...(scope ? { scope } : {}),\n };\n }\n if (seen.has(output))\n return unchanged(\n `Formatting by ${listed(applied)} oscillates; the document was left unchanged.`,\n );\n seen.add(output);\n }\n return unchanged(\n `Formatting by ${listed(applied)} did not converge in eight passes; the document was left unchanged.`,\n );\n } catch (error) {\n if (hosted.errors.has(error)) throw error;\n return unchanged(error instanceof Error ? error.message : String(error));\n }\n}\n"]}
|
package/dist/rules/blocks.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import stringWidth from "string-width";
|
|
2
2
|
import { belowTomlFrontMatter, frontMatterReading, joinsTomlFrontMatter, range, startsWithMarker, unclosedFrontMatter, } from "../syntax/parse.js";
|
|
3
|
+
import { misreadLists } from "../syntax/misread-lists.js";
|
|
3
4
|
import { walk } from "../syntax/walk.js";
|
|
4
5
|
/** A JSON Schema for an options object with these properties and no others. */
|
|
5
6
|
function schema(properties) {
|
|
@@ -345,6 +346,35 @@ const thematicBreak = {
|
|
|
345
346
|
return findings;
|
|
346
347
|
},
|
|
347
348
|
};
|
|
349
|
+
/**
|
|
350
|
+
* In the Obsidian dialect, the indices of the lines of blank space that
|
|
351
|
+
* Obsidian's Reading view reads as more of the block above them, where
|
|
352
|
+
* CommonMark and the parser read a blank line: one that holds a tab, which
|
|
353
|
+
* continues a paragraph, and one directly below an HTML block or the text that
|
|
354
|
+
* Obsidian reads as more of one, which continues the block (issue #358).
|
|
355
|
+
* Emptying such a line would end the block there.
|
|
356
|
+
*/
|
|
357
|
+
function obsidianShownBlanks(document, lines) {
|
|
358
|
+
const shown = new Set();
|
|
359
|
+
if (document.dialect !== "obsidian")
|
|
360
|
+
return shown;
|
|
361
|
+
const below = new Set();
|
|
362
|
+
walk(document.tree, "html", (node, _, parent) => {
|
|
363
|
+
// An HTML block, not inline HTML: its parent holds blocks.
|
|
364
|
+
if (parent && containers.has(parent.type) && node.position)
|
|
365
|
+
below.add(node.position.end.line);
|
|
366
|
+
});
|
|
367
|
+
// And so does the text that Obsidian reads as more of such a block.
|
|
368
|
+
for (const node of misreadLists(document).htmlText)
|
|
369
|
+
if (node.position)
|
|
370
|
+
below.add(node.position.end.line);
|
|
371
|
+
lines.forEach((line, index) => {
|
|
372
|
+
const text = document.source.slice(line.start, line.end);
|
|
373
|
+
if (/^[ \t>]*$/.test(text) && /[^>]/.test(text) && (text.includes("\t") || below.has(index)))
|
|
374
|
+
shown.add(index);
|
|
375
|
+
});
|
|
376
|
+
return shown;
|
|
377
|
+
}
|
|
348
378
|
/** Where blank lines are content, or their number counts, as source ranges. */
|
|
349
379
|
function contentBlocks(document) {
|
|
350
380
|
const blocks = [];
|
|
@@ -375,9 +405,11 @@ const blankLines = {
|
|
|
375
405
|
const maximum = typeof options.maximum === "number" ? options.maximum : 1;
|
|
376
406
|
const lines = physicalLines(source);
|
|
377
407
|
const text = (line) => source.slice(line.start, line.end);
|
|
378
|
-
|
|
408
|
+
// Obsidian reads some lines of blank space as text, which stay as written.
|
|
409
|
+
const shown = new Set([...obsidianShownBlanks(document, lines)].map((index) => lines[index]));
|
|
410
|
+
const empty = (line) => !shown.has(line) && /^[ \t]*$/.test(text(line));
|
|
379
411
|
// A line of blank space and block quote markers is blank inside its quotes.
|
|
380
|
-
const blank = (line) => /^[ \t>]*$/.test(text(line));
|
|
412
|
+
const blank = (line) => !shown.has(line) && /^[ \t>]*$/.test(text(line));
|
|
381
413
|
const blocks = contentBlocks(document);
|
|
382
414
|
let block = 0;
|
|
383
415
|
/** Whether a line lies inside a block that began above it; asked in document order. */
|
|
@@ -534,9 +566,12 @@ const trailingSpace = {
|
|
|
534
566
|
return !(forge && source.slice(...paragraph).includes("\\("));
|
|
535
567
|
};
|
|
536
568
|
const findings = [];
|
|
537
|
-
|
|
569
|
+
const lines = physicalLines(source);
|
|
570
|
+
const shown = obsidianShownBlanks(document, lines);
|
|
571
|
+
for (const [index, line] of lines.entries()) {
|
|
538
572
|
const space = /[ \t]+$/.exec(source.slice(line.start, line.end));
|
|
539
|
-
|
|
573
|
+
// Obsidian reads some lines of blank space as text, which stay as written.
|
|
574
|
+
if (!space || shown.has(index))
|
|
540
575
|
continue;
|
|
541
576
|
const start = line.start + space.index;
|
|
542
577
|
const end = line.end;
|