@redocly/recheck 0.14.0 → 2.58.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 +71 -1869
- package/examples/appendices/google.appendix.yaml +1 -1
- package/examples/appendices/inclusive-language.appendix.yaml +1 -1
- package/examples/appendices/microsoft.appendix.yaml +1 -1
- package/examples/appendices/plain-language.appendix.yaml +1 -1
- package/examples/appendices/technical-english.appendix.yaml +1 -1
- package/examples/google.yaml +7 -7
- package/examples/inclusive-language.yaml +7 -7
- package/examples/microsoft.yaml +7 -7
- package/examples/plain-language.yaml +7 -7
- package/examples/technical-english.yaml +7 -7
- package/lib/actions/baseline.d.ts +15 -0
- package/lib/actions/baseline.d.ts.map +1 -0
- package/lib/actions/baseline.js +51 -0
- package/lib/actions/baseline.js.map +1 -0
- package/lib/actions/lint.d.ts +51 -0
- package/lib/actions/lint.d.ts.map +1 -0
- package/lib/actions/lint.js +123 -0
- package/lib/actions/lint.js.map +1 -0
- package/lib/actions/markdoc-schema.d.ts +34 -0
- package/lib/actions/markdoc-schema.d.ts.map +1 -0
- package/lib/actions/markdoc-schema.js +106 -0
- package/lib/actions/markdoc-schema.js.map +1 -0
- package/lib/actions/readability.d.ts +25 -0
- package/lib/actions/readability.d.ts.map +1 -0
- package/lib/actions/readability.js +47 -0
- package/lib/actions/readability.js.map +1 -0
- package/lib/actions/roots.d.ts +7 -0
- package/lib/actions/roots.d.ts.map +1 -0
- package/lib/actions/roots.js +36 -0
- package/lib/actions/roots.js.map +1 -0
- package/lib/config/presets/api-descriptions.d.ts +8 -0
- package/lib/config/presets/api-descriptions.d.ts.map +1 -0
- package/lib/config/presets/api-descriptions.js +24 -0
- package/lib/config/presets/api-descriptions.js.map +1 -0
- package/lib/config/presets/google.d.ts +3 -0
- package/lib/config/presets/google.d.ts.map +1 -0
- package/lib/config/presets/google.js +1086 -0
- package/lib/config/presets/google.js.map +1 -0
- package/lib/config/presets/inclusive-language.d.ts +3 -0
- package/lib/config/presets/inclusive-language.d.ts.map +1 -0
- package/lib/config/presets/inclusive-language.js +151 -0
- package/lib/config/presets/inclusive-language.js.map +1 -0
- package/lib/config/presets/index.d.ts +16 -0
- package/lib/config/presets/index.d.ts.map +1 -0
- package/lib/config/presets/index.js +38 -0
- package/lib/config/presets/index.js.map +1 -0
- package/lib/config/presets/markdoc.d.ts +3 -0
- package/lib/config/presets/markdoc.d.ts.map +1 -0
- package/lib/config/presets/markdoc.js +45 -0
- package/lib/config/presets/markdoc.js.map +1 -0
- package/lib/config/presets/markdown-relaxed.d.ts +3 -0
- package/lib/config/presets/markdown-relaxed.d.ts.map +1 -0
- package/lib/config/presets/markdown-relaxed.js +34 -0
- package/lib/config/presets/markdown-relaxed.js.map +1 -0
- package/lib/config/presets/markdown.d.ts +11 -0
- package/lib/config/presets/markdown.d.ts.map +1 -0
- package/lib/config/presets/markdown.js +73 -0
- package/lib/config/presets/markdown.js.map +1 -0
- package/lib/config/presets/microsoft.d.ts +3 -0
- package/lib/config/presets/microsoft.d.ts.map +1 -0
- package/lib/config/presets/microsoft.js +1260 -0
- package/lib/config/presets/microsoft.js.map +1 -0
- package/lib/config/presets/minimal.d.ts +3 -0
- package/lib/config/presets/minimal.d.ts.map +1 -0
- package/lib/config/presets/minimal.js +13 -0
- package/lib/config/presets/minimal.js.map +1 -0
- package/lib/config/presets/plain-language.d.ts +3 -0
- package/lib/config/presets/plain-language.d.ts.map +1 -0
- package/lib/config/presets/plain-language.js +175 -0
- package/lib/config/presets/plain-language.js.map +1 -0
- package/lib/config/presets/prose.d.ts +3 -0
- package/lib/config/presets/prose.d.ts.map +1 -0
- package/lib/config/presets/prose.js +60 -0
- package/lib/config/presets/prose.js.map +1 -0
- package/lib/config/presets/technical-english.d.ts +22 -0
- package/lib/config/presets/technical-english.d.ts.map +1 -0
- package/lib/config/presets/technical-english.js +61 -0
- package/lib/config/presets/technical-english.js.map +1 -0
- package/lib/config/resolve.d.ts +36 -0
- package/lib/config/resolve.d.ts.map +1 -0
- package/lib/config/resolve.js +106 -0
- package/lib/config/resolve.js.map +1 -0
- package/lib/config/schema.d.ts +215 -0
- package/lib/config/schema.d.ts.map +1 -0
- package/lib/config/schema.js +152 -0
- package/lib/config/schema.js.map +1 -0
- package/lib/config/validate.d.ts +19 -0
- package/lib/config/validate.d.ts.map +1 -0
- package/lib/config/validate.js +1049 -0
- package/lib/config/validate.js.map +1 -0
- package/lib/core/auto-fix.d.ts.map +1 -0
- package/lib/core/auto-fix.js +94 -0
- package/lib/core/auto-fix.js.map +1 -0
- package/lib/core/baseline.d.ts +43 -0
- package/lib/core/baseline.d.ts.map +1 -0
- package/lib/core/baseline.js +142 -0
- package/lib/core/baseline.js.map +1 -0
- package/lib/core/case-preserve.d.ts +11 -0
- package/lib/core/case-preserve.d.ts.map +1 -0
- package/lib/core/case-preserve.js +22 -0
- package/lib/core/case-preserve.js.map +1 -0
- package/lib/core/directives.d.ts.map +1 -0
- package/lib/core/directives.js +66 -0
- package/lib/core/directives.js.map +1 -0
- package/lib/core/files.d.ts +31 -0
- package/lib/core/files.d.ts.map +1 -0
- package/lib/core/files.js +184 -0
- package/lib/core/files.js.map +1 -0
- package/lib/core/inline-code.d.ts +33 -0
- package/lib/core/inline-code.d.ts.map +1 -0
- package/lib/core/inline-code.js +50 -0
- package/lib/core/inline-code.js.map +1 -0
- package/lib/core/line-endings.d.ts +13 -0
- package/lib/core/line-endings.d.ts.map +1 -0
- package/lib/core/line-endings.js +39 -0
- package/lib/core/line-endings.js.map +1 -0
- package/lib/core/markdoc-tags.d.ts +48 -0
- package/lib/core/markdoc-tags.d.ts.map +1 -0
- package/lib/core/markdoc-tags.js +102 -0
- package/lib/core/markdoc-tags.js.map +1 -0
- package/lib/core/prose-extract.d.ts +6 -0
- package/lib/core/prose-extract.d.ts.map +1 -0
- package/lib/core/prose-extract.js +71 -0
- package/lib/core/prose-extract.js.map +1 -0
- package/lib/core/readability.d.ts +17 -0
- package/lib/core/readability.d.ts.map +1 -0
- package/lib/core/readability.js +34 -0
- package/lib/core/readability.js.map +1 -0
- package/lib/core/rule-filters.d.ts +29 -0
- package/lib/core/rule-filters.d.ts.map +1 -0
- package/lib/core/rule-filters.js +88 -0
- package/lib/core/rule-filters.js.map +1 -0
- package/lib/core/runner.d.ts +60 -0
- package/lib/core/runner.d.ts.map +1 -0
- package/lib/core/runner.js +305 -0
- package/lib/core/runner.js.map +1 -0
- package/lib/core/summary.d.ts +4 -0
- package/lib/core/summary.d.ts.map +1 -0
- package/lib/core/summary.js +37 -0
- package/lib/core/summary.js.map +1 -0
- package/lib/core/timing.d.ts +9 -0
- package/lib/core/timing.d.ts.map +1 -0
- package/lib/core/timing.js +19 -0
- package/lib/core/timing.js.map +1 -0
- package/lib/data/markdoc-realm-schema.d.ts.map +1 -0
- package/lib/data/markdoc-realm-schema.js +782 -0
- package/lib/data/markdoc-realm-schema.js.map +1 -0
- package/lib/data/proper-nouns.d.ts.map +1 -0
- package/lib/data/proper-nouns.js +42 -0
- package/lib/data/proper-nouns.js.map +1 -0
- package/lib/data/realm-front-matter-schema.d.ts +12 -0
- package/lib/data/realm-front-matter-schema.d.ts.map +1 -0
- package/lib/data/realm-front-matter-schema.js +51 -0
- package/lib/data/realm-front-matter-schema.js.map +1 -0
- package/lib/index.d.ts +81 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +114 -0
- package/lib/index.js.map +1 -0
- package/lib/metrics/formulas.d.ts +9 -0
- package/lib/metrics/formulas.d.ts.map +1 -0
- package/lib/metrics/formulas.js +59 -0
- package/lib/metrics/formulas.js.map +1 -0
- package/lib/metrics/statistics.d.ts +14 -0
- package/lib/metrics/statistics.d.ts.map +1 -0
- package/lib/metrics/statistics.js +35 -0
- package/lib/metrics/statistics.js.map +1 -0
- package/lib/parser/index.d.ts +13 -0
- package/lib/parser/index.d.ts.map +1 -0
- package/lib/parser/index.js +123 -0
- package/lib/parser/index.js.map +1 -0
- package/lib/parser/markdoc/extract-statics.d.ts +28 -0
- package/lib/parser/markdoc/extract-statics.d.ts.map +1 -0
- package/lib/parser/markdoc/extract-statics.js +80 -0
- package/lib/parser/markdoc/extract-statics.js.map +1 -0
- package/lib/parser/markdoc/pairing.d.ts +38 -0
- package/lib/parser/markdoc/pairing.d.ts.map +1 -0
- package/lib/parser/markdoc/pairing.js +77 -0
- package/lib/parser/markdoc/pairing.js.map +1 -0
- package/lib/parser/markdoc/schema.d.ts +56 -0
- package/lib/parser/markdoc/schema.d.ts.map +1 -0
- package/lib/parser/markdoc/schema.js +60 -0
- package/lib/parser/markdoc/schema.js.map +1 -0
- package/lib/parser/markdoc/span.d.ts +52 -0
- package/lib/parser/markdoc/span.d.ts.map +1 -0
- package/lib/parser/markdoc/span.js +577 -0
- package/lib/parser/markdoc/span.js.map +1 -0
- package/lib/parser/markdoc/structure.d.ts +17 -0
- package/lib/parser/markdoc/structure.d.ts.map +1 -0
- package/lib/parser/markdoc/structure.js +121 -0
- package/lib/parser/markdoc/structure.js.map +1 -0
- package/lib/parser/markdoc/syntax.d.ts +17 -0
- package/lib/parser/markdoc/syntax.d.ts.map +1 -0
- package/lib/parser/markdoc/syntax.js +262 -0
- package/lib/parser/markdoc/syntax.js.map +1 -0
- package/lib/parser/types.d.ts.map +1 -0
- package/lib/presets.d.ts +6 -0
- package/lib/presets.d.ts.map +1 -0
- package/lib/presets.js +12 -0
- package/lib/presets.js.map +1 -0
- package/lib/rules/registry.d.ts +13 -0
- package/lib/rules/registry.d.ts.map +1 -0
- package/lib/rules/registry.js +54 -0
- package/lib/rules/registry.js.map +1 -0
- package/lib/rules/scope/capitalization.d.ts.map +1 -0
- package/lib/rules/scope/capitalization.js +128 -0
- package/lib/rules/scope/capitalization.js.map +1 -0
- package/lib/rules/scope/conditional.d.ts.map +1 -0
- package/lib/rules/scope/conditional.js +93 -0
- package/lib/rules/scope/conditional.js.map +1 -0
- package/lib/rules/scope/consistency.d.ts.map +1 -0
- package/lib/rules/scope/consistency.js +118 -0
- package/lib/rules/scope/consistency.js.map +1 -0
- package/lib/rules/scope/length.d.ts.map +1 -0
- package/lib/rules/scope/length.js +50 -0
- package/lib/rules/scope/length.js.map +1 -0
- package/lib/rules/scope/max-image-size.d.ts.map +1 -0
- package/lib/rules/scope/max-image-size.js +55 -0
- package/lib/rules/scope/max-image-size.js.map +1 -0
- package/lib/rules/scope/metric.d.ts +3 -0
- package/lib/rules/scope/metric.d.ts.map +1 -0
- package/lib/rules/scope/metric.js +59 -0
- package/lib/rules/scope/metric.js.map +1 -0
- package/lib/rules/scope/occurrence.d.ts.map +1 -0
- package/lib/rules/scope/occurrence.js +41 -0
- package/lib/rules/scope/occurrence.js.map +1 -0
- package/lib/rules/scope/pattern.d.ts.map +1 -0
- package/lib/rules/scope/pattern.js +58 -0
- package/lib/rules/scope/pattern.js.map +1 -0
- package/lib/rules/scope/repetition.d.ts.map +1 -0
- package/lib/rules/scope/repetition.js +134 -0
- package/lib/rules/scope/repetition.js.map +1 -0
- package/lib/rules/scope/semantic-line-breaks.d.ts.map +1 -0
- package/lib/rules/scope/semantic-line-breaks.js +180 -0
- package/lib/rules/scope/semantic-line-breaks.js.map +1 -0
- package/lib/rules/scope/spelling.d.ts +11 -0
- package/lib/rules/scope/spelling.d.ts.map +1 -0
- package/lib/rules/scope/spelling.js +146 -0
- package/lib/rules/scope/spelling.js.map +1 -0
- package/lib/rules/scope/swap.d.ts.map +1 -0
- package/lib/rules/scope/swap.js +111 -0
- package/lib/rules/scope/swap.js.map +1 -0
- package/lib/rules/scope/title-case.d.ts +24 -0
- package/lib/rules/scope/title-case.d.ts.map +1 -0
- package/lib/rules/scope/title-case.js +216 -0
- package/lib/rules/scope/title-case.js.map +1 -0
- package/lib/rules/token/blanks-around-fences.d.ts.map +1 -0
- package/lib/rules/token/blanks-around-fences.js.map +1 -0
- package/lib/rules/token/blanks-around-headings.d.ts.map +1 -0
- package/lib/rules/token/blanks-around-headings.js +96 -0
- package/lib/rules/token/blanks-around-headings.js.map +1 -0
- package/lib/rules/token/blanks-around-lists.d.ts.map +1 -0
- package/lib/rules/token/blanks-around-lists.js +48 -0
- package/lib/rules/token/blanks-around-lists.js.map +1 -0
- package/lib/rules/token/blanks-around-tables.d.ts.map +1 -0
- package/lib/rules/token/blanks-around-tables.js +40 -0
- package/lib/rules/token/blanks-around-tables.js.map +1 -0
- package/lib/rules/token/code-block-style.d.ts.map +1 -0
- package/lib/rules/token/code-block-style.js.map +1 -0
- package/lib/rules/token/code-fence-style.d.ts.map +1 -0
- package/lib/rules/token/code-fence-style.js.map +1 -0
- package/lib/rules/token/commands-show-output.d.ts.map +1 -0
- package/lib/rules/token/commands-show-output.js.map +1 -0
- package/lib/rules/token/descriptive-link-text.d.ts.map +1 -0
- package/lib/rules/token/descriptive-link-text.js +46 -0
- package/lib/rules/token/descriptive-link-text.js.map +1 -0
- package/lib/rules/token/fenced-code-language.d.ts.map +1 -0
- package/lib/rules/token/fenced-code-language.js.map +1 -0
- package/lib/rules/token/first-line-h1.d.ts.map +1 -0
- package/lib/rules/token/first-line-h1.js +83 -0
- package/lib/rules/token/first-line-h1.js.map +1 -0
- package/lib/rules/token/front-matter.d.ts.map +1 -0
- package/lib/rules/token/front-matter.js +169 -0
- package/lib/rules/token/front-matter.js.map +1 -0
- package/lib/rules/token/heading-increment.d.ts.map +1 -0
- package/lib/rules/token/heading-increment.js +26 -0
- package/lib/rules/token/heading-increment.js.map +1 -0
- package/lib/rules/token/heading-start-left.d.ts.map +1 -0
- package/lib/rules/token/heading-start-left.js.map +1 -0
- package/lib/rules/token/heading-style.d.ts.map +1 -0
- package/lib/rules/token/heading-style.js.map +1 -0
- package/lib/rules/token/helpers.d.ts +115 -0
- package/lib/rules/token/helpers.d.ts.map +1 -0
- package/lib/rules/token/helpers.js +502 -0
- package/lib/rules/token/helpers.js.map +1 -0
- package/lib/rules/token/hr-style.d.ts.map +1 -0
- package/lib/rules/token/hr-style.js.map +1 -0
- package/lib/rules/token/index.d.ts +65 -0
- package/lib/rules/token/index.d.ts.map +1 -0
- package/lib/rules/token/index.js +157 -0
- package/lib/rules/token/index.js.map +1 -0
- package/lib/rules/token/line-length.d.ts.map +1 -0
- package/lib/rules/token/line-length.js +96 -0
- package/lib/rules/token/line-length.js.map +1 -0
- package/lib/rules/token/link-fragments.d.ts.map +1 -0
- package/lib/rules/token/link-fragments.js +398 -0
- package/lib/rules/token/link-fragments.js.map +1 -0
- package/lib/rules/token/link-image-reference-definitions.d.ts.map +1 -0
- package/lib/rules/token/link-image-reference-definitions.js.map +1 -0
- package/lib/rules/token/link-image-style.d.ts.map +1 -0
- package/lib/rules/token/link-image-style.js +138 -0
- package/lib/rules/token/link-image-style.js.map +1 -0
- package/lib/rules/token/list-indent.d.ts.map +1 -0
- package/lib/rules/token/list-indent.js.map +1 -0
- package/lib/rules/token/list-length.d.ts.map +1 -0
- package/lib/rules/token/list-length.js +31 -0
- package/lib/rules/token/list-length.js.map +1 -0
- package/lib/rules/token/list-marker-space.d.ts.map +1 -0
- package/lib/rules/token/list-marker-space.js.map +1 -0
- package/lib/rules/token/markdoc-attributes.d.ts.map +1 -0
- package/lib/rules/token/markdoc-attributes.js +198 -0
- package/lib/rules/token/markdoc-attributes.js.map +1 -0
- package/lib/rules/token/markdoc-pairing.d.ts.map +1 -0
- package/lib/rules/token/markdoc-pairing.js +65 -0
- package/lib/rules/token/markdoc-pairing.js.map +1 -0
- package/lib/rules/token/markdoc-syntax.d.ts.map +1 -0
- package/lib/rules/token/markdoc-syntax.js +84 -0
- package/lib/rules/token/markdoc-syntax.js.map +1 -0
- package/lib/rules/token/markdoc-unknown-tag.d.ts.map +1 -0
- package/lib/rules/token/markdoc-unknown-tag.js +44 -0
- package/lib/rules/token/markdoc-unknown-tag.js.map +1 -0
- package/lib/rules/token/no-alt-text.d.ts.map +1 -0
- package/lib/rules/token/no-alt-text.js +43 -0
- package/lib/rules/token/no-alt-text.js.map +1 -0
- package/lib/rules/token/no-bare-urls.d.ts.map +1 -0
- package/lib/rules/token/no-bare-urls.js +74 -0
- package/lib/rules/token/no-bare-urls.js.map +1 -0
- package/lib/rules/token/no-blanks-blockquote.d.ts.map +1 -0
- package/lib/rules/token/no-blanks-blockquote.js.map +1 -0
- package/lib/rules/token/no-duplicate-heading.d.ts.map +1 -0
- package/lib/rules/token/no-duplicate-heading.js +89 -0
- package/lib/rules/token/no-duplicate-heading.js.map +1 -0
- package/lib/rules/token/no-duplicate-link-destinations.d.ts.map +1 -0
- package/lib/rules/token/no-duplicate-link-destinations.js +54 -0
- package/lib/rules/token/no-duplicate-link-destinations.js.map +1 -0
- package/lib/rules/token/no-emphasis-as-heading.d.ts.map +1 -0
- package/lib/rules/token/no-emphasis-as-heading.js +39 -0
- package/lib/rules/token/no-emphasis-as-heading.js.map +1 -0
- package/lib/rules/token/no-empty-headings.d.ts.map +1 -0
- package/lib/rules/token/no-empty-headings.js +21 -0
- package/lib/rules/token/no-empty-headings.js.map +1 -0
- package/lib/rules/token/no-empty-links.d.ts.map +1 -0
- package/lib/rules/token/no-empty-links.js.map +1 -0
- package/lib/rules/token/no-hard-tabs.d.ts.map +1 -0
- package/lib/rules/token/no-hard-tabs.js.map +1 -0
- package/lib/rules/token/no-inline-html.d.ts.map +1 -0
- package/lib/rules/token/no-inline-html.js +41 -0
- package/lib/rules/token/no-inline-html.js.map +1 -0
- package/lib/rules/token/no-multiple-blanks.d.ts.map +1 -0
- package/lib/rules/token/no-multiple-blanks.js.map +1 -0
- package/lib/rules/token/no-multiple-space-atx.d.ts +9 -0
- package/lib/rules/token/no-multiple-space-atx.d.ts.map +1 -0
- package/lib/rules/token/no-multiple-space-atx.js +46 -0
- package/lib/rules/token/no-multiple-space-atx.js.map +1 -0
- package/lib/rules/token/no-multiple-space-closed-atx.d.ts.map +1 -0
- package/lib/rules/token/no-multiple-space-closed-atx.js.map +1 -0
- package/lib/rules/token/no-reversed-links.d.ts.map +1 -0
- package/lib/rules/token/no-reversed-links.js.map +1 -0
- package/lib/rules/token/no-space-in-code.d.ts.map +1 -0
- package/lib/rules/token/no-space-in-code.js.map +1 -0
- package/lib/rules/token/no-space-in-emphasis.d.ts.map +1 -0
- package/lib/rules/token/no-space-in-emphasis.js +72 -0
- package/lib/rules/token/no-space-in-emphasis.js.map +1 -0
- package/lib/rules/token/no-space-in-links.d.ts.map +1 -0
- package/lib/rules/token/no-space-in-links.js.map +1 -0
- package/lib/rules/token/no-trailing-punctuation.d.ts.map +1 -0
- package/lib/rules/token/no-trailing-punctuation.js.map +1 -0
- package/lib/rules/token/no-trailing-spaces.d.ts.map +1 -0
- package/lib/rules/token/no-trailing-spaces.js.map +1 -0
- package/lib/rules/token/ol-prefix.d.ts.map +1 -0
- package/lib/rules/token/ol-prefix.js.map +1 -0
- package/lib/rules/token/proper-names.d.ts.map +1 -0
- package/lib/rules/token/proper-names.js +87 -0
- package/lib/rules/token/proper-names.js.map +1 -0
- package/lib/rules/token/reference-links-images.d.ts.map +1 -0
- package/lib/rules/token/reference-links-images.js.map +1 -0
- package/lib/rules/token/required-headings.d.ts.map +1 -0
- package/lib/rules/token/required-headings.js +73 -0
- package/lib/rules/token/required-headings.js.map +1 -0
- package/lib/rules/token/single-h1.d.ts.map +1 -0
- package/lib/rules/token/single-h1.js +43 -0
- package/lib/rules/token/single-h1.js.map +1 -0
- package/lib/rules/token/table-column-count.d.ts.map +1 -0
- package/lib/rules/token/table-column-count.js.map +1 -0
- package/lib/rules/token/table-column-style.d.ts.map +1 -0
- package/lib/rules/token/table-column-style.js +162 -0
- package/lib/rules/token/table-column-style.js.map +1 -0
- package/lib/rules/token/table-pipe-style.d.ts.map +1 -0
- package/lib/rules/token/table-pipe-style.js.map +1 -0
- package/lib/rules/token/ul-indent.d.ts.map +1 -0
- package/lib/rules/token/ul-indent.js.map +1 -0
- package/lib/rules/token/ul-style.d.ts.map +1 -0
- package/lib/rules/token/ul-style.js +70 -0
- package/lib/rules/token/ul-style.js.map +1 -0
- package/lib/rules/types.d.ts +62 -0
- package/lib/rules/types.d.ts.map +1 -0
- package/lib/rules/utils.d.ts +18 -0
- package/lib/rules/utils.d.ts.map +1 -0
- package/lib/rules/utils.js +75 -0
- package/lib/rules/utils.js.map +1 -0
- package/lib/scopes/extractor.d.ts +6 -0
- package/lib/scopes/extractor.d.ts.map +1 -0
- package/lib/scopes/extractor.js +398 -0
- package/lib/scopes/extractor.js.map +1 -0
- package/lib/scopes/selector.d.ts +26 -0
- package/lib/scopes/selector.d.ts.map +1 -0
- package/lib/scopes/selector.js +78 -0
- package/lib/scopes/selector.js.map +1 -0
- package/lib/scopes/sentences.d.ts +13 -0
- package/lib/scopes/sentences.d.ts.map +1 -0
- package/lib/scopes/sentences.js +237 -0
- package/lib/scopes/sentences.js.map +1 -0
- package/lib/scopes/types.d.ts +35 -0
- package/lib/scopes/types.d.ts.map +1 -0
- package/lib/scopes/vocabulary.d.ts +12 -0
- package/lib/scopes/vocabulary.d.ts.map +1 -0
- package/lib/scopes/vocabulary.js +56 -0
- package/lib/scopes/vocabulary.js.map +1 -0
- package/lib/types/assertions.d.ts +97 -0
- package/lib/types/assertions.d.ts.map +1 -0
- package/lib/types/reporting.d.ts +23 -0
- package/lib/types/reporting.d.ts.map +1 -0
- package/lib/types/rules.d.ts +53 -0
- package/lib/types/rules.d.ts.map +1 -0
- package/lib/types/validation.d.ts +5 -0
- package/lib/types/validation.d.ts.map +1 -0
- package/lib/utils/is-plain-object.d.ts +2 -0
- package/lib/utils/is-plain-object.d.ts.map +1 -0
- package/lib/utils/is-plain-object.js +5 -0
- package/lib/utils/is-plain-object.js.map +1 -0
- package/package.json +58 -61
- package/presets/google/PROVENANCE.md +217 -221
- package/presets/inclusive-language/PROVENANCE.md +20 -19
- package/presets/microsoft/PROVENANCE.md +242 -243
- package/presets/plain-language/PROVENANCE.md +66 -60
- package/presets/technical-english/PROVENANCE.md +5 -5
- package/skills/recheck-config/SKILL.md +70 -20
- package/skills/recheck-lint/SKILL.md +37 -13
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -228
- package/dist/cli.js.map +0 -1
- package/dist/commands/baseline.d.ts +0 -10
- package/dist/commands/baseline.d.ts.map +0 -1
- package/dist/commands/baseline.js +0 -59
- package/dist/commands/baseline.js.map +0 -1
- package/dist/commands/markdoc-schema.d.ts +0 -17
- package/dist/commands/markdoc-schema.d.ts.map +0 -1
- package/dist/commands/markdoc-schema.js +0 -127
- package/dist/commands/markdoc-schema.js.map +0 -1
- package/dist/commands/readability.d.ts +0 -10
- package/dist/commands/readability.d.ts.map +0 -1
- package/dist/commands/readability.js +0 -90
- package/dist/commands/readability.js.map +0 -1
- package/dist/commands/run.d.ts +0 -21
- package/dist/commands/run.d.ts.map +0 -1
- package/dist/commands/run.js +0 -236
- package/dist/commands/run.js.map +0 -1
- package/dist/commands/validate.d.ts +0 -8
- package/dist/commands/validate.d.ts.map +0 -1
- package/dist/commands/validate.js +0 -43
- package/dist/commands/validate.js.map +0 -1
- package/dist/config/load.d.ts +0 -33
- package/dist/config/load.d.ts.map +0 -1
- package/dist/config/load.js +0 -98
- package/dist/config/load.js.map +0 -1
- package/dist/config/presets/api-descriptions.d.ts +0 -8
- package/dist/config/presets/api-descriptions.d.ts.map +0 -1
- package/dist/config/presets/api-descriptions.js +0 -24
- package/dist/config/presets/api-descriptions.js.map +0 -1
- package/dist/config/presets/google.d.ts +0 -3
- package/dist/config/presets/google.d.ts.map +0 -1
- package/dist/config/presets/google.js +0 -1671
- package/dist/config/presets/google.js.map +0 -1
- package/dist/config/presets/inclusive-language.d.ts +0 -3
- package/dist/config/presets/inclusive-language.d.ts.map +0 -1
- package/dist/config/presets/inclusive-language.js +0 -321
- package/dist/config/presets/inclusive-language.js.map +0 -1
- package/dist/config/presets/index.d.ts +0 -67
- package/dist/config/presets/index.d.ts.map +0 -1
- package/dist/config/presets/index.js +0 -141
- package/dist/config/presets/index.js.map +0 -1
- package/dist/config/presets/markdoc.d.ts +0 -21
- package/dist/config/presets/markdoc.d.ts.map +0 -1
- package/dist/config/presets/markdoc.js +0 -101
- package/dist/config/presets/markdoc.js.map +0 -1
- package/dist/config/presets/markdown-relaxed.d.ts +0 -3
- package/dist/config/presets/markdown-relaxed.d.ts.map +0 -1
- package/dist/config/presets/markdown-relaxed.js +0 -98
- package/dist/config/presets/markdown-relaxed.js.map +0 -1
- package/dist/config/presets/markdown.d.ts +0 -43
- package/dist/config/presets/markdown.d.ts.map +0 -1
- package/dist/config/presets/markdown.js +0 -132
- package/dist/config/presets/markdown.js.map +0 -1
- package/dist/config/presets/microsoft.d.ts +0 -3
- package/dist/config/presets/microsoft.d.ts.map +0 -1
- package/dist/config/presets/microsoft.js +0 -2268
- package/dist/config/presets/microsoft.js.map +0 -1
- package/dist/config/presets/minimal.d.ts +0 -3
- package/dist/config/presets/minimal.d.ts.map +0 -1
- package/dist/config/presets/minimal.js +0 -21
- package/dist/config/presets/minimal.js.map +0 -1
- package/dist/config/presets/plain-language.d.ts +0 -3
- package/dist/config/presets/plain-language.d.ts.map +0 -1
- package/dist/config/presets/plain-language.js +0 -351
- package/dist/config/presets/plain-language.js.map +0 -1
- package/dist/config/presets/prose.d.ts +0 -52
- package/dist/config/presets/prose.d.ts.map +0 -1
- package/dist/config/presets/prose.js +0 -138
- package/dist/config/presets/prose.js.map +0 -1
- package/dist/config/presets/technical-english.d.ts +0 -34
- package/dist/config/presets/technical-english.d.ts.map +0 -1
- package/dist/config/presets/technical-english.js +0 -79
- package/dist/config/presets/technical-english.js.map +0 -1
- package/dist/config/schema.d.ts +0 -226
- package/dist/config/schema.d.ts.map +0 -1
- package/dist/config/schema.js +0 -196
- package/dist/config/schema.js.map +0 -1
- package/dist/config/validate.d.ts +0 -22
- package/dist/config/validate.d.ts.map +0 -1
- package/dist/config/validate.js +0 -1296
- package/dist/config/validate.js.map +0 -1
- package/dist/core/auto-fix.d.ts.map +0 -1
- package/dist/core/auto-fix.js +0 -101
- package/dist/core/auto-fix.js.map +0 -1
- package/dist/core/baseline.d.ts +0 -49
- package/dist/core/baseline.d.ts.map +0 -1
- package/dist/core/baseline.js +0 -0
- package/dist/core/baseline.js.map +0 -1
- package/dist/core/case-preserve.d.ts +0 -46
- package/dist/core/case-preserve.d.ts.map +0 -1
- package/dist/core/case-preserve.js +0 -57
- package/dist/core/case-preserve.js.map +0 -1
- package/dist/core/directives.d.ts.map +0 -1
- package/dist/core/directives.js +0 -73
- package/dist/core/directives.js.map +0 -1
- package/dist/core/files.d.ts +0 -69
- package/dist/core/files.d.ts.map +0 -1
- package/dist/core/files.js +0 -260
- package/dist/core/files.js.map +0 -1
- package/dist/core/inline-code.d.ts +0 -87
- package/dist/core/inline-code.d.ts.map +0 -1
- package/dist/core/inline-code.js +0 -104
- package/dist/core/inline-code.js.map +0 -1
- package/dist/core/line-endings.d.ts +0 -32
- package/dist/core/line-endings.d.ts.map +0 -1
- package/dist/core/line-endings.js +0 -65
- package/dist/core/line-endings.js.map +0 -1
- package/dist/core/markdoc-tags.d.ts +0 -79
- package/dist/core/markdoc-tags.d.ts.map +0 -1
- package/dist/core/markdoc-tags.js +0 -131
- package/dist/core/markdoc-tags.js.map +0 -1
- package/dist/core/prose-extract.d.ts +0 -6
- package/dist/core/prose-extract.d.ts.map +0 -1
- package/dist/core/prose-extract.js +0 -79
- package/dist/core/prose-extract.js.map +0 -1
- package/dist/core/readability.d.ts +0 -17
- package/dist/core/readability.d.ts.map +0 -1
- package/dist/core/readability.js +0 -37
- package/dist/core/readability.js.map +0 -1
- package/dist/core/rule-filters.d.ts +0 -45
- package/dist/core/rule-filters.d.ts.map +0 -1
- package/dist/core/rule-filters.js +0 -118
- package/dist/core/rule-filters.js.map +0 -1
- package/dist/core/runner.d.ts +0 -99
- package/dist/core/runner.d.ts.map +0 -1
- package/dist/core/runner.js +0 -401
- package/dist/core/runner.js.map +0 -1
- package/dist/core/timing.d.ts +0 -24
- package/dist/core/timing.d.ts.map +0 -1
- package/dist/core/timing.js +0 -39
- package/dist/core/timing.js.map +0 -1
- package/dist/data/markdoc-realm-schema.d.ts.map +0 -1
- package/dist/data/markdoc-realm-schema.js +0 -798
- package/dist/data/markdoc-realm-schema.js.map +0 -1
- package/dist/data/proper-nouns.d.ts.map +0 -1
- package/dist/data/proper-nouns.js +0 -47
- package/dist/data/proper-nouns.js.map +0 -1
- package/dist/data/realm-front-matter-schema.d.ts +0 -28
- package/dist/data/realm-front-matter-schema.d.ts.map +0 -1
- package/dist/data/realm-front-matter-schema.js +0 -73
- package/dist/data/realm-front-matter-schema.js.map +0 -1
- package/dist/index.d.ts +0 -90
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -152
- package/dist/index.js.map +0 -1
- package/dist/metrics/formulas.d.ts +0 -17
- package/dist/metrics/formulas.d.ts.map +0 -1
- package/dist/metrics/formulas.js +0 -70
- package/dist/metrics/formulas.js.map +0 -1
- package/dist/metrics/statistics.d.ts +0 -27
- package/dist/metrics/statistics.d.ts.map +0 -1
- package/dist/metrics/statistics.js +0 -56
- package/dist/metrics/statistics.js.map +0 -1
- package/dist/parser/index.d.ts +0 -19
- package/dist/parser/index.d.ts.map +0 -1
- package/dist/parser/index.js +0 -174
- package/dist/parser/index.js.map +0 -1
- package/dist/parser/markdoc/extract-statics.d.ts +0 -45
- package/dist/parser/markdoc/extract-statics.d.ts.map +0 -1
- package/dist/parser/markdoc/extract-statics.js +0 -139
- package/dist/parser/markdoc/extract-statics.js.map +0 -1
- package/dist/parser/markdoc/pairing.d.ts +0 -63
- package/dist/parser/markdoc/pairing.d.ts.map +0 -1
- package/dist/parser/markdoc/pairing.js +0 -94
- package/dist/parser/markdoc/pairing.js.map +0 -1
- package/dist/parser/markdoc/schema.d.ts +0 -85
- package/dist/parser/markdoc/schema.d.ts.map +0 -1
- package/dist/parser/markdoc/schema.js +0 -86
- package/dist/parser/markdoc/schema.js.map +0 -1
- package/dist/parser/markdoc/span.d.ts +0 -64
- package/dist/parser/markdoc/span.d.ts.map +0 -1
- package/dist/parser/markdoc/span.js +0 -729
- package/dist/parser/markdoc/span.js.map +0 -1
- package/dist/parser/markdoc/structure.d.ts +0 -28
- package/dist/parser/markdoc/structure.d.ts.map +0 -1
- package/dist/parser/markdoc/structure.js +0 -153
- package/dist/parser/markdoc/structure.js.map +0 -1
- package/dist/parser/markdoc/syntax.d.ts +0 -44
- package/dist/parser/markdoc/syntax.d.ts.map +0 -1
- package/dist/parser/markdoc/syntax.js +0 -317
- package/dist/parser/markdoc/syntax.js.map +0 -1
- package/dist/parser/types.d.ts.map +0 -1
- package/dist/reporter/fixes.d.ts +0 -3
- package/dist/reporter/fixes.d.ts.map +0 -1
- package/dist/reporter/fixes.js +0 -41
- package/dist/reporter/fixes.js.map +0 -1
- package/dist/reporter/formats/github-actions.d.ts +0 -6
- package/dist/reporter/formats/github-actions.d.ts.map +0 -1
- package/dist/reporter/formats/github-actions.js +0 -20
- package/dist/reporter/formats/github-actions.js.map +0 -1
- package/dist/reporter/formats/json.d.ts +0 -10
- package/dist/reporter/formats/json.d.ts.map +0 -1
- package/dist/reporter/formats/json.js +0 -25
- package/dist/reporter/formats/json.js.map +0 -1
- package/dist/reporter/formats/sarif.d.ts +0 -10
- package/dist/reporter/formats/sarif.d.ts.map +0 -1
- package/dist/reporter/formats/sarif.js +0 -66
- package/dist/reporter/formats/sarif.js.map +0 -1
- package/dist/reporter/formats/table.d.ts +0 -6
- package/dist/reporter/formats/table.d.ts.map +0 -1
- package/dist/reporter/formats/table.js +0 -43
- package/dist/reporter/formats/table.js.map +0 -1
- package/dist/reporter/index.d.ts +0 -10
- package/dist/reporter/index.d.ts.map +0 -1
- package/dist/reporter/index.js +0 -42
- package/dist/reporter/index.js.map +0 -1
- package/dist/reporter/prioritize-problems.d.ts +0 -7
- package/dist/reporter/prioritize-problems.d.ts.map +0 -1
- package/dist/reporter/prioritize-problems.js +0 -29
- package/dist/reporter/prioritize-problems.js.map +0 -1
- package/dist/reporter/statistics.d.ts +0 -10
- package/dist/reporter/statistics.d.ts.map +0 -1
- package/dist/reporter/statistics.js +0 -52
- package/dist/reporter/statistics.js.map +0 -1
- package/dist/reporter/summary.d.ts +0 -10
- package/dist/reporter/summary.d.ts.map +0 -1
- package/dist/reporter/summary.js +0 -49
- package/dist/reporter/summary.js.map +0 -1
- package/dist/rules/registry.d.ts +0 -15
- package/dist/rules/registry.d.ts.map +0 -1
- package/dist/rules/registry.js +0 -81
- package/dist/rules/registry.js.map +0 -1
- package/dist/rules/scope/capitalization.d.ts.map +0 -1
- package/dist/rules/scope/capitalization.js +0 -164
- package/dist/rules/scope/capitalization.js.map +0 -1
- package/dist/rules/scope/conditional.d.ts.map +0 -1
- package/dist/rules/scope/conditional.js +0 -112
- package/dist/rules/scope/conditional.js.map +0 -1
- package/dist/rules/scope/consistency.d.ts.map +0 -1
- package/dist/rules/scope/consistency.js +0 -179
- package/dist/rules/scope/consistency.js.map +0 -1
- package/dist/rules/scope/length.d.ts.map +0 -1
- package/dist/rules/scope/length.js +0 -73
- package/dist/rules/scope/length.js.map +0 -1
- package/dist/rules/scope/max-image-size.d.ts.map +0 -1
- package/dist/rules/scope/max-image-size.js +0 -65
- package/dist/rules/scope/max-image-size.js.map +0 -1
- package/dist/rules/scope/metric.d.ts +0 -5
- package/dist/rules/scope/metric.d.ts.map +0 -1
- package/dist/rules/scope/metric.js +0 -59
- package/dist/rules/scope/metric.js.map +0 -1
- package/dist/rules/scope/occurrence.d.ts.map +0 -1
- package/dist/rules/scope/occurrence.js +0 -48
- package/dist/rules/scope/occurrence.js.map +0 -1
- package/dist/rules/scope/pattern.d.ts.map +0 -1
- package/dist/rules/scope/pattern.js +0 -75
- package/dist/rules/scope/pattern.js.map +0 -1
- package/dist/rules/scope/repetition.d.ts.map +0 -1
- package/dist/rules/scope/repetition.js +0 -139
- package/dist/rules/scope/repetition.js.map +0 -1
- package/dist/rules/scope/semantic-line-breaks.d.ts.map +0 -1
- package/dist/rules/scope/semantic-line-breaks.js +0 -236
- package/dist/rules/scope/semantic-line-breaks.js.map +0 -1
- package/dist/rules/scope/spelling.d.ts +0 -27
- package/dist/rules/scope/spelling.d.ts.map +0 -1
- package/dist/rules/scope/spelling.js +0 -227
- package/dist/rules/scope/spelling.js.map +0 -1
- package/dist/rules/scope/swap.d.ts.map +0 -1
- package/dist/rules/scope/swap.js +0 -149
- package/dist/rules/scope/swap.js.map +0 -1
- package/dist/rules/scope/title-case.d.ts +0 -46
- package/dist/rules/scope/title-case.d.ts.map +0 -1
- package/dist/rules/scope/title-case.js +0 -301
- package/dist/rules/scope/title-case.js.map +0 -1
- package/dist/rules/token/blanks-around-fences.d.ts.map +0 -1
- package/dist/rules/token/blanks-around-fences.js.map +0 -1
- package/dist/rules/token/blanks-around-headings.d.ts.map +0 -1
- package/dist/rules/token/blanks-around-headings.js +0 -108
- package/dist/rules/token/blanks-around-headings.js.map +0 -1
- package/dist/rules/token/blanks-around-lists.d.ts.map +0 -1
- package/dist/rules/token/blanks-around-lists.js +0 -56
- package/dist/rules/token/blanks-around-lists.js.map +0 -1
- package/dist/rules/token/blanks-around-tables.d.ts.map +0 -1
- package/dist/rules/token/blanks-around-tables.js +0 -42
- package/dist/rules/token/blanks-around-tables.js.map +0 -1
- package/dist/rules/token/code-block-style.d.ts.map +0 -1
- package/dist/rules/token/code-block-style.js.map +0 -1
- package/dist/rules/token/code-fence-style.d.ts.map +0 -1
- package/dist/rules/token/code-fence-style.js.map +0 -1
- package/dist/rules/token/commands-show-output.d.ts.map +0 -1
- package/dist/rules/token/commands-show-output.js.map +0 -1
- package/dist/rules/token/descriptive-link-text.d.ts.map +0 -1
- package/dist/rules/token/descriptive-link-text.js +0 -53
- package/dist/rules/token/descriptive-link-text.js.map +0 -1
- package/dist/rules/token/fenced-code-language.d.ts.map +0 -1
- package/dist/rules/token/fenced-code-language.js.map +0 -1
- package/dist/rules/token/first-line-h1.d.ts.map +0 -1
- package/dist/rules/token/first-line-h1.js +0 -107
- package/dist/rules/token/first-line-h1.js.map +0 -1
- package/dist/rules/token/front-matter.d.ts.map +0 -1
- package/dist/rules/token/front-matter.js +0 -177
- package/dist/rules/token/front-matter.js.map +0 -1
- package/dist/rules/token/heading-increment.d.ts.map +0 -1
- package/dist/rules/token/heading-increment.js +0 -27
- package/dist/rules/token/heading-increment.js.map +0 -1
- package/dist/rules/token/heading-start-left.d.ts.map +0 -1
- package/dist/rules/token/heading-start-left.js.map +0 -1
- package/dist/rules/token/heading-style.d.ts.map +0 -1
- package/dist/rules/token/heading-style.js.map +0 -1
- package/dist/rules/token/helpers.d.ts +0 -313
- package/dist/rules/token/helpers.d.ts.map +0 -1
- package/dist/rules/token/helpers.js +0 -746
- package/dist/rules/token/helpers.js.map +0 -1
- package/dist/rules/token/hr-style.d.ts.map +0 -1
- package/dist/rules/token/hr-style.js.map +0 -1
- package/dist/rules/token/index.d.ts +0 -76
- package/dist/rules/token/index.d.ts.map +0 -1
- package/dist/rules/token/index.js +0 -229
- package/dist/rules/token/index.js.map +0 -1
- package/dist/rules/token/line-length.d.ts.map +0 -1
- package/dist/rules/token/line-length.js +0 -120
- package/dist/rules/token/line-length.js.map +0 -1
- package/dist/rules/token/link-fragments.d.ts.map +0 -1
- package/dist/rules/token/link-fragments.js +0 -393
- package/dist/rules/token/link-fragments.js.map +0 -1
- package/dist/rules/token/link-image-reference-definitions.d.ts.map +0 -1
- package/dist/rules/token/link-image-reference-definitions.js.map +0 -1
- package/dist/rules/token/link-image-style.d.ts.map +0 -1
- package/dist/rules/token/link-image-style.js +0 -131
- package/dist/rules/token/link-image-style.js.map +0 -1
- package/dist/rules/token/list-indent.d.ts.map +0 -1
- package/dist/rules/token/list-indent.js.map +0 -1
- package/dist/rules/token/list-length.d.ts.map +0 -1
- package/dist/rules/token/list-length.js +0 -55
- package/dist/rules/token/list-length.js.map +0 -1
- package/dist/rules/token/list-marker-space.d.ts.map +0 -1
- package/dist/rules/token/list-marker-space.js.map +0 -1
- package/dist/rules/token/markdoc-attributes.d.ts.map +0 -1
- package/dist/rules/token/markdoc-attributes.js +0 -269
- package/dist/rules/token/markdoc-attributes.js.map +0 -1
- package/dist/rules/token/markdoc-pairing.d.ts.map +0 -1
- package/dist/rules/token/markdoc-pairing.js +0 -73
- package/dist/rules/token/markdoc-pairing.js.map +0 -1
- package/dist/rules/token/markdoc-syntax.d.ts.map +0 -1
- package/dist/rules/token/markdoc-syntax.js +0 -119
- package/dist/rules/token/markdoc-syntax.js.map +0 -1
- package/dist/rules/token/markdoc-unknown-tag.d.ts.map +0 -1
- package/dist/rules/token/markdoc-unknown-tag.js +0 -64
- package/dist/rules/token/markdoc-unknown-tag.js.map +0 -1
- package/dist/rules/token/no-alt-text.d.ts.map +0 -1
- package/dist/rules/token/no-alt-text.js +0 -47
- package/dist/rules/token/no-alt-text.js.map +0 -1
- package/dist/rules/token/no-bare-urls.d.ts.map +0 -1
- package/dist/rules/token/no-bare-urls.js +0 -88
- package/dist/rules/token/no-bare-urls.js.map +0 -1
- package/dist/rules/token/no-blanks-blockquote.d.ts.map +0 -1
- package/dist/rules/token/no-blanks-blockquote.js.map +0 -1
- package/dist/rules/token/no-duplicate-heading.d.ts.map +0 -1
- package/dist/rules/token/no-duplicate-heading.js +0 -101
- package/dist/rules/token/no-duplicate-heading.js.map +0 -1
- package/dist/rules/token/no-duplicate-link-destinations.d.ts.map +0 -1
- package/dist/rules/token/no-duplicate-link-destinations.js +0 -65
- package/dist/rules/token/no-duplicate-link-destinations.js.map +0 -1
- package/dist/rules/token/no-emphasis-as-heading.d.ts.map +0 -1
- package/dist/rules/token/no-emphasis-as-heading.js +0 -44
- package/dist/rules/token/no-emphasis-as-heading.js.map +0 -1
- package/dist/rules/token/no-empty-headings.d.ts.map +0 -1
- package/dist/rules/token/no-empty-headings.js +0 -28
- package/dist/rules/token/no-empty-headings.js.map +0 -1
- package/dist/rules/token/no-empty-links.d.ts.map +0 -1
- package/dist/rules/token/no-empty-links.js.map +0 -1
- package/dist/rules/token/no-hard-tabs.d.ts.map +0 -1
- package/dist/rules/token/no-hard-tabs.js.map +0 -1
- package/dist/rules/token/no-inline-html.d.ts.map +0 -1
- package/dist/rules/token/no-inline-html.js +0 -45
- package/dist/rules/token/no-inline-html.js.map +0 -1
- package/dist/rules/token/no-multiple-blanks.d.ts.map +0 -1
- package/dist/rules/token/no-multiple-blanks.js.map +0 -1
- package/dist/rules/token/no-multiple-space-atx.d.ts +0 -13
- package/dist/rules/token/no-multiple-space-atx.d.ts.map +0 -1
- package/dist/rules/token/no-multiple-space-atx.js +0 -50
- package/dist/rules/token/no-multiple-space-atx.js.map +0 -1
- package/dist/rules/token/no-multiple-space-closed-atx.d.ts.map +0 -1
- package/dist/rules/token/no-multiple-space-closed-atx.js.map +0 -1
- package/dist/rules/token/no-reversed-links.d.ts.map +0 -1
- package/dist/rules/token/no-reversed-links.js.map +0 -1
- package/dist/rules/token/no-space-in-code.d.ts.map +0 -1
- package/dist/rules/token/no-space-in-code.js.map +0 -1
- package/dist/rules/token/no-space-in-emphasis.d.ts.map +0 -1
- package/dist/rules/token/no-space-in-emphasis.js +0 -79
- package/dist/rules/token/no-space-in-emphasis.js.map +0 -1
- package/dist/rules/token/no-space-in-links.d.ts.map +0 -1
- package/dist/rules/token/no-space-in-links.js.map +0 -1
- package/dist/rules/token/no-trailing-punctuation.d.ts.map +0 -1
- package/dist/rules/token/no-trailing-punctuation.js.map +0 -1
- package/dist/rules/token/no-trailing-spaces.d.ts.map +0 -1
- package/dist/rules/token/no-trailing-spaces.js.map +0 -1
- package/dist/rules/token/ol-prefix.d.ts.map +0 -1
- package/dist/rules/token/ol-prefix.js.map +0 -1
- package/dist/rules/token/proper-names.d.ts.map +0 -1
- package/dist/rules/token/proper-names.js +0 -93
- package/dist/rules/token/proper-names.js.map +0 -1
- package/dist/rules/token/reference-links-images.d.ts.map +0 -1
- package/dist/rules/token/reference-links-images.js.map +0 -1
- package/dist/rules/token/required-headings.d.ts.map +0 -1
- package/dist/rules/token/required-headings.js +0 -83
- package/dist/rules/token/required-headings.js.map +0 -1
- package/dist/rules/token/single-h1.d.ts.map +0 -1
- package/dist/rules/token/single-h1.js +0 -56
- package/dist/rules/token/single-h1.js.map +0 -1
- package/dist/rules/token/table-column-count.d.ts.map +0 -1
- package/dist/rules/token/table-column-count.js.map +0 -1
- package/dist/rules/token/table-column-style.d.ts.map +0 -1
- package/dist/rules/token/table-column-style.js +0 -179
- package/dist/rules/token/table-column-style.js.map +0 -1
- package/dist/rules/token/table-pipe-style.d.ts.map +0 -1
- package/dist/rules/token/table-pipe-style.js.map +0 -1
- package/dist/rules/token/ul-indent.d.ts.map +0 -1
- package/dist/rules/token/ul-indent.js.map +0 -1
- package/dist/rules/token/ul-style.d.ts.map +0 -1
- package/dist/rules/token/ul-style.js +0 -80
- package/dist/rules/token/ul-style.js.map +0 -1
- package/dist/rules/types.d.ts +0 -83
- package/dist/rules/types.d.ts.map +0 -1
- package/dist/rules/utils.d.ts +0 -31
- package/dist/rules/utils.d.ts.map +0 -1
- package/dist/rules/utils.js +0 -90
- package/dist/rules/utils.js.map +0 -1
- package/dist/scopes/extractor.d.ts +0 -7
- package/dist/scopes/extractor.d.ts.map +0 -1
- package/dist/scopes/extractor.js +0 -536
- package/dist/scopes/extractor.js.map +0 -1
- package/dist/scopes/selector.d.ts +0 -51
- package/dist/scopes/selector.d.ts.map +0 -1
- package/dist/scopes/selector.js +0 -121
- package/dist/scopes/selector.js.map +0 -1
- package/dist/scopes/sentences.d.ts +0 -15
- package/dist/scopes/sentences.d.ts.map +0 -1
- package/dist/scopes/sentences.js +0 -202
- package/dist/scopes/sentences.js.map +0 -1
- package/dist/scopes/types.d.ts +0 -46
- package/dist/scopes/types.d.ts.map +0 -1
- package/dist/scopes/vocabulary.d.ts +0 -16
- package/dist/scopes/vocabulary.d.ts.map +0 -1
- package/dist/scopes/vocabulary.js +0 -70
- package/dist/scopes/vocabulary.js.map +0 -1
- package/dist/types/assertions.d.ts +0 -119
- package/dist/types/assertions.d.ts.map +0 -1
- package/dist/types/reporting.d.ts +0 -32
- package/dist/types/reporting.d.ts.map +0 -1
- package/dist/types/rules.d.ts +0 -41
- package/dist/types/rules.d.ts.map +0 -1
- package/dist/types/validation.d.ts +0 -6
- package/dist/types/validation.d.ts.map +0 -1
- /package/{dist → lib}/core/auto-fix.d.ts +0 -0
- /package/{dist → lib}/core/directives.d.ts +0 -0
- /package/{dist → lib}/data/markdoc-realm-schema.d.ts +0 -0
- /package/{dist → lib}/data/proper-nouns.d.ts +0 -0
- /package/{dist → lib}/metrics/index.d.ts +0 -0
- /package/{dist → lib}/metrics/index.d.ts.map +0 -0
- /package/{dist → lib}/metrics/index.js +0 -0
- /package/{dist → lib}/metrics/index.js.map +0 -0
- /package/{dist → lib}/parser/types.d.ts +0 -0
- /package/{dist → lib}/parser/types.js +0 -0
- /package/{dist → lib}/parser/types.js.map +0 -0
- /package/{dist → lib}/rules/scope/capitalization.d.ts +0 -0
- /package/{dist → lib}/rules/scope/conditional.d.ts +0 -0
- /package/{dist → lib}/rules/scope/consistency.d.ts +0 -0
- /package/{dist → lib}/rules/scope/length.d.ts +0 -0
- /package/{dist → lib}/rules/scope/max-image-size.d.ts +0 -0
- /package/{dist → lib}/rules/scope/occurrence.d.ts +0 -0
- /package/{dist → lib}/rules/scope/pattern.d.ts +0 -0
- /package/{dist → lib}/rules/scope/repetition.d.ts +0 -0
- /package/{dist → lib}/rules/scope/semantic-line-breaks.d.ts +0 -0
- /package/{dist → lib}/rules/scope/swap.d.ts +0 -0
- /package/{dist → lib}/rules/token/blanks-around-fences.d.ts +0 -0
- /package/{dist → lib}/rules/token/blanks-around-fences.js +0 -0
- /package/{dist → lib}/rules/token/blanks-around-headings.d.ts +0 -0
- /package/{dist → lib}/rules/token/blanks-around-lists.d.ts +0 -0
- /package/{dist → lib}/rules/token/blanks-around-tables.d.ts +0 -0
- /package/{dist → lib}/rules/token/code-block-style.d.ts +0 -0
- /package/{dist → lib}/rules/token/code-block-style.js +0 -0
- /package/{dist → lib}/rules/token/code-fence-style.d.ts +0 -0
- /package/{dist → lib}/rules/token/code-fence-style.js +0 -0
- /package/{dist → lib}/rules/token/commands-show-output.d.ts +0 -0
- /package/{dist → lib}/rules/token/commands-show-output.js +0 -0
- /package/{dist → lib}/rules/token/descriptive-link-text.d.ts +0 -0
- /package/{dist → lib}/rules/token/emphasis-style.d.ts +0 -0
- /package/{dist → lib}/rules/token/emphasis-style.d.ts.map +0 -0
- /package/{dist → lib}/rules/token/emphasis-style.js +0 -0
- /package/{dist → lib}/rules/token/emphasis-style.js.map +0 -0
- /package/{dist → lib}/rules/token/fenced-code-language.d.ts +0 -0
- /package/{dist → lib}/rules/token/fenced-code-language.js +0 -0
- /package/{dist → lib}/rules/token/first-line-h1.d.ts +0 -0
- /package/{dist → lib}/rules/token/front-matter.d.ts +0 -0
- /package/{dist → lib}/rules/token/heading-increment.d.ts +0 -0
- /package/{dist → lib}/rules/token/heading-start-left.d.ts +0 -0
- /package/{dist → lib}/rules/token/heading-start-left.js +0 -0
- /package/{dist → lib}/rules/token/heading-style.d.ts +0 -0
- /package/{dist → lib}/rules/token/heading-style.js +0 -0
- /package/{dist → lib}/rules/token/hr-style.d.ts +0 -0
- /package/{dist → lib}/rules/token/hr-style.js +0 -0
- /package/{dist → lib}/rules/token/line-length.d.ts +0 -0
- /package/{dist → lib}/rules/token/link-fragments.d.ts +0 -0
- /package/{dist → lib}/rules/token/link-image-reference-definitions.d.ts +0 -0
- /package/{dist → lib}/rules/token/link-image-reference-definitions.js +0 -0
- /package/{dist → lib}/rules/token/link-image-style.d.ts +0 -0
- /package/{dist → lib}/rules/token/list-indent.d.ts +0 -0
- /package/{dist → lib}/rules/token/list-indent.js +0 -0
- /package/{dist → lib}/rules/token/list-length.d.ts +0 -0
- /package/{dist → lib}/rules/token/list-marker-space.d.ts +0 -0
- /package/{dist → lib}/rules/token/list-marker-space.js +0 -0
- /package/{dist → lib}/rules/token/markdoc-attributes.d.ts +0 -0
- /package/{dist → lib}/rules/token/markdoc-pairing.d.ts +0 -0
- /package/{dist → lib}/rules/token/markdoc-syntax.d.ts +0 -0
- /package/{dist → lib}/rules/token/markdoc-unknown-tag.d.ts +0 -0
- /package/{dist → lib}/rules/token/messages.d.ts +0 -0
- /package/{dist → lib}/rules/token/messages.d.ts.map +0 -0
- /package/{dist → lib}/rules/token/messages.js +0 -0
- /package/{dist → lib}/rules/token/messages.js.map +0 -0
- /package/{dist → lib}/rules/token/no-alt-text.d.ts +0 -0
- /package/{dist → lib}/rules/token/no-bare-urls.d.ts +0 -0
- /package/{dist → lib}/rules/token/no-blanks-blockquote.d.ts +0 -0
- /package/{dist → lib}/rules/token/no-blanks-blockquote.js +0 -0
- /package/{dist → lib}/rules/token/no-duplicate-heading.d.ts +0 -0
- /package/{dist → lib}/rules/token/no-duplicate-link-destinations.d.ts +0 -0
- /package/{dist → lib}/rules/token/no-emphasis-as-heading.d.ts +0 -0
- /package/{dist → lib}/rules/token/no-empty-headings.d.ts +0 -0
- /package/{dist → lib}/rules/token/no-empty-links.d.ts +0 -0
- /package/{dist → lib}/rules/token/no-empty-links.js +0 -0
- /package/{dist → lib}/rules/token/no-hard-tabs.d.ts +0 -0
- /package/{dist → lib}/rules/token/no-hard-tabs.js +0 -0
- /package/{dist → lib}/rules/token/no-inline-html.d.ts +0 -0
- /package/{dist → lib}/rules/token/no-missing-space-atx.d.ts +0 -0
- /package/{dist → lib}/rules/token/no-missing-space-atx.d.ts.map +0 -0
- /package/{dist → lib}/rules/token/no-missing-space-atx.js +0 -0
- /package/{dist → lib}/rules/token/no-missing-space-atx.js.map +0 -0
- /package/{dist → lib}/rules/token/no-missing-space-closed-atx.d.ts +0 -0
- /package/{dist → lib}/rules/token/no-missing-space-closed-atx.d.ts.map +0 -0
- /package/{dist → lib}/rules/token/no-missing-space-closed-atx.js +0 -0
- /package/{dist → lib}/rules/token/no-missing-space-closed-atx.js.map +0 -0
- /package/{dist → lib}/rules/token/no-multiple-blanks.d.ts +0 -0
- /package/{dist → lib}/rules/token/no-multiple-blanks.js +0 -0
- /package/{dist → lib}/rules/token/no-multiple-space-blockquote.d.ts +0 -0
- /package/{dist → lib}/rules/token/no-multiple-space-blockquote.d.ts.map +0 -0
- /package/{dist → lib}/rules/token/no-multiple-space-blockquote.js +0 -0
- /package/{dist → lib}/rules/token/no-multiple-space-blockquote.js.map +0 -0
- /package/{dist → lib}/rules/token/no-multiple-space-closed-atx.d.ts +0 -0
- /package/{dist → lib}/rules/token/no-multiple-space-closed-atx.js +0 -0
- /package/{dist → lib}/rules/token/no-reversed-links.d.ts +0 -0
- /package/{dist → lib}/rules/token/no-reversed-links.js +0 -0
- /package/{dist → lib}/rules/token/no-space-in-code.d.ts +0 -0
- /package/{dist → lib}/rules/token/no-space-in-code.js +0 -0
- /package/{dist → lib}/rules/token/no-space-in-emphasis.d.ts +0 -0
- /package/{dist → lib}/rules/token/no-space-in-links.d.ts +0 -0
- /package/{dist → lib}/rules/token/no-space-in-links.js +0 -0
- /package/{dist → lib}/rules/token/no-trailing-punctuation.d.ts +0 -0
- /package/{dist → lib}/rules/token/no-trailing-punctuation.js +0 -0
- /package/{dist → lib}/rules/token/no-trailing-spaces.d.ts +0 -0
- /package/{dist → lib}/rules/token/no-trailing-spaces.js +0 -0
- /package/{dist → lib}/rules/token/ol-prefix.d.ts +0 -0
- /package/{dist → lib}/rules/token/ol-prefix.js +0 -0
- /package/{dist → lib}/rules/token/proper-names.d.ts +0 -0
- /package/{dist → lib}/rules/token/reference-links-images.d.ts +0 -0
- /package/{dist → lib}/rules/token/reference-links-images.js +0 -0
- /package/{dist → lib}/rules/token/required-headings.d.ts +0 -0
- /package/{dist → lib}/rules/token/single-h1.d.ts +0 -0
- /package/{dist → lib}/rules/token/single-trailing-newline.d.ts +0 -0
- /package/{dist → lib}/rules/token/single-trailing-newline.d.ts.map +0 -0
- /package/{dist → lib}/rules/token/single-trailing-newline.js +0 -0
- /package/{dist → lib}/rules/token/single-trailing-newline.js.map +0 -0
- /package/{dist → lib}/rules/token/strong-style.d.ts +0 -0
- /package/{dist → lib}/rules/token/strong-style.d.ts.map +0 -0
- /package/{dist → lib}/rules/token/strong-style.js +0 -0
- /package/{dist → lib}/rules/token/strong-style.js.map +0 -0
- /package/{dist → lib}/rules/token/table-column-count.d.ts +0 -0
- /package/{dist → lib}/rules/token/table-column-count.js +0 -0
- /package/{dist → lib}/rules/token/table-column-style.d.ts +0 -0
- /package/{dist → lib}/rules/token/table-pipe-style.d.ts +0 -0
- /package/{dist → lib}/rules/token/table-pipe-style.js +0 -0
- /package/{dist → lib}/rules/token/ul-indent.d.ts +0 -0
- /package/{dist → lib}/rules/token/ul-indent.js +0 -0
- /package/{dist → lib}/rules/token/ul-style.d.ts +0 -0
- /package/{dist → lib}/rules/types.js +0 -0
- /package/{dist → lib}/rules/types.js.map +0 -0
- /package/{dist → lib}/scopes/types.js +0 -0
- /package/{dist → lib}/scopes/types.js.map +0 -0
- /package/{dist → lib}/types/assertions.js +0 -0
- /package/{dist → lib}/types/assertions.js.map +0 -0
- /package/{dist → lib}/types/index.d.ts +0 -0
- /package/{dist → lib}/types/index.d.ts.map +0 -0
- /package/{dist → lib}/types/index.js +0 -0
- /package/{dist → lib}/types/index.js.map +0 -0
- /package/{dist → lib}/types/problems.d.ts +0 -0
- /package/{dist → lib}/types/problems.d.ts.map +0 -0
- /package/{dist → lib}/types/problems.js +0 -0
- /package/{dist → lib}/types/problems.js.map +0 -0
- /package/{dist → lib}/types/reporting.js +0 -0
- /package/{dist → lib}/types/reporting.js.map +0 -0
- /package/{dist → lib}/types/rules.js +0 -0
- /package/{dist → lib}/types/rules.js.map +0 -0
- /package/{dist → lib}/types/validation.js +0 -0
- /package/{dist → lib}/types/validation.js.map +0 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import * as fs from 'fs/promises';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import picomatch from 'picomatch';
|
|
4
|
+
import { parseMarkdown } from '../parser/index.js';
|
|
5
|
+
import { getImageDestinations } from '../rules/token/helpers.js';
|
|
6
|
+
const SKIP_DIRS = ['node_modules', 'dist', 'build'];
|
|
7
|
+
export async function discoverMarkdownFiles(inputPath) {
|
|
8
|
+
async function walkDir(dir) {
|
|
9
|
+
const files = [];
|
|
10
|
+
try {
|
|
11
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
12
|
+
for (const entry of entries) {
|
|
13
|
+
const fullPath = path.join(dir, entry.name);
|
|
14
|
+
if (entry.isDirectory()) {
|
|
15
|
+
if (entry.name.startsWith('.') || SKIP_DIRS.includes(entry.name)) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
files.push(...(await walkDir(fullPath)));
|
|
19
|
+
}
|
|
20
|
+
else if (entry.isFile() &&
|
|
21
|
+
picomatch.isMatch(entry.name, '*.{md,markdown}', { nocase: true })) {
|
|
22
|
+
files.push(fullPath);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
return files;
|
|
30
|
+
}
|
|
31
|
+
const stat = await fs.stat(inputPath);
|
|
32
|
+
if (stat.isFile()) {
|
|
33
|
+
return [inputPath];
|
|
34
|
+
}
|
|
35
|
+
else if (stat.isDirectory()) {
|
|
36
|
+
return walkDir(inputPath);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Load list of changed files from either a file path or stdin
|
|
44
|
+
*/
|
|
45
|
+
export async function loadChangedFiles(changedListPath) {
|
|
46
|
+
if (changedListPath && changedListPath.length > 0) {
|
|
47
|
+
try {
|
|
48
|
+
const content = await fs.readFile(changedListPath, 'utf8');
|
|
49
|
+
return content
|
|
50
|
+
.split(/\r?\n/)
|
|
51
|
+
.map((s) => s.trim())
|
|
52
|
+
.filter(Boolean);
|
|
53
|
+
}
|
|
54
|
+
catch (_err) {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (process.stdin.isTTY)
|
|
59
|
+
return [];
|
|
60
|
+
const chunks = [];
|
|
61
|
+
return await new Promise((resolve) => {
|
|
62
|
+
process.stdin.setEncoding('utf8');
|
|
63
|
+
process.stdin.on('data', (d) => chunks.push(String(d)));
|
|
64
|
+
process.stdin.on('end', () => {
|
|
65
|
+
const text = chunks.join('');
|
|
66
|
+
const lines = text
|
|
67
|
+
.split(/\r?\n/)
|
|
68
|
+
.map((s) => s.trim())
|
|
69
|
+
.filter(Boolean);
|
|
70
|
+
resolve(lines);
|
|
71
|
+
});
|
|
72
|
+
process.stdin.resume();
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Runs `fn` over `items` with at most `limit` calls at once. Results are in the same order as
|
|
77
|
+
* `items`. Recheck is published on its own, so it cannot use @redocly/shared's promiseMapLimit.
|
|
78
|
+
*/
|
|
79
|
+
export async function mapLimit(items, limit, fn) {
|
|
80
|
+
const results = new Array(items.length);
|
|
81
|
+
let next = 0;
|
|
82
|
+
async function worker() {
|
|
83
|
+
while (next < items.length) {
|
|
84
|
+
const index = next++;
|
|
85
|
+
results[index] = await fn(items[index], index);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
89
|
+
return results;
|
|
90
|
+
}
|
|
91
|
+
/** Whether any rule uses `max-image-size`, which needs image metadata from disk. */
|
|
92
|
+
export function needsImageMetadata(rules) {
|
|
93
|
+
return rules.some((rule) => Object.keys(rule.assertions).includes('max-image-size'));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Returns the local (not `http(s)://`) image paths in `content`, from inline and reference-style
|
|
97
|
+
* images. It uses the same `getImageDestinations` as `max-image-size`, so the paths match the
|
|
98
|
+
* keys that `loadImageMetadata` stores. Markdoc parsing is off here, because it does not change
|
|
99
|
+
* where images start or end.
|
|
100
|
+
*/
|
|
101
|
+
function extractImageReferences(content) {
|
|
102
|
+
return getImageDestinations(parseMarkdown(content))
|
|
103
|
+
.map(({ destination }) => destination)
|
|
104
|
+
.filter((destination) => !destination.startsWith('http://') && !destination.startsWith('https://'));
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Most unique image refs checked per file, to limit the number of `fs.stat` calls. Refs past the
|
|
108
|
+
* limit are left out of the metadata instead of being marked as missing.
|
|
109
|
+
*/
|
|
110
|
+
export const MAX_IMAGE_REFS_PER_FILE = 1000;
|
|
111
|
+
/** Whether `resolved` (an absolute path) is `root` itself or inside it. */
|
|
112
|
+
function isInsideRoot(root, resolved) {
|
|
113
|
+
const relative = path.relative(root, resolved);
|
|
114
|
+
return (relative === '' ||
|
|
115
|
+
(relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative)));
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Loads size and existence for the images in a markdown file, keyed by the path as written.
|
|
119
|
+
*
|
|
120
|
+
* Refs are limited to `root` (default `process.cwd()`). A ref that leaves it, by `../` or an
|
|
121
|
+
* absolute path, is marked as missing without being checked, so a document cannot probe other
|
|
122
|
+
* files. Symlinks are followed only if they resolve inside the root.
|
|
123
|
+
*
|
|
124
|
+
* At most `MAX_IMAGE_REFS_PER_FILE` unique refs are checked. The rest are left out, so
|
|
125
|
+
* `max-image-size` skips them instead of reporting them as missing.
|
|
126
|
+
*/
|
|
127
|
+
export async function loadImageMetadata(file, content, root = process.cwd()) {
|
|
128
|
+
const images = new Map();
|
|
129
|
+
const baseDir = path.dirname(file);
|
|
130
|
+
const resolvedRoot = path.resolve(root);
|
|
131
|
+
const imageReferences = extractImageReferences(content);
|
|
132
|
+
// The root's real path, resolved once. `undefined` if the root does not exist.
|
|
133
|
+
let realRoot;
|
|
134
|
+
try {
|
|
135
|
+
realRoot = await fs.realpath(resolvedRoot);
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
realRoot = undefined;
|
|
139
|
+
}
|
|
140
|
+
for (const imagePath of imageReferences) {
|
|
141
|
+
if (images.has(imagePath)) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (images.size >= MAX_IMAGE_REFS_PER_FILE) {
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
const fullPath = path.resolve(baseDir, imagePath);
|
|
148
|
+
if (!isInsideRoot(resolvedRoot, fullPath)) {
|
|
149
|
+
images.set(imagePath, { path: imagePath, size: 0, exists: false });
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
// Follow symlinks, and reject any that end up outside the root. If the path cannot be
|
|
153
|
+
// resolved, the `fs.stat` below reports it as missing.
|
|
154
|
+
if (realRoot !== undefined) {
|
|
155
|
+
try {
|
|
156
|
+
const realPath = await fs.realpath(fullPath);
|
|
157
|
+
if (!isInsideRoot(realRoot, realPath)) {
|
|
158
|
+
images.set(imagePath, { path: imagePath, size: 0, exists: false });
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
// Fall through to the stat below.
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
const stats = await fs.stat(fullPath);
|
|
168
|
+
images.set(imagePath, {
|
|
169
|
+
path: imagePath,
|
|
170
|
+
size: stats.size,
|
|
171
|
+
exists: true,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
images.set(imagePath, {
|
|
176
|
+
path: imagePath,
|
|
177
|
+
size: 0,
|
|
178
|
+
exists: false,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return images.size > 0 ? { images } : undefined;
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/core/files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,EA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BACf,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,MAAM,EAAE,IAAI;aACb,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE;gBACpB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,CAAC;gBACP,MAAM,EAAE,KAAK;aACd,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Matches one inline code span: a run of N backticks, then text up to the next run of exactly N
|
|
3
|
+
* backticks. It stays on one line, so use it on single-line text.
|
|
4
|
+
*/
|
|
5
|
+
export declare const BACKTICK_SPAN_RE: RegExp;
|
|
6
|
+
/** The character that `maskInlineCode` uses. Word tokenizers never match it. */
|
|
7
|
+
export declare const INLINE_CODE_MASK_CHAR = "\0";
|
|
8
|
+
/**
|
|
9
|
+
* Replaces each inline code span with the same number of `INLINE_CODE_MASK_CHAR`. The length stays
|
|
10
|
+
* the same, so positions in the masked text are valid in the original.
|
|
11
|
+
*/
|
|
12
|
+
export declare function maskInlineCode(text: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Puts the code spans of `original` back into `transformed`, a masked copy that was changed
|
|
15
|
+
* without changing its length (for example, case changes).
|
|
16
|
+
*/
|
|
17
|
+
export declare function restoreInlineCode(original: string, transformed: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* The `[start, end)` ranges of the inline code spans in `text`.
|
|
20
|
+
*
|
|
21
|
+
* Rules that run a user regex (`swap`, `pattern`) use these ranges to drop matches inside code.
|
|
22
|
+
* Masking would not work for them, because the mask characters can change what the regex matches.
|
|
23
|
+
*/
|
|
24
|
+
export declare function inlineCodeRanges(text: string): Array<{
|
|
25
|
+
start: number;
|
|
26
|
+
end: number;
|
|
27
|
+
}>;
|
|
28
|
+
/** Whether `[start, end)` overlaps any of `ranges`. Touching at an end does not count. */
|
|
29
|
+
export declare function overlapsAnyRange(start: number, end: number, ranges: Array<{
|
|
30
|
+
start: number;
|
|
31
|
+
end: number;
|
|
32
|
+
}>): boolean;
|
|
33
|
+
//# sourceMappingURL=inline-code.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-code.d.ts","sourceRoot":"","sources":["../../src/core/inline-code.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAAwB,CAAC;AAEtD,gFAAgF;AAChF,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAE1C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAY/E;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAOpF;AAED,0FAA0F;AAC1F,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,GAC5C,OAAO,CAET"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Matches one inline code span: a run of N backticks, then text up to the next run of exactly N
|
|
3
|
+
* backticks. It stays on one line, so use it on single-line text.
|
|
4
|
+
*/
|
|
5
|
+
export const BACKTICK_SPAN_RE = /(`+)[^\n]*?\1(?!`)/g;
|
|
6
|
+
/** The character that `maskInlineCode` uses. Word tokenizers never match it. */
|
|
7
|
+
export const INLINE_CODE_MASK_CHAR = '\0';
|
|
8
|
+
/**
|
|
9
|
+
* Replaces each inline code span with the same number of `INLINE_CODE_MASK_CHAR`. The length stays
|
|
10
|
+
* the same, so positions in the masked text are valid in the original.
|
|
11
|
+
*/
|
|
12
|
+
export function maskInlineCode(text) {
|
|
13
|
+
return text.replace(BACKTICK_SPAN_RE, (span) => INLINE_CODE_MASK_CHAR.repeat(span.length));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Puts the code spans of `original` back into `transformed`, a masked copy that was changed
|
|
17
|
+
* without changing its length (for example, case changes).
|
|
18
|
+
*/
|
|
19
|
+
export function restoreInlineCode(original, transformed) {
|
|
20
|
+
let result = '';
|
|
21
|
+
let cursor = 0;
|
|
22
|
+
for (const match of original.matchAll(BACKTICK_SPAN_RE)) {
|
|
23
|
+
const start = match.index ?? 0;
|
|
24
|
+
const end = start + match[0].length;
|
|
25
|
+
result += transformed.slice(cursor, start);
|
|
26
|
+
result += original.slice(start, end);
|
|
27
|
+
cursor = end;
|
|
28
|
+
}
|
|
29
|
+
result += transformed.slice(cursor);
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The `[start, end)` ranges of the inline code spans in `text`.
|
|
34
|
+
*
|
|
35
|
+
* Rules that run a user regex (`swap`, `pattern`) use these ranges to drop matches inside code.
|
|
36
|
+
* Masking would not work for them, because the mask characters can change what the regex matches.
|
|
37
|
+
*/
|
|
38
|
+
export function inlineCodeRanges(text) {
|
|
39
|
+
const ranges = [];
|
|
40
|
+
for (const match of text.matchAll(BACKTICK_SPAN_RE)) {
|
|
41
|
+
const start = match.index ?? 0;
|
|
42
|
+
ranges.push({ start, end: start + match[0].length });
|
|
43
|
+
}
|
|
44
|
+
return ranges;
|
|
45
|
+
}
|
|
46
|
+
/** Whether `[start, end)` overlaps any of `ranges`. Touching at an end does not count. */
|
|
47
|
+
export function overlapsAnyRange(start, end, ranges) {
|
|
48
|
+
return ranges.some((range) => start < range.end && range.start < end);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=inline-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-code.js","sourceRoot":"","sources":["../../src/core/inline-code.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AAEtD,gFAAgF;AAChF,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,qBAAqB,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AAC7F,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAgB,EAAE,WAAmB;IACrE,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACxD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;QAC/B,MAAM,GAAG,GAAG,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACpC,MAAM,IAAI,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAC3C,MAAM,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACrC,MAAM,GAAG,GAAG,CAAC;IACf,CAAC;IACD,MAAM,IAAI,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,MAAM,GAA0C,EAAE,CAAC;IACzD,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACpD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;QAC/B,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,gBAAgB,CAC9B,KAAa,EACb,GAAW,EACX,MAA6C;IAE7C,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Matches one line ending: CRLF, lone CR or LF. */
|
|
2
|
+
export declare const newLineRe: RegExp;
|
|
3
|
+
/**
|
|
4
|
+
* Maps a 0-based offset in `text` to a 1-based line and column. CRLF, CR and LF each count as one
|
|
5
|
+
* line ending. An offset at the `\n` of a CRLF is reported as column 1 of the next line.
|
|
6
|
+
*/
|
|
7
|
+
export declare function offsetToLineColumn(text: string, offset: number): {
|
|
8
|
+
line: number;
|
|
9
|
+
column: number;
|
|
10
|
+
};
|
|
11
|
+
/** Returns the most common line ending in `input`, or the platform default if there is none. */
|
|
12
|
+
export declare function getPreferredLineEnding(input: string): string;
|
|
13
|
+
//# sourceMappingURL=line-endings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line-endings.d.ts","sourceRoot":"","sources":["../../src/core/line-endings.ts"],"names":[],"mappings":"AAIA,oDAAoD;AACpD,eAAO,MAAM,SAAS,QAAc,CAAC;AAErC;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAQjG;AAED,gGAAgG;AAChG,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAa5D"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Based on markdownlint's `newlineRe` and `getPreferredLineEnding` (MIT, David Anson).
|
|
2
|
+
// Always split lines with `newLineRe`, never '\n', or CRLF files keep a trailing '\r' on every line.
|
|
3
|
+
import * as os from 'node:os';
|
|
4
|
+
/** Matches one line ending: CRLF, lone CR or LF. */
|
|
5
|
+
export const newLineRe = /\r\n?|\n/g;
|
|
6
|
+
/**
|
|
7
|
+
* Maps a 0-based offset in `text` to a 1-based line and column. CRLF, CR and LF each count as one
|
|
8
|
+
* line ending. An offset at the `\n` of a CRLF is reported as column 1 of the next line.
|
|
9
|
+
*/
|
|
10
|
+
export function offsetToLineColumn(text, offset) {
|
|
11
|
+
let line = 1;
|
|
12
|
+
let lineStart = 0;
|
|
13
|
+
for (const match of text.slice(0, offset).matchAll(newLineRe)) {
|
|
14
|
+
line++;
|
|
15
|
+
lineStart = match.index + match[0].length;
|
|
16
|
+
}
|
|
17
|
+
return { line, column: offset - lineStart + 1 };
|
|
18
|
+
}
|
|
19
|
+
/** Returns the most common line ending in `input`, or the platform default if there is none. */
|
|
20
|
+
export function getPreferredLineEnding(input) {
|
|
21
|
+
let cr = 0;
|
|
22
|
+
let lf = 0;
|
|
23
|
+
let crlf = 0;
|
|
24
|
+
const endings = input.match(newLineRe) ?? [];
|
|
25
|
+
for (const ending of endings) {
|
|
26
|
+
if (ending === '\r')
|
|
27
|
+
cr++;
|
|
28
|
+
else if (ending === '\n')
|
|
29
|
+
lf++;
|
|
30
|
+
else
|
|
31
|
+
crlf++;
|
|
32
|
+
}
|
|
33
|
+
if (!cr && !lf && !crlf)
|
|
34
|
+
return os.EOL;
|
|
35
|
+
if (lf >= crlf && lf >= cr)
|
|
36
|
+
return '\n';
|
|
37
|
+
return crlf >= cr ? '\r\n' : '\r';
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=line-endings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line-endings.js","sourceRoot":"","sources":["../../src/core/line-endings.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,qGAAqG;AACrG,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B,oDAAoD;AACpD,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAC;AAErC;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY,EAAE,MAAc;IAC7D,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9D,IAAI,EAAE,CAAC;QACP,SAAS,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC5C,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,CAAC,EAAE,CAAC;AAClD,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,sBAAsB,CAAC,KAAa;IAClD,IAAI,EAAE,GAAG,CAAC,CAAC;IACX,IAAI,EAAE,GAAG,CAAC,CAAC;IACX,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;IAC7C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,MAAM,KAAK,IAAI;YAAE,EAAE,EAAE,CAAC;aACrB,IAAI,MAAM,KAAK,IAAI;YAAE,EAAE,EAAE,CAAC;;YAC1B,IAAI,EAAE,CAAC;IACd,CAAC;IACD,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC,GAAG,CAAC;IACvC,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE,IAAI,EAAE;QAAE,OAAO,IAAI,CAAC;IACxC,OAAO,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { TokenTree } from '../parser/types.js';
|
|
2
|
+
import type { Fix } from '../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* The character that replaces a Markdoc tag in prose text (see `scopes/extractor.ts`). It is a
|
|
5
|
+
* space, so word splitting and sentence splitting treat the tag as a gap. A user regex cannot rely
|
|
6
|
+
* on this, so regex rules check match ranges instead (`ScopedSegment.maskedRanges`,
|
|
7
|
+
* `nonProseRanges` in `rules/utils.ts`).
|
|
8
|
+
*/
|
|
9
|
+
export declare const MARKDOC_TAG_MASK_CHAR = " ";
|
|
10
|
+
/**
|
|
11
|
+
* The source text of one Markdoc tag on one line. A tag that spans several lines gives one entry
|
|
12
|
+
* per line, because a `Fix` is always on a single line.
|
|
13
|
+
*/
|
|
14
|
+
export interface MarkdocTagSpan {
|
|
15
|
+
/** 1-based source line. */
|
|
16
|
+
line: number;
|
|
17
|
+
/** 1-based, inclusive. */
|
|
18
|
+
startColumn: number;
|
|
19
|
+
/** 1-based, exclusive. */
|
|
20
|
+
endColumn: number;
|
|
21
|
+
/** The source bytes between those columns — what must survive a fix. */
|
|
22
|
+
text: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The source span of every Markdoc tag in `content`, split by line. Empty when Markdoc parsing is
|
|
26
|
+
* off. Uses `filterByTypes` to skip tokens that repeat the position of their `htmlFlow` parent.
|
|
27
|
+
*/
|
|
28
|
+
export declare function markdocTagSpans(tree: TokenTree, content: string): MarkdocTagSpan[];
|
|
29
|
+
export interface ProtectedFixes {
|
|
30
|
+
/** Fixes that are safe to apply. */
|
|
31
|
+
fixes: Fix[];
|
|
32
|
+
/** Fixes that could not be made safe. The caller reports them as skipped. */
|
|
33
|
+
dropped: Fix[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Keeps `--fix` from changing Markdoc tags. Prose text has tags masked, so a fix that replaces a
|
|
37
|
+
* whole span would write the mask over the real tag and delete it. Every fix passes through here:
|
|
38
|
+
*
|
|
39
|
+
* - A fix that does not touch a tag is kept as is.
|
|
40
|
+
* - A fix that replaces text with the same number of characters keeps its place, and the original
|
|
41
|
+
* tag text is copied back in.
|
|
42
|
+
* - Any other fix that touches a tag is dropped and reported as skipped.
|
|
43
|
+
*
|
|
44
|
+
* A fix that changes nothing once the tags are restored is dropped too. Otherwise it would be
|
|
45
|
+
* reported as fixed and proposed again on every pass of `runRulesUntilStable`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function protectMarkdocTags(fixes: Fix[], spans: MarkdocTagSpan[], content: string): ProtectedFixes;
|
|
48
|
+
//# sourceMappingURL=markdoc-tags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdoc-tags.d.ts","sourceRoot":"","sources":["../../src/core/markdoc-tags.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAG7C;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,EAAE,CAoBlF;AAED,MAAM,WAAW,cAAc;IAC7B,oCAAoC;IACpC,KAAK,EAAE,GAAG,EAAE,CAAC;IACb,6EAA6E;IAC7E,OAAO,EAAE,GAAG,EAAE,CAAC;CAChB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,GAAG,EAAE,EACZ,KAAK,EAAE,cAAc,EAAE,EACvB,OAAO,EAAE,MAAM,GACd,cAAc,CAsDhB"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { filterByTypes } from '../parser/index.js';
|
|
2
|
+
import { newLineRe } from './line-endings.js';
|
|
3
|
+
/**
|
|
4
|
+
* The character that replaces a Markdoc tag in prose text (see `scopes/extractor.ts`). It is a
|
|
5
|
+
* space, so word splitting and sentence splitting treat the tag as a gap. A user regex cannot rely
|
|
6
|
+
* on this, so regex rules check match ranges instead (`ScopedSegment.maskedRanges`,
|
|
7
|
+
* `nonProseRanges` in `rules/utils.ts`).
|
|
8
|
+
*/
|
|
9
|
+
export const MARKDOC_TAG_MASK_CHAR = ' ';
|
|
10
|
+
/**
|
|
11
|
+
* The source span of every Markdoc tag in `content`, split by line. Empty when Markdoc parsing is
|
|
12
|
+
* off. Uses `filterByTypes` to skip tokens that repeat the position of their `htmlFlow` parent.
|
|
13
|
+
*/
|
|
14
|
+
export function markdocTagSpans(tree, content) {
|
|
15
|
+
const tags = filterByTypes(tree, ['markdocTag']);
|
|
16
|
+
if (tags.length === 0)
|
|
17
|
+
return [];
|
|
18
|
+
const sourceLines = content.split(newLineRe);
|
|
19
|
+
const spans = [];
|
|
20
|
+
for (const tag of tags) {
|
|
21
|
+
for (let line = tag.startLine; line <= tag.endLine; line++) {
|
|
22
|
+
const sourceLine = sourceLines[line - 1] ?? '';
|
|
23
|
+
const startColumn = line === tag.startLine ? tag.startColumn : 1;
|
|
24
|
+
const endColumn = line === tag.endLine ? tag.endColumn : sourceLine.length + 1;
|
|
25
|
+
if (endColumn <= startColumn)
|
|
26
|
+
continue;
|
|
27
|
+
spans.push({
|
|
28
|
+
line,
|
|
29
|
+
startColumn,
|
|
30
|
+
endColumn,
|
|
31
|
+
text: sourceLine.slice(startColumn - 1, endColumn - 1),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return spans;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Keeps `--fix` from changing Markdoc tags. Prose text has tags masked, so a fix that replaces a
|
|
39
|
+
* whole span would write the mask over the real tag and delete it. Every fix passes through here:
|
|
40
|
+
*
|
|
41
|
+
* - A fix that does not touch a tag is kept as is.
|
|
42
|
+
* - A fix that replaces text with the same number of characters keeps its place, and the original
|
|
43
|
+
* tag text is copied back in.
|
|
44
|
+
* - Any other fix that touches a tag is dropped and reported as skipped.
|
|
45
|
+
*
|
|
46
|
+
* A fix that changes nothing once the tags are restored is dropped too. Otherwise it would be
|
|
47
|
+
* reported as fixed and proposed again on every pass of `runRulesUntilStable`.
|
|
48
|
+
*/
|
|
49
|
+
export function protectMarkdocTags(fixes, spans, content) {
|
|
50
|
+
if (spans.length === 0 || fixes.length === 0)
|
|
51
|
+
return { fixes, dropped: [] };
|
|
52
|
+
const byLine = new Map();
|
|
53
|
+
for (const span of spans) {
|
|
54
|
+
const existing = byLine.get(span.line);
|
|
55
|
+
if (existing)
|
|
56
|
+
existing.push(span);
|
|
57
|
+
else
|
|
58
|
+
byLine.set(span.line, [span]);
|
|
59
|
+
}
|
|
60
|
+
const sourceLines = content.split(newLineRe);
|
|
61
|
+
const safe = [];
|
|
62
|
+
const dropped = [];
|
|
63
|
+
for (const fix of fixes) {
|
|
64
|
+
const lineSpans = byLine.get(fix.lineNumber);
|
|
65
|
+
if (lineSpans === undefined) {
|
|
66
|
+
safe.push(fix);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const deleteCount = fix.deleteCount ?? 0;
|
|
70
|
+
if (deleteCount === -1) {
|
|
71
|
+
dropped.push(fix);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const editColumn = fix.editColumn ?? 1;
|
|
75
|
+
const editEnd = editColumn + deleteCount;
|
|
76
|
+
const overlapped = lineSpans.filter((span) => editColumn < span.endColumn && span.startColumn < editEnd);
|
|
77
|
+
if (overlapped.length === 0) {
|
|
78
|
+
safe.push(fix);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const insertText = fix.insertText ?? '';
|
|
82
|
+
const splittable = insertText.length === deleteCount &&
|
|
83
|
+
overlapped.every((span) => span.startColumn >= editColumn && span.endColumn <= editEnd);
|
|
84
|
+
if (!splittable) {
|
|
85
|
+
dropped.push(fix);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
let restored = insertText;
|
|
89
|
+
for (const span of overlapped) {
|
|
90
|
+
const at = span.startColumn - editColumn;
|
|
91
|
+
restored = restored.slice(0, at) + span.text + restored.slice(at + span.text.length);
|
|
92
|
+
}
|
|
93
|
+
const replaced = (sourceLines[fix.lineNumber - 1] ?? '').slice(editColumn - 1, editEnd - 1);
|
|
94
|
+
if (restored === replaced) {
|
|
95
|
+
dropped.push(fix);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
safe.push({ ...fix, insertText: restored });
|
|
99
|
+
}
|
|
100
|
+
return { fixes: safe, dropped };
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=markdoc-tags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdoc-tags.js","sourceRoot":"","sources":["../../src/core/markdoc-tags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C;;;;;GAKG;A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AAU,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ScopedSegment } from '../scopes/types.js';
|
|
2
|
+
/** Removes Markdoc tags and inline code. */
|
|
3
|
+
export declare function stripNonProse(text: string): string;
|
|
4
|
+
/** Builds the prose blocks a readability score reads, from `summary` segments. */
|
|
5
|
+
export declare function extractProse(segments: ScopedSegment[]): string[];
|
|
6
|
+
//# sourceMappingURL=prose-extract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prose-extract.d.ts","sourceRoot":"","sources":["../../src/core/prose-extract.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAOxD,4CAA4C;AAC5C,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAyDD,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,MAAM,EAAE,CAgBhE"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { BACKTICK_SPAN_RE } from './inline-code.js';
|
|
2
|
+
// Markdoc tags. Non-greedy, so tags next to each other are removed one by one. Only used when
|
|
3
|
+
// Markdoc parsing is off; otherwise tags are already masked in `segment.maskedRanges`.
|
|
4
|
+
const MARKDOC_TAG_RE = /\{%-?[\s\S]*?-?%\}/g;
|
|
5
|
+
/** Removes Markdoc tags and inline code. */
|
|
6
|
+
export function stripNonProse(text) {
|
|
7
|
+
return text.replace(MARKDOC_TAG_RE, '').replace(BACKTICK_SPAN_RE, '');
|
|
8
|
+
}
|
|
9
|
+
// Cuts masked tags out of the text instead of leaving spaces, so `<code>{% x %}</code>` is one word.
|
|
10
|
+
function spliceOutMaskedSpans(segment) {
|
|
11
|
+
const ranges = segment.maskedRanges;
|
|
12
|
+
if (ranges === undefined)
|
|
13
|
+
return segment.content;
|
|
14
|
+
let result = '';
|
|
15
|
+
let cursor = 0;
|
|
16
|
+
for (const range of ranges) {
|
|
17
|
+
result += segment.content.slice(cursor, Math.max(range.start, cursor));
|
|
18
|
+
cursor = Math.max(range.end, cursor);
|
|
19
|
+
}
|
|
20
|
+
return result + segment.content.slice(cursor);
|
|
21
|
+
}
|
|
22
|
+
function comparePosition(aLine, aColumn, bLine, bColumn) {
|
|
23
|
+
return aLine - bLine || aColumn - bColumn;
|
|
24
|
+
}
|
|
25
|
+
function spanContains(outer, inner) {
|
|
26
|
+
return (comparePosition(outer.startLine, outer.startColumn, inner.startLine, inner.startColumn) <= 0 &&
|
|
27
|
+
comparePosition(outer.endLine, outer.endColumn, inner.endLine, inner.endColumn) >= 0);
|
|
28
|
+
}
|
|
29
|
+
// Drops segments that sit inside another segment, such as a list in a blockquote, so words are
|
|
30
|
+
// not counted twice. Sorted so that a container comes before what it contains.
|
|
31
|
+
function dedupeBySpanContainment(segments) {
|
|
32
|
+
const ordered = [...segments].sort((a, b) => {
|
|
33
|
+
const byStart = comparePosition(a.startLine, a.startColumn, b.startLine, b.startColumn);
|
|
34
|
+
if (byStart !== 0)
|
|
35
|
+
return byStart;
|
|
36
|
+
return comparePosition(b.endLine, b.endColumn, a.endLine, a.endColumn);
|
|
37
|
+
});
|
|
38
|
+
const stack = [];
|
|
39
|
+
const kept = [];
|
|
40
|
+
for (const segment of ordered) {
|
|
41
|
+
while (stack.length > 0) {
|
|
42
|
+
const top = stack[stack.length - 1];
|
|
43
|
+
if (comparePosition(top.endLine, top.endColumn, segment.startLine, segment.startColumn) < 0) {
|
|
44
|
+
stack.pop();
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const container = stack[stack.length - 1];
|
|
51
|
+
if (container && spanContains(container, segment))
|
|
52
|
+
continue;
|
|
53
|
+
kept.push(segment);
|
|
54
|
+
stack.push(segment);
|
|
55
|
+
}
|
|
56
|
+
return kept;
|
|
57
|
+
}
|
|
58
|
+
/** Builds the prose blocks a readability score reads, from `summary` segments. */
|
|
59
|
+
export function extractProse(segments) {
|
|
60
|
+
// Headings are fragments, so readability tools skip them.
|
|
61
|
+
const proseSegments = segments.filter((segment) => !segment.sourceScope?.startsWith('heading.'));
|
|
62
|
+
const deduped = dedupeBySpanContainment(proseSegments);
|
|
63
|
+
// Back to source order.
|
|
64
|
+
deduped.sort((a, b) => a.startLine - b.startLine || a.startColumn - b.startColumn);
|
|
65
|
+
return deduped
|
|
66
|
+
.map((segment) => segment.maskedRanges !== undefined
|
|
67
|
+
? spliceOutMaskedSpans(segment).replace(BACKTICK_SPAN_RE, '')
|
|
68
|
+
: stripNonProse(segment.content))
|
|
69
|
+
.filter((text) => text.trim() !== '');
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=prose-extract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prose-extract.js","sourceRoot":"","sources":["../../src/core/prose-extract.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,8FAA8F;AAC9F,uFAAuF;AACvF,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAE7C,4CAA4C;AAC5C,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;AACxE,CAAC;AAED,qGAAqG;AACrG,SAAS,oBAAoB,CAAC,OAAsB;IAClD,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IACpC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC,OAAO,CAAC;IACjD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,K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C,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC;IAEnF,OAAO,OAAO;SACX,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CACf,OAAO,CAAC,YAAY,KAAK,SAAS;QAChC,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC;QAC7D,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CACnC;SACA,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface DocumentReadability {
|
|
2
|
+
words: number;
|
|
3
|
+
sentences: number;
|
|
4
|
+
/** Flesch reading ease; higher is easier. Null when there is no prose. */
|
|
5
|
+
fleschReadingEase: number | null;
|
|
6
|
+
/** Flesch-Kincaid grade level. Null when there is no prose. */
|
|
7
|
+
fleschKincaidGrade: number | null;
|
|
8
|
+
/**
|
|
9
|
+
* Automated Readability Index, a grade level based on character counts. Null when there is no
|
|
10
|
+
* prose.
|
|
11
|
+
*/
|
|
12
|
+
automatedReadabilityIndex: number | null;
|
|
13
|
+
}
|
|
14
|
+
export declare function computeDocumentReadability(content: string, options?: {
|
|
15
|
+
markdoc?: boolean;
|
|
16
|
+
}): DocumentReadability;
|
|
17
|
+
//# sourceMappingURL=readability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readability.d.ts","sourceRoot":"","sources":["../../src/core/readability.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,+DAA+D;IAC/D,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC;;;OAGG;IACH,yBAAyB,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1C;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,GAClC,mBAAmB,CAiCrB"}
|