@redocly/recheck 0.4.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +365 -127
- package/dist/cli.js +59 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/baseline.d.ts +10 -0
- package/dist/commands/baseline.d.ts.map +1 -0
- package/dist/commands/baseline.js +59 -0
- package/dist/commands/baseline.js.map +1 -0
- package/dist/commands/readability.d.ts +10 -0
- package/dist/commands/readability.d.ts.map +1 -0
- package/dist/commands/readability.js +90 -0
- package/dist/commands/readability.js.map +1 -0
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +52 -8
- package/dist/commands/run.js.map +1 -1
- package/dist/config/load.d.ts +2 -0
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +3 -0
- package/dist/config/load.js.map +1 -1
- package/dist/config/schema.d.ts +4 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +3 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/config/validate.d.ts +2 -0
- package/dist/config/validate.d.ts.map +1 -1
- package/dist/config/validate.js +3 -1
- package/dist/config/validate.js.map +1 -1
- package/dist/core/baseline.d.ts +49 -0
- package/dist/core/baseline.d.ts.map +1 -0
- package/dist/core/baseline.js +0 -0
- package/dist/core/baseline.js.map +1 -0
- package/dist/core/prose-extract.d.ts +6 -0
- package/dist/core/prose-extract.d.ts.map +1 -0
- package/dist/core/prose-extract.js +79 -0
- package/dist/core/prose-extract.js.map +1 -0
- package/dist/core/readability.d.ts +17 -0
- package/dist/core/readability.d.ts.map +1 -0
- package/dist/core/readability.js +37 -0
- package/dist/core/readability.js.map +1 -0
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +1 -0
- package/dist/core/runner.js.map +1 -1
- package/dist/data/markdoc-realm-schema.d.ts.map +1 -1
- package/dist/data/markdoc-realm-schema.js +13 -0
- package/dist/data/markdoc-realm-schema.js.map +1 -1
- package/dist/reporter/formats/json.d.ts +5 -1
- package/dist/reporter/formats/json.d.ts.map +1 -1
- package/dist/reporter/formats/json.js +2 -1
- package/dist/reporter/formats/json.js.map +1 -1
- package/dist/reporter/index.js +2 -2
- package/dist/reporter/index.js.map +1 -1
- package/dist/reporter/summary.d.ts +1 -1
- package/dist/reporter/summary.d.ts.map +1 -1
- package/dist/reporter/summary.js +2 -1
- package/dist/reporter/summary.js.map +1 -1
- package/dist/rules/scope/metric.d.ts +2 -14
- package/dist/rules/scope/metric.d.ts.map +1 -1
- package/dist/rules/scope/metric.js +11 -187
- package/dist/rules/scope/metric.js.map +1 -1
- package/dist/rules/scope/semantic-line-breaks.d.ts.map +1 -1
- package/dist/rules/scope/semantic-line-breaks.js +58 -35
- package/dist/rules/scope/semantic-line-breaks.js.map +1 -1
- package/dist/rules/token/link-fragments.d.ts.map +1 -1
- package/dist/rules/token/link-fragments.js +251 -91
- package/dist/rules/token/link-fragments.js.map +1 -1
- package/dist/rules/types.d.ts +2 -0
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/types/reporting.d.ts +9 -0
- package/dist/types/reporting.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/reporter/formats/json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAIlC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,QAAmB,EACnB,SAAiB,EACjB,UAAmB;
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/reporter/formats/json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAIlC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,QAAmB,EACnB,SAAiB,EACjB,UAAmB,EACnB,QAA0D;IAE1D,MAAM,MAAM,GAAG;QACb,OAAO,EAAE;YACP,YAAY,EAAE,SAAS;YACvB,WAAW,EAAE,QAAQ,CAAC,MAAM;YAC5B,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;YAC/C,SAAS,EAAE,iBAAiB,CAAC,QAAQ,CAAC;SACvC;QACD,MAAM,EAAE,QAAQ;KACjB,CAAC;IAEF,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAEhD,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxC,MAAM,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAChD,OAAO,CAAC,GAAG,CAAC,6BAA6B,UAAU,EAAE,CAAC,CAAC;IACzD,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
|
package/dist/reporter/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { outputGitHubActionsFormat } from './formats/github-actions.js';
|
|
|
7
7
|
* Generate report in the specified format
|
|
8
8
|
*/
|
|
9
9
|
export async function generateReport(problems, fileCount, options) {
|
|
10
|
-
const { format, showStats, annotationsLimit, outputPath } = options;
|
|
10
|
+
const { format, showStats, annotationsLimit, outputPath, baseline } = options;
|
|
11
11
|
const prioritized = typeof annotationsLimit === 'number'
|
|
12
12
|
? prioritizeProblems(problems, annotationsLimit)
|
|
13
13
|
: problems;
|
|
@@ -19,7 +19,7 @@ export async function generateReport(problems, fileCount, options) {
|
|
|
19
19
|
outputGitHubActionsFormat(prioritized);
|
|
20
20
|
break;
|
|
21
21
|
case 'json':
|
|
22
|
-
await outputJsonFormat(prioritized, fileCount, outputPath);
|
|
22
|
+
await outputJsonFormat(prioritized, fileCount, outputPath, baseline);
|
|
23
23
|
break;
|
|
24
24
|
default:
|
|
25
25
|
outputTableFormat(problems, fileCount, showStats);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reporter/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,QAAmB,EACnB,SAAiB,EACjB,OAAsB;IAEtB,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reporter/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,QAAmB,EACnB,SAAiB,EACjB,OAAsB;IAEtB,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAE9E,MAAM,WAAW,GACf,OAAO,gBAAgB,KAAK,QAAQ;QAClC,CAAC,CAAC,kBAAkB,CAAC,QAAQ,EAAE,gBAAgB,CAAC;QAChD,CAAC,CAAC,QAAQ,CAAC;IAEf,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,OAAO;YACV,MAAM,iBAAiB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;YACjD,MAAM;QACR,KAAK,gBAAgB;YACnB,yBAAyB,CAAC,WAAW,CAAC,CAAC;YACvC,MAAM;QACR,KAAK,MAAM;YACT,MAAM,gBAAgB,CAAC,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;YACrE,MAAM;QACR;YACE,iBAAiB,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;YAClD,MAAM;IACV,CAAC;IAED,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,MAAM,YAAY,GAChB,OAAO,OAAO,CAAC,gBAAgB,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,OAAO,CAAC,gBAAgB,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7F,OAAO,CAAC,GAAG,CAAC,8BAA8B,WAAW,CAAC,MAAM,GAAG,YAAY,EAAE,CAAC,CAAC;IACjF,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAAsB;IAC9D,MAAM,cAAc,CAAC,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -2,7 +2,7 @@ import type { Problem, Summary } from '../types/index.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Build summary object from problems and file count
|
|
4
4
|
*/
|
|
5
|
-
export declare function buildSummary(problems: Problem[], fileCount: number): Summary;
|
|
5
|
+
export declare function buildSummary(problems: Problem[], fileCount: number, baseline?: Summary['baseline']): Summary;
|
|
6
6
|
/**
|
|
7
7
|
* Emit summary in requested format to file or stdout
|
|
8
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../src/reporter/summary.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAI1D;;GAEG;AACH,wBAAgB,YAAY,
|
|
1
|
+
{"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../src/reporter/summary.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAI1D;;GAEG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,OAAO,EAAE,EACnB,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAC7B,OAAO,CAeT;AAED;;GAEG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CA2Bf"}
|
package/dist/reporter/summary.js
CHANGED
|
@@ -3,7 +3,7 @@ import { getBreakdownStats } from './statistics.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Build summary object from problems and file count
|
|
5
5
|
*/
|
|
6
|
-
export function buildSummary(problems, fileCount) {
|
|
6
|
+
export function buildSummary(problems, fileCount, baseline) {
|
|
7
7
|
const breakdown = getBreakdownStats(problems);
|
|
8
8
|
const totalErrors = problems.filter((h) => h.severity === 'error').length;
|
|
9
9
|
const totalWarnings = problems.filter((h) => h.severity === 'warn').length;
|
|
@@ -11,6 +11,7 @@ export function buildSummary(problems, fileCount) {
|
|
|
11
11
|
return {
|
|
12
12
|
filesScanned: fileCount,
|
|
13
13
|
totalIssues: problems.length,
|
|
14
|
+
...(baseline === undefined ? {} : { baseline }),
|
|
14
15
|
totalErrors,
|
|
15
16
|
totalWarnings,
|
|
16
17
|
totalInfo,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summary.js","sourceRoot":"","sources":["../../src/reporter/summary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAIlC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;GAEG;AACH,MAAM,UAAU,YAAY,
|
|
1
|
+
{"version":3,"file":"summary.js","sourceRoot":"","sources":["../../src/reporter/summary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAIlC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,QAAmB,EACnB,SAAiB,EACjB,QAA8B;IAE9B,MAAM,SAAS,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC9C,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,MAAM,CAAC;IAC1E,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,MAAM,CAAC;IAC3E,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,MAAM,CAAC;IAEvE,OAAO;QACL,YAAY,EAAE,SAAS;QACvB,WAAW,EAAE,QAAQ,CAAC,MAAM;QAC5B,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;QA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C,CAAC;QAC1C,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,EAAE,CAAC,CAAC;IAC/C,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import type { ScopeRule } from '../types.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* code spans) from RAW segment text -- i.e. text that has not already been
|
|
5
|
-
* structurally masked, see `MARKDOC_TAG_RE`'s comment. Inline code spans
|
|
6
|
-
* are REMOVED outright (not masked-and-restored like
|
|
7
|
-
* capitalization.ts/spelling.ts do): there is no position-sensitive rewrite
|
|
8
|
-
* downstream to keep offsets aligned for, just a word/syllable count that
|
|
9
|
-
* must never include a code span's content. BACKTICK_SPAN_RE
|
|
10
|
-
* (core/inline-code.ts) gives this the same CommonMark-correct
|
|
11
|
-
* open-run/close-run-of-equal-length span recognition capitalization.ts and
|
|
12
|
-
* spelling.ts use, including a span whose content itself contains a
|
|
13
|
-
* shorter, unpaired backtick run. Exported for direct unit testing.
|
|
14
|
-
*/
|
|
15
|
-
export declare function stripNonProse(text: string): string;
|
|
2
|
+
import { stripNonProse } from '../../core/prose-extract.js';
|
|
3
|
+
export { stripNonProse };
|
|
16
4
|
export declare const metric: ScopeRule;
|
|
17
5
|
//# sourceMappingURL=metric.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metric.d.ts","sourceRoot":"","sources":["../../../src/rules/scope/metric.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAoB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"metric.d.ts","sourceRoot":"","sources":["../../../src/rules/scope/metric.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAoB,MAAM,aAAa,CAAC;AAG/D,OAAO,EAAgB,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAK1E,OAAO,EAAE,aAAa,EAAE,CAAC;AAoEzB,eAAO,MAAM,MAAM,EAAE,SAAqD,CAAC"}
|
|
@@ -1,194 +1,18 @@
|
|
|
1
1
|
import { formatTemplate } from '../token/messages.js';
|
|
2
2
|
import { computeTextStatistics, computeReadability } from '../../metrics/index.js';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* `{% /admonition %}` each strip as their OWN span rather than one tag's
|
|
9
|
-
* opener swallowing everything up to the other tag's closer -- which would
|
|
10
|
-
* delete the prose BETWEEN them too.
|
|
11
|
-
*
|
|
12
|
-
* Only used when markdoc parsing is off. With it on, `maskProse` in
|
|
13
|
-
* scopes/extractor.ts has already found every real `markdocTag` token and
|
|
14
|
-
* recorded its exact span in the segment's `maskedRanges`, so `extractProse`
|
|
15
|
-
* below splices those spans out instead of re-discovering tags with this
|
|
16
|
-
* regex. The regex is still needed with the flag off: the parser doesn't
|
|
17
|
-
* recognize tags at all in that mode, so `{% ... %}` is just ordinary text and
|
|
18
|
-
* nothing else keeps it out of the readability formulas.
|
|
19
|
-
*/
|
|
20
|
-
const MARKDOC_TAG_RE = /\{%-?[\s\S]*?-?%\}/g;
|
|
21
|
-
/**
|
|
22
|
-
* Strips markup that is never readable prose (Markdoc tag markers, inline
|
|
23
|
-
* code spans) from RAW segment text -- i.e. text that has not already been
|
|
24
|
-
* structurally masked, see `MARKDOC_TAG_RE`'s comment. Inline code spans
|
|
25
|
-
* are REMOVED outright (not masked-and-restored like
|
|
26
|
-
* capitalization.ts/spelling.ts do): there is no position-sensitive rewrite
|
|
27
|
-
* downstream to keep offsets aligned for, just a word/syllable count that
|
|
28
|
-
* must never include a code span's content. BACKTICK_SPAN_RE
|
|
29
|
-
* (core/inline-code.ts) gives this the same CommonMark-correct
|
|
30
|
-
* open-run/close-run-of-equal-length span recognition capitalization.ts and
|
|
31
|
-
* spelling.ts use, including a span whose content itself contains a
|
|
32
|
-
* shorter, unpaired backtick run. Exported for direct unit testing.
|
|
33
|
-
*/
|
|
34
|
-
export function stripNonProse(text) {
|
|
35
|
-
return text.replace(MARKDOC_TAG_RE, '').replace(BACKTICK_SPAN_RE, '');
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Counterpart to `stripNonProse` for a masked segment: its tag spans are
|
|
39
|
-
* already known exactly (`segment.maskedRanges`, set by `maskProse` only when
|
|
40
|
-
* it actually blanked something), so this splices each span out of `content`
|
|
41
|
-
* rather than leaving the mask's same-width spaces in place.
|
|
42
|
-
*
|
|
43
|
-
* Deletion, not blanking, matters here. `length.ts`'s `measure()` only needs a
|
|
44
|
-
* width to subtract from a character count, so reading through the mask as if
|
|
45
|
-
* it were whitespace is harmless there. `metric` tokenizes words by splitting
|
|
46
|
-
* on whitespace, so mask spaces are not interchangeable with deletion whenever
|
|
47
|
-
* a tag sits flush against real text with no separating space — for example
|
|
48
|
-
* `<code>{% $optionName %}</code>`, a shape that occurs in the repo's own docs.
|
|
49
|
-
* Left as mask spaces, `<code>` and `</code>` tokenize as two separate words;
|
|
50
|
-
* deleting the span joins them back into the single adjacent run they actually
|
|
51
|
-
* are. Splicing reproduces exactly what the regex strip did on unmasked source.
|
|
52
|
-
*/
|
|
53
|
-
function spliceOutMaskedSpans(segment) {
|
|
54
|
-
const ranges = segment.maskedRanges;
|
|
55
|
-
if (ranges === undefined)
|
|
56
|
-
return segment.content;
|
|
57
|
-
let result = '';
|
|
58
|
-
let cursor = 0;
|
|
59
|
-
for (const range of ranges) {
|
|
60
|
-
// `maskedRanges` is produced ascending and non-overlapping (maskProse
|
|
61
|
-
// sorts and clamps; shiftRanges preserves order). The clamp here mirrors
|
|
62
|
-
// maskProse's own defense: an out-of-order range would otherwise move
|
|
63
|
-
// `cursor` backward and re-emit already-copied characters.
|
|
64
|
-
result += segment.content.slice(cursor, Math.max(range.start, cursor));
|
|
65
|
-
cursor = Math.max(range.end, cursor);
|
|
66
|
-
}
|
|
67
|
-
return result + segment.content.slice(cursor);
|
|
68
|
-
}
|
|
3
|
+
import { extractProse, stripNonProse } from '../../core/prose-extract.js';
|
|
4
|
+
// Re-exported so existing direct unit tests keep their import path; the
|
|
5
|
+
// implementation lives in core/prose-extract.ts, shared with the
|
|
6
|
+
// `recheck readability` command.
|
|
7
|
+
export { stripNonProse };
|
|
69
8
|
const FALLBACK_MESSAGE = 'Readability (%s) is %s; expected between %s and %s.';
|
|
70
|
-
// Compares two (line, column) source positions the way source order does:
|
|
71
|
-
// earlier line first, then earlier column on the same line.
|
|
72
|
-
function comparePosition(aLine, aColumn, bLine, bColumn) {
|
|
73
|
-
return aLine - bLine || aColumn - bColumn;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Whether `outer`'s span fully contains `inner`'s -- `outer` starts at or
|
|
77
|
-
* before `inner` and ends at or after it. `startLine`/`startColumn`/
|
|
78
|
-
* `endLine`/`endColumn` are already the exact verbatim source span each
|
|
79
|
-
* segment's `content` covers (see extractor.ts's `segmentFromToken` and the
|
|
80
|
-
* `tableRow` case's explicit anchor/trim arithmetic), so containment can be
|
|
81
|
-
* decided directly from those four numbers -- no separate span needs
|
|
82
|
-
* re-deriving from `content` (e.g. via counting newlines) here.
|
|
83
|
-
*/
|
|
84
|
-
function spanContains(outer, inner) {
|
|
85
|
-
return (comparePosition(outer.startLine, outer.startColumn, inner.startLine, inner.startColumn) <= 0 &&
|
|
86
|
-
comparePosition(outer.endLine, outer.endColumn, inner.endLine, inner.endColumn) >= 0);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Dedupes prose segments whose source span is fully nested inside another
|
|
90
|
-
* kept segment's span. A list nested inside a blockquote emits BOTH the
|
|
91
|
-
* blockquote segment (its whole raw body, list markup and all) AND each
|
|
92
|
-
* list-item segment (the same words again, just the item's own subspan);
|
|
93
|
-
* a blockquote nested inside another blockquote is the same shape one
|
|
94
|
-
* level up. Left uncaught, the nested words are scored twice and
|
|
95
|
-
* readability drifts. The old dedup only matched IDENTICAL start
|
|
96
|
-
* positions, which misses every one of these cases (the nested segment
|
|
97
|
-
* starts later than its container).
|
|
98
|
-
*
|
|
99
|
-
* Segments are sorted by (startLine, startColumn) ascending so a container
|
|
100
|
-
* is always visited before anything nested inside it; ties (a container
|
|
101
|
-
* and its first child starting at the exact same position, e.g. a
|
|
102
|
-
* blockquote and its very first list item) are broken by span
|
|
103
|
-
* DESCENDING -- the later-ending segment first -- so the outer container is
|
|
104
|
-
* always the one considered "already kept" when its nested sibling is
|
|
105
|
-
* checked, never the other way around.
|
|
106
|
-
*
|
|
107
|
-
* `stack` holds the chain of still-open containers, innermost last. Only
|
|
108
|
-
* the top is ever checked against a new candidate: markdown block spans
|
|
109
|
-
* form a laminar family (any two are either disjoint or one fully
|
|
110
|
-
* contains the other, never a partial "crossing" overlap), so once
|
|
111
|
-
* containers whose span has already ended (`end < candidate.start`) are
|
|
112
|
-
* popped off, the remaining top is the ONLY still-open span the next
|
|
113
|
-
* candidate could possibly nest inside. This is what keeps same-line
|
|
114
|
-
* SIBLINGS with disjoint spans (e.g. two table cells on one row) safe:
|
|
115
|
-
* each one's span ends before the next one's begins, so it is popped
|
|
116
|
-
* before the next is checked, and neither is ever mistaken for containing
|
|
117
|
-
* the other.
|
|
118
|
-
*/
|
|
119
|
-
function dedupeBySpanContainment(segments) {
|
|
120
|
-
const ordered = [...segments].sort((a, b) => {
|
|
121
|
-
const byStart = comparePosition(a.startLine, a.startColumn, b.startLine, b.startColumn);
|
|
122
|
-
if (byStart !== 0)
|
|
123
|
-
return byStart;
|
|
124
|
-
return comparePosition(b.endLine, b.endColumn, a.endLine, a.endColumn);
|
|
125
|
-
});
|
|
126
|
-
const stack = [];
|
|
127
|
-
const kept = [];
|
|
128
|
-
for (const segment of ordered) {
|
|
129
|
-
while (stack.length > 0) {
|
|
130
|
-
const top = stack[stack.length - 1];
|
|
131
|
-
if (comparePosition(top.endLine, top.endColumn, segment.startLine, segment.startColumn) < 0) {
|
|
132
|
-
stack.pop();
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
const container = stack[stack.length - 1];
|
|
139
|
-
if (container && spanContains(container, segment))
|
|
140
|
-
continue;
|
|
141
|
-
kept.push(segment);
|
|
142
|
-
stack.push(segment);
|
|
143
|
-
}
|
|
144
|
-
return kept;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Builds the whole-document prose string `metric` scores against, from
|
|
148
|
-
* `ctx.segments`.
|
|
149
|
-
*
|
|
150
|
-
* `metric` rules are always summary-scoped: config normalization
|
|
151
|
-
* (config/validate.ts, normalizeMetricScope) forces `scope: 'summary'` on
|
|
152
|
-
* every rule with a `metric` assertion — readability is a whole-document
|
|
153
|
-
* score over the document's prose, exactly what the extractor's `summary`
|
|
154
|
-
* segments carry — so `ctx.segments` arrives as those summary segments and
|
|
155
|
-
* no scope re-extraction happens here. See the README's `metric` entry.
|
|
156
|
-
*/
|
|
157
|
-
function extractProse(ctx) {
|
|
158
|
-
// Readability is a property of flowing prose, so headings are excluded --
|
|
159
|
-
// fragment headings carry no terminal punctuation and read as sentence
|
|
160
|
-
// fragments, which standard tools (Lexi et al.) strip before scoring. The
|
|
161
|
-
// OTHER summary-scoped rules keep seeing headings; only the metric's prose
|
|
162
|
-
// view narrows.
|
|
163
|
-
const proseSegments = ctx.segments.filter((segment) => !segment.sourceScope?.startsWith('heading.'));
|
|
164
|
-
// Span-containment dedup: a segment fully nested inside another kept
|
|
165
|
-
// segment's source span must not have its text counted a second time --
|
|
166
|
-
// see dedupeBySpanContainment. The extractor already avoids the most
|
|
167
|
-
// common case on its own (see its `isNestedContainerParagraph`), but
|
|
168
|
-
// this catches every other overlap among the summary segments too
|
|
169
|
-
// (e.g. a list nested inside a blockquote).
|
|
170
|
-
const deduped = dedupeBySpanContainment(proseSegments);
|
|
171
|
-
// Re-sort explicitly so the joined prose's sentence order can never
|
|
172
|
-
// depend on the extractor's traversal order (or dedupeBySpanContainment's
|
|
173
|
-
// own tie-breaking order, which favors span DESC, not source order).
|
|
174
|
-
deduped.sort((a, b) => a.startLine - b.startLine || a.startColumn - b.startColumn);
|
|
175
|
-
return deduped
|
|
176
|
-
.map((segment) => segment.maskedRanges !== undefined
|
|
177
|
-
? // This segment's tag spans are already known exactly, so splice them
|
|
178
|
-
// out directly instead of re-discovering them with MARKDOC_TAG_RE,
|
|
179
|
-
// which couldn't match them anyway now that their `{`/`%` characters
|
|
180
|
-
// are mask spaces. Backtick stripping still runs: masking never
|
|
181
|
-
// touches inline code spans.
|
|
182
|
-
spliceOutMaskedSpans(segment).replace(BACKTICK_SPAN_RE, '')
|
|
183
|
-
: // Markdoc parsing off, or a tag the extractor never recognized as one
|
|
184
|
-
// (e.g. written inside an inline code span): content still carries
|
|
185
|
-
// whatever raw markup it always did, so fall back to the regex-based
|
|
186
|
-
// strip.
|
|
187
|
-
stripNonProse(segment.content))
|
|
188
|
-
.filter((text) => text.trim() !== '');
|
|
189
|
-
}
|
|
190
9
|
const execute = async (rule, file, ctx) => {
|
|
191
10
|
const options = rule.assertions['metric'];
|
|
11
|
+
// `metric` rules are always summary-scoped: config normalization
|
|
12
|
+
// (config/validate.ts, normalizeMetricScope) forces `scope: 'summary'`, so
|
|
13
|
+
// `ctx.segments` arrives as the extractor's summary segments and
|
|
14
|
+
// core/prose-extract.ts turns them into readable prose blocks.
|
|
15
|
+
//
|
|
192
16
|
// Statistics are computed PER BLOCK and summed, so a block's end is an
|
|
193
17
|
// unconditional sentence end. Appending punctuation and re-splitting the
|
|
194
18
|
// joined text was not enough: the shared splitter's boundary rule
|
|
@@ -196,7 +20,7 @@ const execute = async (rule, file, ctx) => {
|
|
|
196
20
|
// boundaries whose next word was lowercase or numeric, or whose last word
|
|
197
21
|
// doubled as an abbreviation such as 'max'. Inside a block, the splitter's
|
|
198
22
|
// rule still governs -- that part is genuine prose.
|
|
199
|
-
const blocks = extractProse(ctx);
|
|
23
|
+
const blocks = extractProse(ctx.segments);
|
|
200
24
|
const stats = blocks.map(computeTextStatistics).reduce((sum, one) => ({
|
|
201
25
|
words: sum.words + one.words,
|
|
202
26
|
sentences: sum.sentences + one.sentences,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metric.js","sourceRoot":"","sources":["../../../src/rules/scope/metric.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"metric.js","sourceRoot":"","sources":["../../../src/rules/scope/metric.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE1E,wEAAwE;AACxE,iEAAiE;AACjE,iCAAiC;AACjC,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,MAAM,gBAAgB,GAAG,qDAAqD,CAAC;AAE/E,MAAM,OAAO,GAAG,KAAK,EACnB,IAAoB,EACpB,IAAY,EACZ,GAAqB,EACD,EAAE;IACtB,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAoB,CAAC;IAC7D,iEAAiE;IACjE,2EAA2E;IAC3E,iEAAiE;IACjE,+DAA+D;IAC/D,EAAE;IACF,uEAAuE;IACvE,yEAAyE;IACzE,kEAAkE;IAClE,wEAAwE;IACxE,0EAA0E;IAC1E,2EAA2E;IAC3E,oDAAoD;IACpD,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,MAAM,CACpD,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QACb,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK;QAC5B,SAAS,EAAE,GAAG,CAAC,SAA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AC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EACtD,OAAO,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CACtD;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAc,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semantic-line-breaks.d.ts","sourceRoot":"","sources":["../../../src/rules/scope/semantic-line-breaks.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAoB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"semantic-line-breaks.d.ts","sourceRoot":"","sources":["../../../src/rules/scope/semantic-line-breaks.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAoB,MAAM,aAAa,CAAC;AAuQ/D,eAAO,MAAM,kBAAkB,EAAE,SAKhC,CAAC"}
|
|
@@ -2,31 +2,39 @@ import { filterByTypes } from '../../parser/index.js';
|
|
|
2
2
|
import { addRangeToSet } from '../token/helpers.js';
|
|
3
3
|
import { newLineRe } from '../../core/line-endings.js';
|
|
4
4
|
import { splitSentences } from '../../scopes/sentences.js';
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
// One real CommonMark list marker with its required spacing. The spacing
|
|
6
|
+
// keeps prose starting with emphasis (`*text*`), a non-list dash
|
|
7
|
+
// (`-3 degrees`), or a decimal (`1.5 million`) out of this match. Lettered
|
|
8
|
+
// markers (`a.`) are absent: micromark never parses them as lists.
|
|
9
|
+
const SINGLE_MARKER_RE = /^(?:[-*+]|\d+\.)[ \t]+/;
|
|
10
|
+
// Lettered pseudo-markers (`- a. Text`): splitSentences reads `a.` as a
|
|
11
|
+
// sentence boundary and --fix would sever it from its own text. They are
|
|
12
|
+
// not CommonMark markers, so they cannot be stripped like nested numbered
|
|
13
|
+
// markers; the whole line is skipped instead.
|
|
14
|
+
const PSEUDO_MARKER_RE = /^[a-zA-Z]\.[ \t]/;
|
|
15
|
+
// Length of the whole list-marker prefix: blockquote markers, indent, then
|
|
16
|
+
// every directly nested real marker (`- 1. text` consumes `- 1. `). Nested
|
|
17
|
+
// markers strip iteratively so whole-file runs and scoped runs (which get
|
|
18
|
+
// outer markers pre-stripped by token boundaries) reduce to the same text.
|
|
19
|
+
function listMarkerLength(lineText) {
|
|
20
|
+
const prefix = lineText.match(/^\s*(?:>\s*)*/)?.[0].length ?? 0;
|
|
21
|
+
let length = prefix;
|
|
22
|
+
let marker = lineText.slice(length).match(SINGLE_MARKER_RE);
|
|
23
|
+
if (!marker)
|
|
24
|
+
return 0;
|
|
25
|
+
while (marker) {
|
|
26
|
+
length += marker[0].length;
|
|
27
|
+
marker = lineText.slice(length).match(SINGLE_MARKER_RE);
|
|
28
|
+
}
|
|
29
|
+
return length;
|
|
30
|
+
}
|
|
24
31
|
function isSkippableLine(lineText) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
if (lineText.trim() === '' || lineText.startsWith('#'))
|
|
33
|
+
return true;
|
|
34
|
+
const markerLength = listMarkerLength(lineText);
|
|
35
|
+
if (markerLength > 0)
|
|
36
|
+
return PSEUDO_MARKER_RE.test(lineText.slice(markerLength));
|
|
37
|
+
return /^\s*[a-zA-Z]\.\s/.test(lineText);
|
|
30
38
|
}
|
|
31
39
|
function calculateContinuationIndent(line) {
|
|
32
40
|
// Peel off the blockquote prefix first: leading whitespace plus one or
|
|
@@ -41,21 +49,31 @@ function calculateContinuationIndent(line) {
|
|
|
41
49
|
const blockquotePrefix = line.match(/^(\s*(?:>\s*)+)/)?.[1] ?? '';
|
|
42
50
|
const remainder = line.slice(blockquotePrefix.length);
|
|
43
51
|
const leadingWhitespace = remainder.match(/^(\s*)/)?.[1] || '';
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
// continuation under
|
|
52
|
+
// Markers must not repeat on continuation lines (that would create new
|
|
53
|
+
// list items), so they are replaced by spaces of equal width. They
|
|
54
|
+
// consume iteratively, matching listMarkerLength, so a nested `- 1. text`
|
|
55
|
+
// line aligns its continuation under `text`.
|
|
48
56
|
const listMarkers = [
|
|
49
57
|
/^(\s*[-*+]\s)/, // Bullet points (all three CommonMark markers, matching isSkippableLine)
|
|
50
58
|
/^(\s*\d+\.\s)/, // Numbered lists
|
|
51
59
|
/^(\s*[a-zA-Z]\.\s)/, // Letter lists
|
|
52
60
|
];
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
let markerRegionWidth = 0;
|
|
62
|
+
let consumed = true;
|
|
63
|
+
while (consumed) {
|
|
64
|
+
consumed = false;
|
|
65
|
+
for (const pattern of listMarkers) {
|
|
66
|
+
const match = remainder.slice(markerRegionWidth).match(pattern);
|
|
67
|
+
if (match) {
|
|
68
|
+
markerRegionWidth += match[1].length;
|
|
69
|
+
consumed = true;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
57
72
|
}
|
|
58
73
|
}
|
|
74
|
+
if (markerRegionWidth > 0) {
|
|
75
|
+
return blockquotePrefix + ' '.repeat(markerRegionWidth);
|
|
76
|
+
}
|
|
59
77
|
return blockquotePrefix + leadingWhitespace;
|
|
60
78
|
}
|
|
61
79
|
// Shared by execute() and fix() so both apply the exact same gate: with
|
|
@@ -124,7 +142,9 @@ const execute = async (rule, file, ctx) => {
|
|
|
124
142
|
if (isIgnoredLine(lineText, lineNumber, options, ignoredLines))
|
|
125
143
|
continue;
|
|
126
144
|
if (isSentenceMode(options)) {
|
|
127
|
-
|
|
145
|
+
// Count sentences after the marker: an ordered marker's own `1.`
|
|
146
|
+
// would otherwise register as a sentence boundary.
|
|
147
|
+
const sentenceCount = splitSentences(lineText.slice(listMarkerLength(lineText))).length;
|
|
128
148
|
if (sentenceCount > 1) {
|
|
129
149
|
problems.push({
|
|
130
150
|
file,
|
|
@@ -156,7 +176,10 @@ const fix = async (rule, file, ctx) => {
|
|
|
156
176
|
const lineNumber = segment.startLine + lineIndex;
|
|
157
177
|
if (isIgnoredLine(lineText, lineNumber, options, ignoredLines))
|
|
158
178
|
continue;
|
|
159
|
-
|
|
179
|
+
// Same marker strip as execute(); markerLength shifts the sentence
|
|
180
|
+
// spans back to line positions.
|
|
181
|
+
const markerLength = listMarkerLength(lineText);
|
|
182
|
+
const sentences = splitSentences(lineText.slice(markerLength));
|
|
160
183
|
if (sentences.length <= 1)
|
|
161
184
|
continue;
|
|
162
185
|
// The replacement is applied with deleteCount: -1 (whole-line
|
|
@@ -186,7 +209,7 @@ const fix = async (rule, file, ctx) => {
|
|
|
186
209
|
// leading whitespace on the line is gone from `.text` with nowhere to
|
|
187
210
|
// go back to. Continuation lines are unaffected -- they were never
|
|
188
211
|
// built from the original line's own prefix in the first place.
|
|
189
|
-
const firstLinePrefix = rawLine.slice(0, prefixOffset + firstSentence.start);
|
|
212
|
+
const firstLinePrefix = rawLine.slice(0, prefixOffset + markerLength + firstSentence.start);
|
|
190
213
|
const newLinesForThisLine = [
|
|
191
214
|
firstLinePrefix + firstSentence.text,
|
|
192
215
|
...continuationSentences.map((sentence) => indentation + sentence.text),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semantic-line-breaks.js","sourceRoot":"","sources":["../../../src/rules/scope/semantic-line-breaks.ts"],"names":[],"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2B,CAAC,OAAO,CAAC,CAAC;YAEzD,MAAM,CAAC,aAAa,EAAE,GAAG,qBAAqB,CAAC,GAAG,SAAS,CAAC;YAC5D,oEAAoE;YACpE,kEAAkE;YAClE,sEAAsE;YACtE,sEAAsE;YACtE,sEAAsE;YACtE,mEAAmE;YACnE,gEAAgE;YAChE,MAAM,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,GAAG,YAAY,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;YAC5F,MAAM,mBAAmB,GAAG;gBAC1B,eAAe,GAAG,aAAa,CAAC,IAAI;gBACpC,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC;aACxE,CAAC;YAEF,MAAM,OAAO,GAAG,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAE/C,KAAK,CAAC,IAAI,CAAC;gBACT,IAAI;gBACJ,QAAQ,EAAE,IAAI,CAAC,IAAI;gBACnB,UAAU;gBACV,UAAU,EAAE,CAAC;gBACb,WAAW,EAAE,CAAC,CAAC;gBACf,UAAU,EAAE,OAAO;aACpB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAc;IAC3C,EAAE,EAAE,sBAAsB;IAC1B,OAAO,EAAE,IAAI;IACb,OAAO;IACP,GAAG;CACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-fragments.d.ts","sourceRoot":"","sources":["../../../src/rules/token/link-fragments.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"link-fragments.d.ts","sourceRoot":"","sources":["../../../src/rules/token/link-fragments.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAkU7C,eAAO,MAAM,aAAa,EAAE,SAc3B,CAAC"}
|