@redocly/recheck 0.1.0 → 0.3.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 +1023 -56
- package/dist/cli.js +40 -7
- package/dist/cli.js.map +1 -1
- package/dist/commands/markdoc-schema.d.ts +17 -0
- package/dist/commands/markdoc-schema.d.ts.map +1 -0
- package/dist/commands/markdoc-schema.js +127 -0
- package/dist/commands/markdoc-schema.js.map +1 -0
- package/dist/commands/run.d.ts +2 -1
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +87 -10
- package/dist/commands/run.js.map +1 -1
- package/dist/config/load.d.ts +11 -0
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +12 -2
- package/dist/config/load.js.map +1 -1
- package/dist/config/presets/google.d.ts +3 -0
- package/dist/config/presets/google.d.ts.map +1 -0
- package/dist/config/presets/google.js +1671 -0
- package/dist/config/presets/google.js.map +1 -0
- package/dist/config/presets/inclusive-language.d.ts +3 -0
- package/dist/config/presets/inclusive-language.d.ts.map +1 -0
- package/dist/config/presets/inclusive-language.js +321 -0
- package/dist/config/presets/inclusive-language.js.map +1 -0
- package/dist/config/presets/index.d.ts +67 -0
- package/dist/config/presets/index.d.ts.map +1 -0
- package/dist/config/presets/index.js +137 -0
- package/dist/config/presets/index.js.map +1 -0
- package/dist/config/presets/markdoc.d.ts +21 -0
- package/dist/config/presets/markdoc.d.ts.map +1 -0
- package/dist/config/presets/markdoc.js +101 -0
- package/dist/config/presets/markdoc.js.map +1 -0
- package/dist/config/presets/markdown-relaxed.d.ts +3 -0
- package/dist/config/presets/markdown-relaxed.d.ts.map +1 -0
- package/dist/config/presets/markdown-relaxed.js +98 -0
- package/dist/config/presets/markdown-relaxed.js.map +1 -0
- package/dist/config/presets/markdown.d.ts +43 -0
- package/dist/config/presets/markdown.d.ts.map +1 -0
- package/dist/config/presets/markdown.js +132 -0
- package/dist/config/presets/markdown.js.map +1 -0
- package/dist/config/presets/microsoft.d.ts +3 -0
- package/dist/config/presets/microsoft.d.ts.map +1 -0
- package/dist/config/presets/microsoft.js +2268 -0
- package/dist/config/presets/microsoft.js.map +1 -0
- package/dist/config/presets/minimal.d.ts +3 -0
- package/dist/config/presets/minimal.d.ts.map +1 -0
- package/dist/config/presets/minimal.js +21 -0
- package/dist/config/presets/minimal.js.map +1 -0
- package/dist/config/presets/plain-language.d.ts +3 -0
- package/dist/config/presets/plain-language.d.ts.map +1 -0
- package/dist/config/presets/plain-language.js +351 -0
- package/dist/config/presets/plain-language.js.map +1 -0
- package/dist/config/presets/prose.d.ts +52 -0
- package/dist/config/presets/prose.d.ts.map +1 -0
- package/dist/config/presets/prose.js +138 -0
- package/dist/config/presets/prose.js.map +1 -0
- package/dist/config/schema.d.ts +128 -22
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +105 -21
- package/dist/config/schema.js.map +1 -1
- package/dist/config/validate.d.ts +12 -2
- package/dist/config/validate.d.ts.map +1 -1
- package/dist/config/validate.js +1200 -44
- package/dist/config/validate.js.map +1 -1
- package/dist/core/auto-fix.d.ts +8 -13
- package/dist/core/auto-fix.d.ts.map +1 -1
- package/dist/core/auto-fix.js +94 -75
- package/dist/core/auto-fix.js.map +1 -1
- package/dist/core/case-preserve.d.ts +46 -0
- package/dist/core/case-preserve.d.ts.map +1 -0
- package/dist/core/case-preserve.js +57 -0
- package/dist/core/case-preserve.js.map +1 -0
- package/dist/core/directives.d.ts +9 -0
- package/dist/core/directives.d.ts.map +1 -0
- package/dist/core/directives.js +73 -0
- package/dist/core/directives.js.map +1 -0
- package/dist/core/files.d.ts +63 -0
- package/dist/core/files.d.ts.map +1 -1
- package/dist/core/files.js +185 -0
- package/dist/core/files.js.map +1 -1
- package/dist/core/inline-code.d.ts +87 -0
- package/dist/core/inline-code.d.ts.map +1 -0
- package/dist/core/inline-code.js +104 -0
- package/dist/core/inline-code.js.map +1 -0
- package/dist/core/line-endings.d.ts +32 -0
- package/dist/core/line-endings.d.ts.map +1 -0
- package/dist/core/line-endings.js +65 -0
- package/dist/core/line-endings.js.map +1 -0
- package/dist/core/markdoc-tags.d.ts +79 -0
- package/dist/core/markdoc-tags.d.ts.map +1 -0
- package/dist/core/markdoc-tags.js +131 -0
- package/dist/core/markdoc-tags.js.map +1 -0
- package/dist/core/rule-filters.d.ts +17 -0
- package/dist/core/rule-filters.d.ts.map +1 -1
- package/dist/core/rule-filters.js +64 -0
- package/dist/core/rule-filters.js.map +1 -1
- package/dist/core/runner.d.ts +92 -3
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +348 -110
- package/dist/core/runner.js.map +1 -1
- package/dist/core/timing.d.ts.map +1 -1
- package/dist/data/markdoc-realm-schema.d.ts +3 -0
- package/dist/data/markdoc-realm-schema.d.ts.map +1 -0
- package/dist/data/markdoc-realm-schema.js +760 -0
- package/dist/data/markdoc-realm-schema.js.map +1 -0
- package/dist/data/proper-nouns.d.ts +2 -0
- package/dist/data/proper-nouns.d.ts.map +1 -0
- package/dist/data/proper-nouns.js +47 -0
- package/dist/data/proper-nouns.js.map +1 -0
- package/dist/index.d.ts +90 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +152 -0
- package/dist/index.js.map +1 -0
- package/dist/metrics/formulas.d.ts +17 -0
- package/dist/metrics/formulas.d.ts.map +1 -0
- package/dist/metrics/formulas.js +70 -0
- package/dist/metrics/formulas.js.map +1 -0
- package/dist/metrics/index.d.ts +5 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +3 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/statistics.d.ts +27 -0
- package/dist/metrics/statistics.d.ts.map +1 -0
- package/dist/metrics/statistics.js +56 -0
- package/dist/metrics/statistics.js.map +1 -0
- package/dist/parser/index.d.ts +18 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +168 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/markdoc/extract-statics.d.ts +45 -0
- package/dist/parser/markdoc/extract-statics.d.ts.map +1 -0
- package/dist/parser/markdoc/extract-statics.js +139 -0
- package/dist/parser/markdoc/extract-statics.js.map +1 -0
- package/dist/parser/markdoc/pairing.d.ts +63 -0
- package/dist/parser/markdoc/pairing.d.ts.map +1 -0
- package/dist/parser/markdoc/pairing.js +94 -0
- package/dist/parser/markdoc/pairing.js.map +1 -0
- package/dist/parser/markdoc/schema.d.ts +85 -0
- package/dist/parser/markdoc/schema.d.ts.map +1 -0
- package/dist/parser/markdoc/schema.js +86 -0
- package/dist/parser/markdoc/schema.js.map +1 -0
- package/dist/parser/markdoc/span.d.ts +64 -0
- package/dist/parser/markdoc/span.d.ts.map +1 -0
- package/dist/parser/markdoc/span.js +729 -0
- package/dist/parser/markdoc/span.js.map +1 -0
- package/dist/parser/markdoc/structure.d.ts +28 -0
- package/dist/parser/markdoc/structure.d.ts.map +1 -0
- package/dist/parser/markdoc/structure.js +153 -0
- package/dist/parser/markdoc/structure.js.map +1 -0
- package/dist/parser/markdoc/syntax.d.ts +44 -0
- package/dist/parser/markdoc/syntax.d.ts.map +1 -0
- package/dist/parser/markdoc/syntax.js +317 -0
- package/dist/parser/markdoc/syntax.js.map +1 -0
- package/dist/parser/types.d.ts +18 -0
- package/dist/parser/types.d.ts.map +1 -0
- package/dist/parser/types.js.map +1 -0
- package/dist/reporter/fixes.d.ts.map +1 -1
- package/dist/reporter/fixes.js +22 -1
- package/dist/reporter/fixes.js.map +1 -1
- package/dist/reporter/statistics.d.ts +1 -8
- package/dist/reporter/statistics.d.ts.map +1 -1
- package/dist/reporter/statistics.js.map +1 -1
- package/dist/rules/registry.d.ts +15 -0
- package/dist/rules/registry.d.ts.map +1 -0
- package/dist/rules/registry.js +81 -0
- package/dist/rules/registry.js.map +1 -0
- package/dist/rules/scope/capitalization.d.ts +3 -0
- package/dist/rules/scope/capitalization.d.ts.map +1 -0
- package/dist/rules/scope/capitalization.js +163 -0
- package/dist/rules/scope/capitalization.js.map +1 -0
- package/dist/rules/scope/conditional.d.ts +3 -0
- package/dist/rules/scope/conditional.d.ts.map +1 -0
- package/dist/rules/scope/conditional.js +112 -0
- package/dist/rules/scope/conditional.js.map +1 -0
- package/dist/rules/scope/consistency.d.ts +3 -0
- package/dist/rules/scope/consistency.d.ts.map +1 -0
- package/dist/rules/scope/consistency.js +178 -0
- package/dist/rules/scope/consistency.js.map +1 -0
- package/dist/rules/scope/length.d.ts +3 -0
- package/dist/rules/scope/length.d.ts.map +1 -0
- package/dist/rules/scope/length.js +69 -0
- package/dist/rules/scope/length.js.map +1 -0
- package/dist/rules/scope/max-image-size.d.ts +3 -0
- package/dist/rules/scope/max-image-size.d.ts.map +1 -0
- package/dist/rules/scope/max-image-size.js +65 -0
- package/dist/rules/scope/max-image-size.js.map +1 -0
- package/dist/rules/scope/metric.d.ts +17 -0
- package/dist/rules/scope/metric.d.ts.map +1 -0
- package/dist/rules/scope/metric.js +216 -0
- package/dist/rules/scope/metric.js.map +1 -0
- package/dist/rules/scope/occurrence.d.ts +3 -0
- package/dist/rules/scope/occurrence.d.ts.map +1 -0
- package/dist/rules/scope/occurrence.js +48 -0
- package/dist/rules/scope/occurrence.js.map +1 -0
- package/dist/rules/scope/pattern.d.ts +3 -0
- package/dist/rules/scope/pattern.d.ts.map +1 -0
- package/dist/rules/scope/pattern.js +75 -0
- package/dist/rules/scope/pattern.js.map +1 -0
- package/dist/rules/scope/repetition.d.ts +3 -0
- package/dist/rules/scope/repetition.d.ts.map +1 -0
- package/dist/rules/scope/repetition.js +139 -0
- package/dist/rules/scope/repetition.js.map +1 -0
- package/dist/rules/scope/semantic-line-breaks.d.ts +3 -0
- package/dist/rules/scope/semantic-line-breaks.d.ts.map +1 -0
- package/dist/rules/scope/semantic-line-breaks.js +213 -0
- package/dist/rules/scope/semantic-line-breaks.js.map +1 -0
- package/dist/rules/scope/spelling.d.ts +27 -0
- package/dist/rules/scope/spelling.d.ts.map +1 -0
- package/dist/rules/scope/spelling.js +227 -0
- package/dist/rules/scope/spelling.js.map +1 -0
- package/dist/rules/scope/swap.d.ts +3 -0
- package/dist/rules/scope/swap.d.ts.map +1 -0
- package/dist/rules/scope/swap.js +149 -0
- package/dist/rules/scope/swap.js.map +1 -0
- package/dist/rules/scope/title-case.d.ts +46 -0
- package/dist/rules/scope/title-case.d.ts.map +1 -0
- package/dist/rules/scope/title-case.js +301 -0
- package/dist/rules/scope/title-case.js.map +1 -0
- package/dist/rules/token/blanks-around-fences.d.ts +3 -0
- package/dist/rules/token/blanks-around-fences.d.ts.map +1 -0
- package/dist/rules/token/blanks-around-fences.js +44 -0
- package/dist/rules/token/blanks-around-fences.js.map +1 -0
- package/dist/rules/token/blanks-around-headings.d.ts +3 -0
- package/dist/rules/token/blanks-around-headings.d.ts.map +1 -0
- package/dist/rules/token/blanks-around-headings.js +108 -0
- package/dist/rules/token/blanks-around-headings.js.map +1 -0
- package/dist/rules/token/blanks-around-lists.d.ts +3 -0
- package/dist/rules/token/blanks-around-lists.d.ts.map +1 -0
- package/dist/rules/token/blanks-around-lists.js +56 -0
- package/dist/rules/token/blanks-around-lists.js.map +1 -0
- package/dist/rules/token/blanks-around-tables.d.ts +3 -0
- package/dist/rules/token/blanks-around-tables.d.ts.map +1 -0
- package/dist/rules/token/blanks-around-tables.js +42 -0
- package/dist/rules/token/blanks-around-tables.js.map +1 -0
- package/dist/rules/token/code-block-style.d.ts +3 -0
- package/dist/rules/token/code-block-style.d.ts.map +1 -0
- package/dist/rules/token/code-block-style.js +30 -0
- package/dist/rules/token/code-block-style.js.map +1 -0
- package/dist/rules/token/code-fence-style.d.ts +3 -0
- package/dist/rules/token/code-fence-style.d.ts.map +1 -0
- package/dist/rules/token/code-fence-style.js +35 -0
- package/dist/rules/token/code-fence-style.js.map +1 -0
- package/dist/rules/token/commands-show-output.d.ts +3 -0
- package/dist/rules/token/commands-show-output.d.ts.map +1 -0
- package/dist/rules/token/commands-show-output.js +38 -0
- package/dist/rules/token/commands-show-output.js.map +1 -0
- package/dist/rules/token/descriptive-link-text.d.ts +3 -0
- package/dist/rules/token/descriptive-link-text.d.ts.map +1 -0
- package/dist/rules/token/descriptive-link-text.js +53 -0
- package/dist/rules/token/descriptive-link-text.js.map +1 -0
- package/dist/rules/token/emphasis-style.d.ts +3 -0
- package/dist/rules/token/emphasis-style.d.ts.map +1 -0
- package/dist/rules/token/emphasis-style.js +51 -0
- package/dist/rules/token/emphasis-style.js.map +1 -0
- package/dist/rules/token/fenced-code-language.d.ts +3 -0
- package/dist/rules/token/fenced-code-language.d.ts.map +1 -0
- package/dist/rules/token/fenced-code-language.js +35 -0
- package/dist/rules/token/fenced-code-language.js.map +1 -0
- package/dist/rules/token/first-line-h1.d.ts +3 -0
- package/dist/rules/token/first-line-h1.d.ts.map +1 -0
- package/dist/rules/token/first-line-h1.js +107 -0
- package/dist/rules/token/first-line-h1.js.map +1 -0
- package/dist/rules/token/heading-increment.d.ts +3 -0
- package/dist/rules/token/heading-increment.d.ts.map +1 -0
- package/dist/rules/token/heading-increment.js +27 -0
- package/dist/rules/token/heading-increment.js.map +1 -0
- package/dist/rules/token/heading-start-left.d.ts +3 -0
- package/dist/rules/token/heading-start-left.d.ts.map +1 -0
- package/dist/rules/token/heading-start-left.js +31 -0
- package/dist/rules/token/heading-start-left.js.map +1 -0
- package/dist/rules/token/heading-style.d.ts +3 -0
- package/dist/rules/token/heading-style.d.ts.map +1 -0
- package/dist/rules/token/heading-style.js +41 -0
- package/dist/rules/token/heading-style.js.map +1 -0
- package/dist/rules/token/helpers.d.ts +313 -0
- package/dist/rules/token/helpers.d.ts.map +1 -0
- package/dist/rules/token/helpers.js +746 -0
- package/dist/rules/token/helpers.js.map +1 -0
- package/dist/rules/token/hr-style.d.ts +3 -0
- package/dist/rules/token/hr-style.d.ts.map +1 -0
- package/dist/rules/token/hr-style.js +28 -0
- package/dist/rules/token/hr-style.js.map +1 -0
- package/dist/rules/token/index.d.ts +75 -0
- package/dist/rules/token/index.d.ts.map +1 -0
- package/dist/rules/token/index.js +226 -0
- package/dist/rules/token/index.js.map +1 -0
- package/dist/rules/token/line-length.d.ts +3 -0
- package/dist/rules/token/line-length.d.ts.map +1 -0
- package/dist/rules/token/line-length.js +120 -0
- package/dist/rules/token/line-length.js.map +1 -0
- package/dist/rules/token/link-fragments.d.ts +3 -0
- package/dist/rules/token/link-fragments.d.ts.map +1 -0
- package/dist/rules/token/link-fragments.js +145 -0
- package/dist/rules/token/link-fragments.js.map +1 -0
- package/dist/rules/token/link-image-reference-definitions.d.ts +3 -0
- package/dist/rules/token/link-image-reference-definitions.d.ts.map +1 -0
- package/dist/rules/token/link-image-reference-definitions.js +50 -0
- package/dist/rules/token/link-image-reference-definitions.js.map +1 -0
- package/dist/rules/token/link-image-style.d.ts +3 -0
- package/dist/rules/token/link-image-style.d.ts.map +1 -0
- package/dist/rules/token/link-image-style.js +131 -0
- package/dist/rules/token/link-image-style.js.map +1 -0
- package/dist/rules/token/list-indent.d.ts +3 -0
- package/dist/rules/token/list-indent.d.ts.map +1 -0
- package/dist/rules/token/list-indent.js +60 -0
- package/dist/rules/token/list-indent.js.map +1 -0
- package/dist/rules/token/list-length.d.ts +3 -0
- package/dist/rules/token/list-length.d.ts.map +1 -0
- package/dist/rules/token/list-length.js +55 -0
- package/dist/rules/token/list-length.js.map +1 -0
- package/dist/rules/token/list-marker-space.d.ts +3 -0
- package/dist/rules/token/list-marker-space.d.ts.map +1 -0
- package/dist/rules/token/list-marker-space.js +52 -0
- package/dist/rules/token/list-marker-space.js.map +1 -0
- package/dist/rules/token/markdoc-attributes.d.ts +3 -0
- package/dist/rules/token/markdoc-attributes.d.ts.map +1 -0
- package/dist/rules/token/markdoc-attributes.js +269 -0
- package/dist/rules/token/markdoc-attributes.js.map +1 -0
- package/dist/rules/token/markdoc-pairing.d.ts +3 -0
- package/dist/rules/token/markdoc-pairing.d.ts.map +1 -0
- package/dist/rules/token/markdoc-pairing.js +73 -0
- package/dist/rules/token/markdoc-pairing.js.map +1 -0
- package/dist/rules/token/markdoc-syntax.d.ts +3 -0
- package/dist/rules/token/markdoc-syntax.d.ts.map +1 -0
- package/dist/rules/token/markdoc-syntax.js +119 -0
- package/dist/rules/token/markdoc-syntax.js.map +1 -0
- package/dist/rules/token/markdoc-unknown-tag.d.ts +3 -0
- package/dist/rules/token/markdoc-unknown-tag.d.ts.map +1 -0
- package/dist/rules/token/markdoc-unknown-tag.js +64 -0
- package/dist/rules/token/markdoc-unknown-tag.js.map +1 -0
- package/dist/rules/token/messages.d.ts +4 -0
- package/dist/rules/token/messages.d.ts.map +1 -0
- package/dist/rules/token/messages.js +20 -0
- package/dist/rules/token/messages.js.map +1 -0
- package/dist/rules/token/no-alt-text.d.ts +3 -0
- package/dist/rules/token/no-alt-text.d.ts.map +1 -0
- package/dist/rules/token/no-alt-text.js +47 -0
- package/dist/rules/token/no-alt-text.js.map +1 -0
- package/dist/rules/token/no-bare-urls.d.ts +3 -0
- package/dist/rules/token/no-bare-urls.d.ts.map +1 -0
- package/dist/rules/token/no-bare-urls.js +88 -0
- package/dist/rules/token/no-bare-urls.js.map +1 -0
- package/dist/rules/token/no-blanks-blockquote.d.ts +3 -0
- package/dist/rules/token/no-blanks-blockquote.d.ts.map +1 -0
- package/dist/rules/token/no-blanks-blockquote.js +39 -0
- package/dist/rules/token/no-blanks-blockquote.js.map +1 -0
- package/dist/rules/token/no-duplicate-heading.d.ts +3 -0
- package/dist/rules/token/no-duplicate-heading.d.ts.map +1 -0
- package/dist/rules/token/no-duplicate-heading.js +101 -0
- package/dist/rules/token/no-duplicate-heading.js.map +1 -0
- package/dist/rules/token/no-duplicate-link-destinations.d.ts +3 -0
- package/dist/rules/token/no-duplicate-link-destinations.d.ts.map +1 -0
- package/dist/rules/token/no-duplicate-link-destinations.js +65 -0
- package/dist/rules/token/no-duplicate-link-destinations.js.map +1 -0
- package/dist/rules/token/no-emphasis-as-heading.d.ts +3 -0
- package/dist/rules/token/no-emphasis-as-heading.d.ts.map +1 -0
- package/dist/rules/token/no-emphasis-as-heading.js +44 -0
- package/dist/rules/token/no-emphasis-as-heading.js.map +1 -0
- package/dist/rules/token/no-empty-headings.d.ts +3 -0
- package/dist/rules/token/no-empty-headings.d.ts.map +1 -0
- package/dist/rules/token/no-empty-headings.js +28 -0
- package/dist/rules/token/no-empty-headings.js.map +1 -0
- package/dist/rules/token/no-empty-links.d.ts +3 -0
- package/dist/rules/token/no-empty-links.d.ts.map +1 -0
- package/dist/rules/token/no-empty-links.js +67 -0
- package/dist/rules/token/no-empty-links.js.map +1 -0
- package/dist/rules/token/no-hard-tabs.d.ts +3 -0
- package/dist/rules/token/no-hard-tabs.d.ts.map +1 -0
- package/dist/rules/token/no-hard-tabs.js +76 -0
- package/dist/rules/token/no-hard-tabs.js.map +1 -0
- package/dist/rules/token/no-inline-html.d.ts +3 -0
- package/dist/rules/token/no-inline-html.d.ts.map +1 -0
- package/dist/rules/token/no-inline-html.js +45 -0
- package/dist/rules/token/no-inline-html.js.map +1 -0
- package/dist/rules/token/no-missing-space-atx.d.ts +3 -0
- package/dist/rules/token/no-missing-space-atx.d.ts.map +1 -0
- package/dist/rules/token/no-missing-space-atx.js +36 -0
- package/dist/rules/token/no-missing-space-atx.js.map +1 -0
- package/dist/rules/token/no-missing-space-closed-atx.d.ts +3 -0
- package/dist/rules/token/no-missing-space-closed-atx.d.ts.map +1 -0
- package/dist/rules/token/no-missing-space-closed-atx.js +45 -0
- package/dist/rules/token/no-missing-space-closed-atx.js.map +1 -0
- package/dist/rules/token/no-multiple-blanks.d.ts +3 -0
- package/dist/rules/token/no-multiple-blanks.d.ts.map +1 -0
- package/dist/rules/token/no-multiple-blanks.js +35 -0
- package/dist/rules/token/no-multiple-blanks.js.map +1 -0
- package/dist/rules/token/no-multiple-space-atx.d.ts +13 -0
- package/dist/rules/token/no-multiple-space-atx.d.ts.map +1 -0
- package/dist/rules/token/no-multiple-space-atx.js +50 -0
- package/dist/rules/token/no-multiple-space-atx.js.map +1 -0
- package/dist/rules/token/no-multiple-space-blockquote.d.ts +3 -0
- package/dist/rules/token/no-multiple-space-blockquote.d.ts.map +1 -0
- package/dist/rules/token/no-multiple-space-blockquote.js +43 -0
- package/dist/rules/token/no-multiple-space-blockquote.js.map +1 -0
- package/dist/rules/token/no-multiple-space-closed-atx.d.ts +3 -0
- package/dist/rules/token/no-multiple-space-closed-atx.d.ts.map +1 -0
- package/dist/rules/token/no-multiple-space-closed-atx.js +19 -0
- package/dist/rules/token/no-multiple-space-closed-atx.js.map +1 -0
- package/dist/rules/token/no-reversed-links.d.ts +3 -0
- package/dist/rules/token/no-reversed-links.d.ts.map +1 -0
- package/dist/rules/token/no-reversed-links.js +52 -0
- package/dist/rules/token/no-reversed-links.js.map +1 -0
- package/dist/rules/token/no-space-in-code.d.ts +3 -0
- package/dist/rules/token/no-space-in-code.d.ts.map +1 -0
- package/dist/rules/token/no-space-in-code.js +75 -0
- package/dist/rules/token/no-space-in-code.js.map +1 -0
- package/dist/rules/token/no-space-in-emphasis.d.ts +3 -0
- package/dist/rules/token/no-space-in-emphasis.d.ts.map +1 -0
- package/dist/rules/token/no-space-in-emphasis.js +79 -0
- package/dist/rules/token/no-space-in-emphasis.js.map +1 -0
- package/dist/rules/token/no-space-in-links.d.ts +3 -0
- package/dist/rules/token/no-space-in-links.d.ts.map +1 -0
- package/dist/rules/token/no-space-in-links.js +48 -0
- package/dist/rules/token/no-space-in-links.js.map +1 -0
- package/dist/rules/token/no-trailing-punctuation.d.ts +3 -0
- package/dist/rules/token/no-trailing-punctuation.d.ts.map +1 -0
- package/dist/rules/token/no-trailing-punctuation.js +38 -0
- package/dist/rules/token/no-trailing-punctuation.js.map +1 -0
- package/dist/rules/token/no-trailing-spaces.d.ts +3 -0
- package/dist/rules/token/no-trailing-spaces.d.ts.map +1 -0
- package/dist/rules/token/no-trailing-spaces.js +89 -0
- package/dist/rules/token/no-trailing-spaces.js.map +1 -0
- package/dist/rules/token/ol-prefix.d.ts +3 -0
- package/dist/rules/token/ol-prefix.d.ts.map +1 -0
- package/dist/rules/token/ol-prefix.js +70 -0
- package/dist/rules/token/ol-prefix.js.map +1 -0
- package/dist/rules/token/proper-names.d.ts +3 -0
- package/dist/rules/token/proper-names.d.ts.map +1 -0
- package/dist/rules/token/proper-names.js +93 -0
- package/dist/rules/token/proper-names.js.map +1 -0
- package/dist/rules/token/reference-links-images.d.ts +3 -0
- package/dist/rules/token/reference-links-images.d.ts.map +1 -0
- package/dist/rules/token/reference-links-images.js +36 -0
- package/dist/rules/token/reference-links-images.js.map +1 -0
- package/dist/rules/token/required-headings.d.ts +3 -0
- package/dist/rules/token/required-headings.d.ts.map +1 -0
- package/dist/rules/token/required-headings.js +83 -0
- package/dist/rules/token/required-headings.js.map +1 -0
- package/dist/rules/token/single-h1.d.ts +3 -0
- package/dist/rules/token/single-h1.d.ts.map +1 -0
- package/dist/rules/token/single-h1.js +56 -0
- package/dist/rules/token/single-h1.js.map +1 -0
- package/dist/rules/token/single-trailing-newline.d.ts +3 -0
- package/dist/rules/token/single-trailing-newline.d.ts.map +1 -0
- package/dist/rules/token/single-trailing-newline.js +25 -0
- package/dist/rules/token/single-trailing-newline.js.map +1 -0
- package/dist/rules/token/strong-style.d.ts +3 -0
- package/dist/rules/token/strong-style.d.ts.map +1 -0
- package/dist/rules/token/strong-style.js +51 -0
- package/dist/rules/token/strong-style.js.map +1 -0
- package/dist/rules/token/table-column-count.d.ts +3 -0
- package/dist/rules/token/table-column-count.d.ts.map +1 -0
- package/dist/rules/token/table-column-count.js +44 -0
- package/dist/rules/token/table-column-count.js.map +1 -0
- package/dist/rules/token/table-column-style.d.ts +3 -0
- package/dist/rules/token/table-column-style.d.ts.map +1 -0
- package/dist/rules/token/table-column-style.js +179 -0
- package/dist/rules/token/table-column-style.js.map +1 -0
- package/dist/rules/token/table-pipe-style.d.ts +3 -0
- package/dist/rules/token/table-pipe-style.d.ts.map +1 -0
- package/dist/rules/token/table-pipe-style.js +54 -0
- package/dist/rules/token/table-pipe-style.js.map +1 -0
- package/dist/rules/token/ul-indent.d.ts +3 -0
- package/dist/rules/token/ul-indent.d.ts.map +1 -0
- package/dist/rules/token/ul-indent.js +72 -0
- package/dist/rules/token/ul-indent.js.map +1 -0
- package/dist/rules/token/ul-style.d.ts +3 -0
- package/dist/rules/token/ul-style.d.ts.map +1 -0
- package/dist/rules/token/ul-style.js +80 -0
- package/dist/rules/token/ul-style.js.map +1 -0
- package/dist/rules/types.d.ts +81 -0
- package/dist/rules/types.d.ts.map +1 -0
- package/dist/rules/types.js +2 -0
- package/dist/rules/types.js.map +1 -0
- package/dist/rules/utils.d.ts +29 -0
- package/dist/rules/utils.d.ts.map +1 -0
- package/dist/{assertions → rules}/utils.js +27 -0
- package/dist/rules/utils.js.map +1 -0
- package/dist/scopes/extractor.d.ts +7 -0
- package/dist/scopes/extractor.d.ts.map +1 -0
- package/dist/scopes/extractor.js +475 -0
- package/dist/scopes/extractor.js.map +1 -0
- package/dist/scopes/selector.d.ts +51 -0
- package/dist/scopes/selector.d.ts.map +1 -0
- package/dist/scopes/selector.js +121 -0
- package/dist/scopes/selector.js.map +1 -0
- package/dist/scopes/sentences.d.ts +15 -0
- package/dist/scopes/sentences.d.ts.map +1 -0
- package/dist/scopes/sentences.js +124 -0
- package/dist/scopes/sentences.js.map +1 -0
- package/dist/scopes/types.d.ts +44 -0
- package/dist/scopes/types.d.ts.map +1 -0
- package/dist/scopes/types.js +2 -0
- package/dist/scopes/types.js.map +1 -0
- package/dist/scopes/vocabulary.d.ts +16 -0
- package/dist/scopes/vocabulary.d.ts.map +1 -0
- package/dist/scopes/vocabulary.js +70 -0
- package/dist/scopes/vocabulary.js.map +1 -0
- package/dist/types/assertions.d.ts +95 -32
- package/dist/types/assertions.d.ts.map +1 -1
- package/dist/types/problems.d.ts +4 -5
- package/dist/types/problems.d.ts.map +1 -1
- package/dist/types/rules.d.ts +4 -6
- package/dist/types/rules.d.ts.map +1 -1
- package/examples/appendices/google.appendix.yaml +91 -0
- package/examples/appendices/inclusive-language.appendix.yaml +61 -0
- package/examples/appendices/microsoft.appendix.yaml +99 -0
- package/examples/appendices/plain-language.appendix.yaml +88 -0
- package/examples/google.yaml +1525 -0
- package/examples/inclusive-language.yaml +304 -0
- package/examples/microsoft.yaml +1542 -0
- package/examples/plain-language.yaml +325 -0
- package/package.json +49 -16
- package/presets/google/PROVENANCE.md +1022 -0
- package/presets/google/sources.json +192 -0
- package/presets/inclusive-language/PROVENANCE.md +174 -0
- package/presets/inclusive-language/sources.json +107 -0
- package/presets/microsoft/PROVENANCE.md +1555 -0
- package/presets/microsoft/sources.json +494 -0
- package/presets/plain-language/PROVENANCE.md +364 -0
- package/presets/plain-language/sources.json +108 -0
- package/dist/assertions/bullet-style.d.ts +0 -3
- package/dist/assertions/bullet-style.d.ts.map +0 -1
- package/dist/assertions/bullet-style.js +0 -60
- package/dist/assertions/bullet-style.js.map +0 -1
- package/dist/assertions/index.d.ts +0 -21
- package/dist/assertions/index.d.ts.map +0 -1
- package/dist/assertions/index.js +0 -30
- package/dist/assertions/index.js.map +0 -1
- package/dist/assertions/max-image-size.d.ts +0 -3
- package/dist/assertions/max-image-size.d.ts.map +0 -1
- package/dist/assertions/max-image-size.js +0 -73
- package/dist/assertions/max-image-size.js.map +0 -1
- package/dist/assertions/max-line-length.d.ts +0 -3
- package/dist/assertions/max-line-length.d.ts.map +0 -1
- package/dist/assertions/max-line-length.js +0 -68
- package/dist/assertions/max-line-length.js.map +0 -1
- package/dist/assertions/no-broken-fragment-links.d.ts +0 -3
- package/dist/assertions/no-broken-fragment-links.d.ts.map +0 -1
- package/dist/assertions/no-broken-fragment-links.js +0 -79
- package/dist/assertions/no-broken-fragment-links.js.map +0 -1
- package/dist/assertions/no-duplicate-headings.d.ts +0 -3
- package/dist/assertions/no-duplicate-headings.d.ts.map +0 -1
- package/dist/assertions/no-duplicate-headings.js +0 -66
- package/dist/assertions/no-duplicate-headings.js.map +0 -1
- package/dist/assertions/no-hard-tabs.d.ts +0 -3
- package/dist/assertions/no-hard-tabs.d.ts.map +0 -1
- package/dist/assertions/no-hard-tabs.js +0 -63
- package/dist/assertions/no-hard-tabs.js.map +0 -1
- package/dist/assertions/no-trailing-spaces.d.ts +0 -3
- package/dist/assertions/no-trailing-spaces.d.ts.map +0 -1
- package/dist/assertions/no-trailing-spaces.js +0 -72
- package/dist/assertions/no-trailing-spaces.js.map +0 -1
- package/dist/assertions/pattern.d.ts +0 -3
- package/dist/assertions/pattern.d.ts.map +0 -1
- package/dist/assertions/pattern.js +0 -39
- package/dist/assertions/pattern.js.map +0 -1
- package/dist/assertions/semantic-line-breaks.d.ts +0 -3
- package/dist/assertions/semantic-line-breaks.d.ts.map +0 -1
- package/dist/assertions/semantic-line-breaks.js +0 -152
- package/dist/assertions/semantic-line-breaks.js.map +0 -1
- package/dist/assertions/swap.d.ts +0 -3
- package/dist/assertions/swap.d.ts.map +0 -1
- package/dist/assertions/swap.js +0 -39
- package/dist/assertions/swap.js.map +0 -1
- package/dist/assertions/utils.d.ts +0 -8
- package/dist/assertions/utils.d.ts.map +0 -1
- package/dist/assertions/utils.js.map +0 -1
- package/dist/core/scope-parser.d.ts +0 -26
- package/dist/core/scope-parser.d.ts.map +0 -1
- package/dist/core/scope-parser.js +0 -110
- package/dist/core/scope-parser.js.map +0 -1
- package/dist/files.d.ts +0 -2
- package/dist/files.d.ts.map +0 -1
- package/dist/files.js +0 -39
- package/dist/files.js.map +0 -1
- package/dist/load-config.d.ts +0 -25
- package/dist/load-config.d.ts.map +0 -1
- package/dist/load-config.js +0 -104
- package/dist/load-config.js.map +0 -1
- package/dist/load.d.ts +0 -25
- package/dist/load.d.ts.map +0 -1
- package/dist/load.js +0 -112
- package/dist/load.js.map +0 -1
- package/dist/scope.d.ts +0 -26
- package/dist/scope.d.ts.map +0 -1
- package/dist/scope.js +0 -110
- package/dist/scope.js.map +0 -1
- package/dist/types.d.ts +0 -109
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/validate.d.ts +0 -31
- package/dist/validate.d.ts.map +0 -1
- package/dist/validate.js +0 -154
- package/dist/validate.js.map +0 -1
- /package/dist/{types.js → parser/types.js} +0 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// Micromark wrapper producing Recheck's public TokenTree.
|
|
2
|
+
// Event-to-tree construction adapted from markdownlint's lib/micromark-parse.mjs
|
|
3
|
+
// (https://github.com/DavidAnson/markdownlint, MIT © David Anson).
|
|
4
|
+
import { parse, postprocess, preprocess } from 'micromark';
|
|
5
|
+
import { directive } from 'micromark-extension-directive';
|
|
6
|
+
import { frontmatter } from 'micromark-extension-frontmatter';
|
|
7
|
+
import { gfmAutolinkLiteral } from 'micromark-extension-gfm-autolink-literal';
|
|
8
|
+
import { gfmFootnote } from 'micromark-extension-gfm-footnote';
|
|
9
|
+
import { gfmTable } from 'micromark-extension-gfm-table';
|
|
10
|
+
import { math } from 'micromark-extension-math';
|
|
11
|
+
import { markdocSyntax } from './markdoc/syntax.js';
|
|
12
|
+
import { structureMarkdocTags } from './markdoc/structure.js';
|
|
13
|
+
const baseExtensions = [
|
|
14
|
+
directive(),
|
|
15
|
+
gfmAutolinkLiteral(),
|
|
16
|
+
gfmFootnote(),
|
|
17
|
+
gfmTable(),
|
|
18
|
+
math(),
|
|
19
|
+
frontmatter(['yaml']),
|
|
20
|
+
];
|
|
21
|
+
// Forces htmlFlow (block HTML) regions to be reparsed as if they were
|
|
22
|
+
// regular inline content -- disabling the `codeIndented`/`htmlFlow` block
|
|
23
|
+
// constructs makes micromark fall through to paragraph/inline tokenization
|
|
24
|
+
// for the same text, which is exactly what upstream markdownlint's own
|
|
25
|
+
// `micromark-parse.mjs` shim does (it disables the identical pair) to
|
|
26
|
+
// produce real `htmlText` tokens for tags inside HTML blocks. See
|
|
27
|
+
// `reparseHtmlFlow` below.
|
|
28
|
+
const htmlFlowReparseExtension = { disable: { null: ['codeIndented', 'htmlFlow'] } };
|
|
29
|
+
function getEvents(content, extensions) {
|
|
30
|
+
const parseContext = parse({ extensions });
|
|
31
|
+
const chunks = preprocess()(content, undefined, true);
|
|
32
|
+
return postprocess(parseContext.document().write(chunks));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Builds a Token tree from a flat micromark event list. `lineOffset` and
|
|
36
|
+
* `firstLineColumnOffset` translate positions that are relative to
|
|
37
|
+
* `content` (starting at line 1, column 1) into the surrounding
|
|
38
|
+
* document's coordinate space -- used by `reparseHtmlFlow` below to splice
|
|
39
|
+
* a reparsed `htmlFlow` block's tokens back in at their real position.
|
|
40
|
+
* `content` itself must already be the exact document (or sub-region)
|
|
41
|
+
* text so `start.offset`/`end.offset` slicing stays correct.
|
|
42
|
+
*/
|
|
43
|
+
function buildTree(events, content, lineOffset = 0, firstLineColumnOffset = 0) {
|
|
44
|
+
const children = [];
|
|
45
|
+
const flat = [];
|
|
46
|
+
const stack = [];
|
|
47
|
+
const adjustLine = (line) => line + lineOffset;
|
|
48
|
+
const adjustColumn = (line, column) => line === 1 ? column + firstLineColumnOffset : column;
|
|
49
|
+
for (const event of events) {
|
|
50
|
+
const [kind, mmToken] = event;
|
|
51
|
+
if (kind === 'enter') {
|
|
52
|
+
const parent = stack[stack.length - 1] ?? null;
|
|
53
|
+
const token = {
|
|
54
|
+
type: mmToken.type,
|
|
55
|
+
startLine: adjustLine(mmToken.start.line),
|
|
56
|
+
startColumn: adjustColumn(mmToken.start.line, mmToken.start.column),
|
|
57
|
+
endLine: adjustLine(mmToken.end.line),
|
|
58
|
+
endColumn: adjustColumn(mmToken.end.line, mmToken.end.column),
|
|
59
|
+
text: '',
|
|
60
|
+
children: [],
|
|
61
|
+
parent,
|
|
62
|
+
};
|
|
63
|
+
(parent ? parent.children : children).push(token);
|
|
64
|
+
flat.push(token);
|
|
65
|
+
stack.push(token);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
const token = stack.pop();
|
|
69
|
+
if (token) {
|
|
70
|
+
// Slice from the original content via absolute offsets rather than
|
|
71
|
+
// `context.sliceSerialize`. Nested/subtokenized content (e.g. list
|
|
72
|
+
// items containing sublists) can leave an exit event's `context`
|
|
73
|
+
// pointing at a tokenizer buffer that no longer covers this token,
|
|
74
|
+
// crashing `sliceSerialize`. `start.offset`/`end.offset` are stable
|
|
75
|
+
// document-absolute positions, so slicing `content` directly avoids
|
|
76
|
+
// depending on which context object emitted the event, matching
|
|
77
|
+
// markdownlint's lib/micromark-parse.mjs `getText` helper (MIT).
|
|
78
|
+
token.text = content.slice(mmToken.start.offset, mmToken.end.offset);
|
|
79
|
+
token.endLine = adjustLine(mmToken.end.line);
|
|
80
|
+
token.endColumn = adjustColumn(mmToken.end.line, mmToken.end.column);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return { children, flat };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Returns true iff the token is an HTML comment (`<!-- ... -->`) that is
|
|
88
|
+
* valid per the CommonMark spec. Duplicated (narrowly) from
|
|
89
|
+
* rules/token/helpers.ts's `isHtmlFlowComment` rather than imported --
|
|
90
|
+
* that module is rule-layer code that itself depends on parser types, and
|
|
91
|
+
* this parser module must not depend back on the rules layer.
|
|
92
|
+
*/
|
|
93
|
+
function isHtmlFlowComment(token) {
|
|
94
|
+
const { text, type } = token;
|
|
95
|
+
if (type === 'htmlFlow' && text.startsWith('<!--') && text.endsWith('-->')) {
|
|
96
|
+
const comment = text.slice(4, -3);
|
|
97
|
+
return !comment.startsWith('>') && !comment.startsWith('->') && !comment.endsWith('-');
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Re-tokenizes every non-comment `htmlFlow` (block HTML) token's own text
|
|
103
|
+
* as inline content, splicing the result in as that token's children (and
|
|
104
|
+
* into `flat`) so rules that look for `htmlText` tokens (e.g. MD033
|
|
105
|
+
* no-inline-html) see tags inside HTML blocks -- not just genuinely
|
|
106
|
+
* inline HTML -- exactly like upstream markdownlint (see
|
|
107
|
+
* `htmlFlowReparseExtension`'s doc comment). Mutates `tree.flat` in place;
|
|
108
|
+
* `tree.children` already references the same token objects, so no
|
|
109
|
+
* further mutation is needed there.
|
|
110
|
+
*
|
|
111
|
+
* A block like:
|
|
112
|
+
* <details>
|
|
113
|
+
* <summary>Text</summary>
|
|
114
|
+
* is ONE `htmlFlow` token whose raw text spans both lines; reparsing it
|
|
115
|
+
* with `codeIndented`/`htmlFlow` disabled naturally produces `htmlText`
|
|
116
|
+
* tokens for `<details>`, `<summary>`, and `</summary>` as descendants,
|
|
117
|
+
* which is what makes the fix work even when multiple tags/lines are
|
|
118
|
+
* inside a single flow block.
|
|
119
|
+
*/
|
|
120
|
+
function reparseHtmlFlow(tree) {
|
|
121
|
+
const htmlFlowTokens = tree.flat.filter((token) => token.type === 'htmlFlow' && !isHtmlFlowComment(token));
|
|
122
|
+
for (const token of htmlFlowTokens) {
|
|
123
|
+
const events = getEvents(token.text, [...baseExtensions, htmlFlowReparseExtension]);
|
|
124
|
+
const reparsed = buildTree(events, token.text, token.startLine - 1, token.startColumn - 1);
|
|
125
|
+
// Re-parent every reparsed token onto the original htmlFlow token, mark
|
|
126
|
+
// it `inHtmlFlow` (see Token's doc comment -- lets `filterByTypes`
|
|
127
|
+
// exclude this synthetic content by default, matching upstream), and
|
|
128
|
+
// add them all to the shared flat list. The htmlFlow token's OWN
|
|
129
|
+
// top-level type/text/position are left untouched -- only its
|
|
130
|
+
// (previously empty-of-inline-tags) children are replaced.
|
|
131
|
+
for (const descendant of reparsed.flat)
|
|
132
|
+
descendant.inHtmlFlow = true;
|
|
133
|
+
for (const child of reparsed.children)
|
|
134
|
+
child.parent = token;
|
|
135
|
+
token.children = reparsed.children;
|
|
136
|
+
// Push one-by-one: spreading an unbounded array as arguments overflows
|
|
137
|
+
// the call stack on huge HTML blocks (tens of thousands of lines), and
|
|
138
|
+
// this pass must never throw on a large document.
|
|
139
|
+
for (const descendant of reparsed.flat)
|
|
140
|
+
tree.flat.push(descendant);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
export function parseMarkdown(content, options = {}) {
|
|
144
|
+
// With the flag off, the extension list and the post-passes are identical to
|
|
145
|
+
// a parse that knows nothing about Markdoc -- `markdocSyntax()` is never even
|
|
146
|
+
// instantiated -- so the tree stays byte-identical by construction.
|
|
147
|
+
const extensions = options.markdoc ? [...baseExtensions, markdocSyntax(content)] : baseExtensions;
|
|
148
|
+
const events = getEvents(content, extensions);
|
|
149
|
+
const tree = buildTree(events, content);
|
|
150
|
+
reparseHtmlFlow(tree);
|
|
151
|
+
if (options.markdoc)
|
|
152
|
+
structureMarkdocTags(tree);
|
|
153
|
+
return tree;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Filters the tree's flat token list by type. By default, tokens produced
|
|
157
|
+
* by reparsing an `htmlFlow` block (see `reparseHtmlFlow` above) are
|
|
158
|
+
* EXCLUDED -- matching upstream markdownlint's own `filterByTypes(tokens,
|
|
159
|
+
* types, htmlFlow)` helper, whose `htmlFlow` parameter defaults to falsy.
|
|
160
|
+
* Pass `includeHtmlFlow: true` for rules that explicitly want to see
|
|
161
|
+
* inside HTML blocks too (upstream's MD033/no-inline-html and
|
|
162
|
+
* MD045/no-alt-text opt in this way; see their recheck ports for the same
|
|
163
|
+
* opt-in).
|
|
164
|
+
*/
|
|
165
|
+
export function filterByTypes(tree, types, includeHtmlFlow = false) {
|
|
166
|
+
return tree.flat.filter((token) => types.includes(token.type) && (includeHtmlFlow || !token.inHtmlFlow));
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,iFAAiF;AACjF,mEAAmE;AACnE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO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ClG,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC9C,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtB,IAAI,OAAO,CAAC,OAAO;QAAE,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAChD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAe,EACf,KAAwB,EACxB,eAAe,GAAG,KAAK;IAEvB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CACrB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAChF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { MarkdocAttributeSchema, MarkdocSchema } from './schema.js';
|
|
2
|
+
/** Enough of a real Markdoc `Config['tags'][name]['attributes'][name]` entry to extract statics from. */
|
|
3
|
+
export interface RawMarkdocAttribute {
|
|
4
|
+
type?: unknown;
|
|
5
|
+
required?: boolean;
|
|
6
|
+
default?: unknown;
|
|
7
|
+
matches?: unknown;
|
|
8
|
+
}
|
|
9
|
+
/** Enough of a real Markdoc `Config['tags'][name]` entry to extract statics from. */
|
|
10
|
+
export interface RawMarkdocTag {
|
|
11
|
+
selfClosing?: boolean;
|
|
12
|
+
attributes?: Record<string, RawMarkdocAttribute>;
|
|
13
|
+
validate?: unknown;
|
|
14
|
+
}
|
|
15
|
+
export type RawMarkdocTagMap = Record<string, RawMarkdocTag>;
|
|
16
|
+
/**
|
|
17
|
+
* Converts one raw Markdoc attribute definition into recheck's
|
|
18
|
+
* `MarkdocAttributeSchema`.
|
|
19
|
+
*
|
|
20
|
+
* `tagHasValidate` forces `dynamic: true` regardless of this attribute's own
|
|
21
|
+
* type. A tag-level `validate()` -- for example `img`'s src/srcSet/images
|
|
22
|
+
* mutual-exclusivity check, `code-snippet`'s from/after and to/before checks,
|
|
23
|
+
* or `diagram`'s type/align re-checks -- can read and reject any of the tag's
|
|
24
|
+
* attributes for reasons this generator can't discover from the schema object
|
|
25
|
+
* alone, since that would mean analyzing an arbitrary JS function body. So
|
|
26
|
+
* every attribute of a `validate()`-carrying tag is conservatively marked
|
|
27
|
+
* dynamic, even one with a plain `String`/`Number`/`Boolean` type and a
|
|
28
|
+
* `matches` array (`img.align`, `diagram.type`).
|
|
29
|
+
*
|
|
30
|
+
* Recorded facets (`required`, `default`, `enum`) are kept even when dynamic:
|
|
31
|
+
* `dynamic` only tells a value-checking rule to skip them, it doesn't make the
|
|
32
|
+
* facet itself unknown.
|
|
33
|
+
*/
|
|
34
|
+
export declare function extractAttribute(rawAttribute: RawMarkdocAttribute, tagHasValidate: boolean): MarkdocAttributeSchema;
|
|
35
|
+
/**
|
|
36
|
+
* Composes three raw Markdoc tag maps in caller-chosen precedence order
|
|
37
|
+
* (later arguments win a name collision) and converts every tag to recheck's
|
|
38
|
+
* statics-only `MarkdocSchema`. Both callers share this precedence-then-convert
|
|
39
|
+
* shape: the built-in generator composes markdoc + portal + theme in Realm's
|
|
40
|
+
* own override order; the `recheck markdoc-schema` command extracts one
|
|
41
|
+
* project module's tags at a time and passes empty maps for the other two, so
|
|
42
|
+
* the composition is a no-op and only that module's tags come out.
|
|
43
|
+
*/
|
|
44
|
+
export declare function extractStatics(themeTagMap: RawMarkdocTagMap, markdocBuiltinTags: RawMarkdocTagMap, portalBuiltInTagMap: RawMarkdocTagMap): MarkdocSchema;
|
|
45
|
+
//# sourceMappingURL=extract-statics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-statics.d.ts","sourceRoot":"","sources":["../../../src/parser/markdoc/extract-statics.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,sBAAsB,EAAoB,aAAa,EAAE,MAAM,aAAa,CAAC;AAE3F,yGAAyG;AACzG,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,qFAAqF;AACrF,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACjD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAe7D;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,mBAAmB,EACjC,cAAc,EAAE,OAAO,GACtB,sBAAsB,CAoDxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,gBAAgB,EAC7B,kBAAkB,EAAE,gBAAgB,EACpC,mBAAmB,EAAE,gBAAgB,GACpC,aAAa,CA+Bf"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// The single implementation of "a real Markdoc tag map -> recheck's
|
|
2
|
+
// statics-only MarkdocSchema". Two callers share it and must never define
|
|
3
|
+
// "what counts as a static facet" two different ways:
|
|
4
|
+
// - `scripts/generate-markdoc-schema.mjs`, which resolves Realm's composed
|
|
5
|
+
// built-in schema (markdoc + portal + theme) for the committed
|
|
6
|
+
// `src/data/markdoc-realm-schema.ts`, and re-exports these functions
|
|
7
|
+
// unchanged so its own drift test keeps working.
|
|
8
|
+
// - `src/commands/markdoc-schema.ts`, the `recheck markdoc-schema` CLI
|
|
9
|
+
// command, which extracts statics from a project's own schema module(s).
|
|
10
|
+
//
|
|
11
|
+
// Lives under `src/` (not `scripts/`) so the built CLI can import it at
|
|
12
|
+
// runtime: `scripts/`'s own generator imports `@redocly/theme` and
|
|
13
|
+
// `@redocly/portal`, both devDependencies-only, and this module must stay
|
|
14
|
+
// free of any such import so requiring it from a published package never
|
|
15
|
+
// drags those in.
|
|
16
|
+
//
|
|
17
|
+
// Raw tag/attribute shapes are typed loosely here rather than imported from
|
|
18
|
+
// `@markdoc/markdoc` (also a devDependency-only): this module's declaration
|
|
19
|
+
// file ships with the published package, and a type-only import still leaves
|
|
20
|
+
// a reference downstream consumers' own type-checking would need
|
|
21
|
+
// `@markdoc/markdoc` installed to resolve.
|
|
22
|
+
// The three attribute-type constructors recheck's own format can represent
|
|
23
|
+
// (see MarkdocAttributeSchema's doc comment in ./schema.ts). Every other
|
|
24
|
+
// upstream type -- `Object`, `Array`, a union like `[String, Number]`, a
|
|
25
|
+
// custom class implementing `CustomAttributeTypeInterface` (`RelativePath`,
|
|
26
|
+
// `PartialFile`, ...), or no `type` at all (`debug`'s bare `{ value: {} }`) --
|
|
27
|
+
// has no faithful single-primitive representative, so it's recorded
|
|
28
|
+
// `dynamic: true` instead of guessing.
|
|
29
|
+
const PRIMITIVE_TYPE_NAMES = new Map([
|
|
30
|
+
[String, 'string'],
|
|
31
|
+
[Number, 'number'],
|
|
32
|
+
[Boolean, 'boolean'],
|
|
33
|
+
]);
|
|
34
|
+
/**
|
|
35
|
+
* Converts one raw Markdoc attribute definition into recheck's
|
|
36
|
+
* `MarkdocAttributeSchema`.
|
|
37
|
+
*
|
|
38
|
+
* `tagHasValidate` forces `dynamic: true` regardless of this attribute's own
|
|
39
|
+
* type. A tag-level `validate()` -- for example `img`'s src/srcSet/images
|
|
40
|
+
* mutual-exclusivity check, `code-snippet`'s from/after and to/before checks,
|
|
41
|
+
* or `diagram`'s type/align re-checks -- can read and reject any of the tag's
|
|
42
|
+
* attributes for reasons this generator can't discover from the schema object
|
|
43
|
+
* alone, since that would mean analyzing an arbitrary JS function body. So
|
|
44
|
+
* every attribute of a `validate()`-carrying tag is conservatively marked
|
|
45
|
+
* dynamic, even one with a plain `String`/`Number`/`Boolean` type and a
|
|
46
|
+
* `matches` array (`img.align`, `diagram.type`).
|
|
47
|
+
*
|
|
48
|
+
* Recorded facets (`required`, `default`, `enum`) are kept even when dynamic:
|
|
49
|
+
* `dynamic` only tells a value-checking rule to skip them, it doesn't make the
|
|
50
|
+
* facet itself unknown.
|
|
51
|
+
*/
|
|
52
|
+
export function extractAttribute(rawAttribute, tagHasValidate) {
|
|
53
|
+
const rawType = rawAttribute.type;
|
|
54
|
+
const primitiveName = typeof rawType === 'function' ? PRIMITIVE_TYPE_NAMES.get(rawType) : undefined;
|
|
55
|
+
// `type` is non-optional in MarkdocAttributeSchema, and 'string' is the
|
|
56
|
+
// placeholder for anything non-primitive. It's a faithful placeholder
|
|
57
|
+
// rather than an arbitrary one: every custom attribute type in
|
|
58
|
+
// packages/theme (RelativePath, PartialFile, CodeSnippetFile, ...)
|
|
59
|
+
// implements `validate(value: string)`, so the wire value is always a
|
|
60
|
+
// string even when the class does extra work with it. A dynamic attribute
|
|
61
|
+
// is never value-checked anyway -- only the presence of `type` satisfies
|
|
62
|
+
// the interface.
|
|
63
|
+
const out = { type: primitiveName ?? 'string' };
|
|
64
|
+
if (rawAttribute.required === true)
|
|
65
|
+
out.required = true;
|
|
66
|
+
// `MarkdocAttributeSchema.default` can only hold a JSON primitive, and some
|
|
67
|
+
// defaults aren't one: `connect-mcp`'s `options` attribute defaults to an
|
|
68
|
+
// array (`['cursor', 'vscode', 'copy']`), which the interface has no slot
|
|
69
|
+
// for. Recording it would produce a schema that doesn't type-check against
|
|
70
|
+
// its own interface, so drop it rather than guess a representation.
|
|
71
|
+
// Nothing is lost: a non-primitive default always pairs with a
|
|
72
|
+
// non-primitive `type`, so the attribute is already `dynamic: true` and no
|
|
73
|
+
// value check reads its default.
|
|
74
|
+
const defaultType = typeof rawAttribute.default;
|
|
75
|
+
if (defaultType === 'string' || defaultType === 'number' || defaultType === 'boolean') {
|
|
76
|
+
out.default = rawAttribute.default;
|
|
77
|
+
}
|
|
78
|
+
// Markdoc's `matches` isn't always an array -- it can also be a RegExp or a
|
|
79
|
+
// predicate function -- and even when it is an array, its entries aren't
|
|
80
|
+
// guaranteed to be strings. `MarkdocAttributeSchema.enum` is
|
|
81
|
+
// `readonly string[]`, so:
|
|
82
|
+
// - A non-array `matches` can't be represented as an enum at all, so it
|
|
83
|
+
// falls back to `dynamic: true` like a class-typed attribute or a
|
|
84
|
+
// `validate()`-carrying tag. Don't guess at a constraint this can't
|
|
85
|
+
// statically resolve.
|
|
86
|
+
// - An array `matches` with non-string entries is representable, just not
|
|
87
|
+
// verbatim, so coerce it with `String(...)` rather than marking it
|
|
88
|
+
// dynamic. The enum value check compares a parsed attribute literal's
|
|
89
|
+
// source text against the declared enum -- a string comparison either
|
|
90
|
+
// way -- so a coerced `'1'`/`'true'` is exactly what it needs.
|
|
91
|
+
if (rawAttribute.matches !== undefined) {
|
|
92
|
+
if (Array.isArray(rawAttribute.matches)) {
|
|
93
|
+
if (rawAttribute.matches.length > 0) {
|
|
94
|
+
out.enum = rawAttribute.matches.map((value) => String(value));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
out.dynamic = true;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (primitiveName === undefined || tagHasValidate)
|
|
102
|
+
out.dynamic = true;
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Composes three raw Markdoc tag maps in caller-chosen precedence order
|
|
107
|
+
* (later arguments win a name collision) and converts every tag to recheck's
|
|
108
|
+
* statics-only `MarkdocSchema`. Both callers share this precedence-then-convert
|
|
109
|
+
* shape: the built-in generator composes markdoc + portal + theme in Realm's
|
|
110
|
+
* own override order; the `recheck markdoc-schema` command extracts one
|
|
111
|
+
* project module's tags at a time and passes empty maps for the other two, so
|
|
112
|
+
* the composition is a no-op and only that module's tags come out.
|
|
113
|
+
*/
|
|
114
|
+
export function extractStatics(themeTagMap, markdocBuiltinTags, portalBuiltInTagMap) {
|
|
115
|
+
const composed = { ...markdocBuiltinTags, ...portalBuiltInTagMap, ...themeTagMap };
|
|
116
|
+
const tagNames = Object.keys(composed).sort();
|
|
117
|
+
const tags = {};
|
|
118
|
+
for (const tagName of tagNames) {
|
|
119
|
+
const rawSchema = composed[tagName];
|
|
120
|
+
const tagHasValidate = typeof rawSchema.validate === 'function';
|
|
121
|
+
const tagOut = {};
|
|
122
|
+
if (rawSchema.selfClosing === true)
|
|
123
|
+
tagOut.selfClosing = true;
|
|
124
|
+
const rawAttributes = rawSchema.attributes;
|
|
125
|
+
if (rawAttributes) {
|
|
126
|
+
const attributeNames = Object.keys(rawAttributes).sort();
|
|
127
|
+
if (attributeNames.length > 0) {
|
|
128
|
+
const attributesOut = {};
|
|
129
|
+
for (const attributeName of attributeNames) {
|
|
130
|
+
attributesOut[attributeName] = extractAttribute(rawAttributes[attributeName], tagHasValidate);
|
|
131
|
+
}
|
|
132
|
+
tagOut.attributes = attributesOut;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
tags[tagName] = tagOut;
|
|
136
|
+
}
|
|
137
|
+
return { tags };
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=extract-statics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-statics.js","sourceRoot":"","sources":["../../../src/parser/markdoc/extract-statics.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,0EAA0E;AAC1E,sDAAsD;AACtD,6EAA6E;AAC7E,mEAAmE;AACnE,yEAAyE;AACzE,qDAAqD;AACrD,yEAAyE;AACzE,6EAA6E;AAC7E,EAAE;AACF,wEAAwE;AACxE,mEAAmE;AACnE,0EAA0E;AAC1E,yEAAyE;AACzE,kBAAkB;AAClB,EAAE;AACF,4EAA4E;AAC5E,4EAA4E;AAC5E,6EAA6E;AAC7E,iEAAiE;AACjE,2CAA2C;AAqB3C,2EAA2E;AAC3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C,WAAW,GAAG,IAAI,CAAC;QAE9D,MAAM,aAAa,GAAG,SAAS,CAAC,UAAU,CAAC;QAC3C,IAAI,aAAa,EAAE,CAAC;YAClB,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,CAAC;YACzD,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC9B,MAAM,aAAa,GAA2C,EAAE,CAAC;gBACjE,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE,CAAC;oBAC3C,aAAa,CAAC,aAAa,CAAC,GAAG,gBAAgB,CAC7C,aAAa,CAAC,aAAa,CAAC,EAC5B,cAAc,CACf,CAAC;gBACJ,CAAC;gBACD,MAAM,CAAC,UAAU,GAAG,aAAa,CAAC;YACpC,CAAC;QACH,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Token, TokenTree } from '../types.js';
|
|
2
|
+
export interface MarkdocPair {
|
|
3
|
+
open: Token;
|
|
4
|
+
close: Token;
|
|
5
|
+
/**
|
|
6
|
+
* Nesting depth of `open` at the moment it was pushed: 0 for a top-level tag,
|
|
7
|
+
* 1 for a tag opened inside exactly one other, and so on. It stays fixed even
|
|
8
|
+
* when `close` jumps over an intervening unmatched open (see `crossed`), since
|
|
9
|
+
* it describes where `open` appeared, not where its match landed.
|
|
10
|
+
*/
|
|
11
|
+
depth: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The five buckets are disjoint: a pair lands in `pairs` or `crossed` but never
|
|
15
|
+
* both, and a token appears in at most one bucket.
|
|
16
|
+
*/
|
|
17
|
+
export interface MarkdocPairing {
|
|
18
|
+
/** Cleanly matched open/close pairs (no crossing involved on either side). */
|
|
19
|
+
pairs: MarkdocPair[];
|
|
20
|
+
/** Opens with no close by EOF (excluding schema-known void tags, below). */
|
|
21
|
+
unclosed: Token[];
|
|
22
|
+
/** Closes that match no open anywhere on the stack. */
|
|
23
|
+
orphaned: Token[];
|
|
24
|
+
/** Matched pairs whose open or close jumped, or was jumped by, another pair. */
|
|
25
|
+
crossed: MarkdocPair[];
|
|
26
|
+
/** Opens whose name is schema-declared self-closing, written without `/%}`. */
|
|
27
|
+
voidMissingSlash: Token[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A "nothing was paired" result for callers that must still supply a
|
|
31
|
+
* `MarkdocPairing` but have no reason to run the pass -- the runner uses it when
|
|
32
|
+
* the Markdoc flag is on but no active rule can read the buckets anyway. A
|
|
33
|
+
* factory rather than a shared constant, because the buckets are mutable arrays
|
|
34
|
+
* and one shared instance would let an accidental push leak across files.
|
|
35
|
+
*/
|
|
36
|
+
export declare function emptyMarkdocPairing(): MarkdocPairing;
|
|
37
|
+
export interface PairingOptions {
|
|
38
|
+
/**
|
|
39
|
+
* Tag names a schema declares self-closing. A plain `Set<string>` rather than
|
|
40
|
+
* a dependency on the schema module, so the schema's shape can change without
|
|
41
|
+
* this pass knowing anything beyond which names never take a close tag.
|
|
42
|
+
*/
|
|
43
|
+
selfClosingTags?: ReadonlySet<string>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Computes open/close pairing for a document's `markdocTag` tokens with a single
|
|
47
|
+
* stack walk in document order. The filtered list is sorted by position rather
|
|
48
|
+
* than trusting whatever order `tree.flat` happens to be in, since
|
|
49
|
+
* `structureMarkdocTags` (structure.ts) appends its own synthesized children to
|
|
50
|
+
* the end of that same array.
|
|
51
|
+
*
|
|
52
|
+
* Deliberate divergence from upstream Markdoc, which tests a close only against
|
|
53
|
+
* the immediate top of its stack and never searches deeper: for
|
|
54
|
+
* `{% a %}{% b %}{% /a %}{% /b %}` upstream reports a missing-closing plus a
|
|
55
|
+
* missing-opening and lets `a`'s node swallow everything to EOF, while this pass
|
|
56
|
+
* searches the whole stack innermost-first and reports both pairs as `crossed`.
|
|
57
|
+
* "These two pairs are interleaved" is the more actionable diagnostic, and a
|
|
58
|
+
* crossing can never silently land in `pairs`, so no error upstream reports is
|
|
59
|
+
* lost. The cost is that consumers relying on pair ranges see a narrower range
|
|
60
|
+
* for a crossed `open` than upstream's AST would give.
|
|
61
|
+
*/
|
|
62
|
+
export declare function computeMarkdocPairing(tree: TokenTree, options?: PairingOptions): MarkdocPairing;
|
|
63
|
+
//# sourceMappingURL=pairing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairing.d.ts","sourceRoot":"","sources":["../../../src/parser/markdoc/pairing.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGpD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,KAAK,CAAC;IACb;;;;;OAKG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,8EAA8E;IAC9E,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,4EAA4E;IAC5E,QAAQ,EAAE,KAAK,EAAE,CAAC;IAClB,uDAAuD;IACvD,QAAQ,EAAE,KAAK,EAAE,CAAC;IAClB,gFAAgF;IAChF,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,+EAA+E;IAC/E,gBAAgB,EAAE,KAAK,EAAE,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,IAAI,cAAc,CAEpD;AAED,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACvC;AAmCD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,SAAS,EACf,OAAO,GAAE,cAAmB,GAC3B,cAAc,CAsDhB"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A "nothing was paired" result for callers that must still supply a
|
|
3
|
+
* `MarkdocPairing` but have no reason to run the pass -- the runner uses it when
|
|
4
|
+
* the Markdoc flag is on but no active rule can read the buckets anyway. A
|
|
5
|
+
* factory rather than a shared constant, because the buckets are mutable arrays
|
|
6
|
+
* and one shared instance would let an accidental push leak across files.
|
|
7
|
+
*/
|
|
8
|
+
export function emptyMarkdocPairing() {
|
|
9
|
+
return { pairs: [], unclosed: [], orphaned: [], crossed: [], voidMissingSlash: [] };
|
|
10
|
+
}
|
|
11
|
+
// Kinds that never enter the pairing stack: annotation, variable, and function
|
|
12
|
+
// spans carry no tag name at all, a self-closing tag (`{% x /%}`) is already
|
|
13
|
+
// complete on its own, and a malformed span is left inert so it cannot disturb
|
|
14
|
+
// the pairing of the well-formed tags around it (the syntax-level rule owns
|
|
15
|
+
// reporting it).
|
|
16
|
+
const NEVER_PAIRED_KINDS = new Set([
|
|
17
|
+
'annotation',
|
|
18
|
+
'variable',
|
|
19
|
+
'function',
|
|
20
|
+
'tag-self-closing',
|
|
21
|
+
'malformed',
|
|
22
|
+
]);
|
|
23
|
+
/** The tag's own name, from its synthesized `markdocTagName` child (absent
|
|
24
|
+
* only for the kinds already filtered out above, where it's `null`). */
|
|
25
|
+
function tagName(token) {
|
|
26
|
+
const nameChild = token.children.find((child) => child.type === 'markdocTagName');
|
|
27
|
+
return nameChild ? nameChild.text : null;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Computes open/close pairing for a document's `markdocTag` tokens with a single
|
|
31
|
+
* stack walk in document order. The filtered list is sorted by position rather
|
|
32
|
+
* than trusting whatever order `tree.flat` happens to be in, since
|
|
33
|
+
* `structureMarkdocTags` (structure.ts) appends its own synthesized children to
|
|
34
|
+
* the end of that same array.
|
|
35
|
+
*
|
|
36
|
+
* Deliberate divergence from upstream Markdoc, which tests a close only against
|
|
37
|
+
* the immediate top of its stack and never searches deeper: for
|
|
38
|
+
* `{% a %}{% b %}{% /a %}{% /b %}` upstream reports a missing-closing plus a
|
|
39
|
+
* missing-opening and lets `a`'s node swallow everything to EOF, while this pass
|
|
40
|
+
* searches the whole stack innermost-first and reports both pairs as `crossed`.
|
|
41
|
+
* "These two pairs are interleaved" is the more actionable diagnostic, and a
|
|
42
|
+
* crossing can never silently land in `pairs`, so no error upstream reports is
|
|
43
|
+
* lost. The cost is that consumers relying on pair ranges see a narrower range
|
|
44
|
+
* for a crossed `open` than upstream's AST would give.
|
|
45
|
+
*/
|
|
46
|
+
export function computeMarkdocPairing(tree, options = {}) {
|
|
47
|
+
const selfClosingTags = options.selfClosingTags ?? new Set();
|
|
48
|
+
const tags = tree.flat
|
|
49
|
+
.filter((token) => token.type === 'markdocTag')
|
|
50
|
+
.sort((a, b) => a.startLine - b.startLine || a.startColumn - b.startColumn);
|
|
51
|
+
const stack = [];
|
|
52
|
+
const pairs = [];
|
|
53
|
+
const crossed = [];
|
|
54
|
+
const orphaned = [];
|
|
55
|
+
for (const token of tags) {
|
|
56
|
+
const kind = token.markdocKind;
|
|
57
|
+
if (kind === undefined || NEVER_PAIRED_KINDS.has(kind))
|
|
58
|
+
continue;
|
|
59
|
+
const name = tagName(token);
|
|
60
|
+
if (name === null)
|
|
61
|
+
continue; // defensive only: every tag-open/tag-close carries a name
|
|
62
|
+
if (kind === 'tag-open') {
|
|
63
|
+
stack.push({ token, name, depth: stack.length, crossed: false });
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
// kind === 'tag-close': innermost-first search for the nearest same-name open.
|
|
67
|
+
let matchIndex = -1;
|
|
68
|
+
for (let i = stack.length - 1; i >= 0; i--) {
|
|
69
|
+
if (stack[i].name === name) {
|
|
70
|
+
matchIndex = i;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (matchIndex === -1) {
|
|
75
|
+
orphaned.push(token);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const jumpedOver = matchIndex !== stack.length - 1;
|
|
79
|
+
if (jumpedOver) {
|
|
80
|
+
for (let i = matchIndex + 1; i < stack.length; i++)
|
|
81
|
+
stack[i].crossed = true;
|
|
82
|
+
}
|
|
83
|
+
const [matched] = stack.splice(matchIndex, 1);
|
|
84
|
+
const pair = { open: matched.token, close: token, depth: matched.depth };
|
|
85
|
+
(jumpedOver || matched.crossed ? crossed : pairs).push(pair);
|
|
86
|
+
}
|
|
87
|
+
const unclosed = [];
|
|
88
|
+
const voidMissingSlash = [];
|
|
89
|
+
for (const entry of stack) {
|
|
90
|
+
(selfClosingTags.has(entry.name) ? voidMissingSlash : unclosed).push(entry.token);
|
|
91
|
+
}
|
|
92
|
+
return { pairs, unclosed, orphaned, crossed, voidMissingSlash };
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=pairing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairing.js","sourceRoot":"","sources":["../../../src/parser/markdoc/pairing.ts"],"names":[],"mappings":"AAoCA;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,gBAAgB,EAAE,EAAE,EAAE,CAAC;AACtF,CAAC;AAWD,+EAA+E;AAC/E,6EAA6E;AAC7E,+EAA+E;AAC/E,4EAA4E;AAC5E,iBAAiB;AACjB,MAAM,kBAAkB,GAA8C,IAAI,GAAG,CAAC;IAC5E,YAAY;IACZ,UAAU;IACV,UAAU;IACV,kBAAkB;IAClB,WAAW;CACH,CAAC,CAAC;AAEZ;wEACwE;AACxE,SAAS,OAAO,CAAC,KAAY;IAC3B,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,gBAAgB,CAAC,CAAC;IAClF,OAA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,CAAC,gBAAgB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACpF,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One attribute's statically-checkable facets. `type` is limited to the three
|
|
3
|
+
* JSON primitives recheck can compare a parsed literal against; anything richer
|
|
4
|
+
* upstream (objects, arrays, union types, custom attribute classes) has no
|
|
5
|
+
* faithful representative here and gets `dynamic: true` instead.
|
|
6
|
+
*/
|
|
7
|
+
export interface MarkdocAttributeSchema {
|
|
8
|
+
type: 'string' | 'number' | 'boolean';
|
|
9
|
+
required?: boolean;
|
|
10
|
+
default?: string | number | boolean;
|
|
11
|
+
/** Markdoc's `matches` array, renamed for recheck's own vocabulary. */
|
|
12
|
+
enum?: readonly string[];
|
|
13
|
+
/**
|
|
14
|
+
* Set when the upstream attribute's type isn't one of the three JSON
|
|
15
|
+
* primitives, or when the tag's schema carries a `validate()` function.
|
|
16
|
+
* Recheck's value-shape checks (type and enum) skip such an attribute rather
|
|
17
|
+
* than guess at business logic they cannot run. `required` is deliberately not
|
|
18
|
+
* skipped: upstream enforces it purely by presence, independently of `type`,
|
|
19
|
+
* `matches`, and `validate()`, even for a custom-class-typed attribute, so
|
|
20
|
+
* `markdoc-attributes` checks it unconditionally. The attribute's name is known
|
|
21
|
+
* either way, so unknown-attribute checks are unaffected.
|
|
22
|
+
*/
|
|
23
|
+
dynamic?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface MarkdocTagSchema {
|
|
26
|
+
selfClosing?: boolean;
|
|
27
|
+
attributes?: Record<string, MarkdocAttributeSchema>;
|
|
28
|
+
}
|
|
29
|
+
export interface MarkdocSchema {
|
|
30
|
+
tags: Record<string, MarkdocTagSchema>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The object form of the `markdoc` config key. `schema` is required here: the
|
|
34
|
+
* boolean shorthand `true` unambiguously means `{ schema: 'realm' }`, but an
|
|
35
|
+
* object with `schema` omitted has no default this format defines, so
|
|
36
|
+
* `config/schema.ts` rejects it rather than guessing.
|
|
37
|
+
*/
|
|
38
|
+
export interface MarkdocUserConfig {
|
|
39
|
+
schema: 'realm' | false;
|
|
40
|
+
extend?: {
|
|
41
|
+
tags?: Record<string, MarkdocTagSchema>;
|
|
42
|
+
tagsFile?: string;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The already-loaded view of `extend` that `config/validate.ts` builds after
|
|
47
|
+
* reading and shape-checking `tagsFile` (if any): `fileTags` is that file's
|
|
48
|
+
* tags, `tags` is the config's own inline `extend.tags`. Kept as two separate
|
|
49
|
+
* fields, not pre-merged, so `mergeExtend` alone owns the precedence order.
|
|
50
|
+
*/
|
|
51
|
+
export interface ResolvedExtend {
|
|
52
|
+
fileTags?: Record<string, MarkdocTagSchema>;
|
|
53
|
+
tags?: Record<string, MarkdocTagSchema>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Normalizes the raw `markdoc` config value (boolean shorthand or object form)
|
|
57
|
+
* into `{ enabled, schema }`. It is called from `config/validate.ts` after AJV
|
|
58
|
+
* structural validation, but the check order there means it still sees the raw
|
|
59
|
+
* value when validation failed, so it must never throw on a malformed shape
|
|
60
|
+
* (`{ schema: 'bogus' }`, a bare string): anything unrecognized normalizes to
|
|
61
|
+
* disabled.
|
|
62
|
+
*
|
|
63
|
+
* `schema: false` deliberately is not "fully off". Parsing and pairing still
|
|
64
|
+
* run, and only the schema-dependent rules (unknown tag, and the
|
|
65
|
+
* unknown/required/enum attribute checks) go inert for lack of anything to check
|
|
66
|
+
* against. `extend` alongside `schema: false` is accepted structurally but has
|
|
67
|
+
* no effect, since there is no base to merge over.
|
|
68
|
+
*
|
|
69
|
+
* `resolvedExtend`, when passed, is the caller's already-loaded view of
|
|
70
|
+
* `extend` (`tagsFile` read and shape-checked, see config/validate.ts) and
|
|
71
|
+
* takes over from `raw.extend` entirely -- this module never reads a
|
|
72
|
+
* `tagsFile` itself, so a caller that resolved one has strictly more
|
|
73
|
+
* information than `raw.extend` alone.
|
|
74
|
+
*/
|
|
75
|
+
export declare function resolveMarkdocConfig(raw: boolean | MarkdocUserConfig | undefined, resolvedExtend?: ResolvedExtend): {
|
|
76
|
+
enabled: boolean;
|
|
77
|
+
schema: MarkdocSchema | null;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Tag names a schema declares self-closing, in the plain `Set<string>` shape
|
|
81
|
+
* `pairing.ts` consumes so the pairing pass depends on none of this module's
|
|
82
|
+
* types.
|
|
83
|
+
*/
|
|
84
|
+
export declare function selfClosingTagNames(schema: MarkdocSchema): ReadonlySet<string>;
|
|
85
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/parser/markdoc/schema.ts"],"names":[],"mappings":"AAWA;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IACpC,uEAAuE;IACvE,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CA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