chaffjs 0.50.0 → 0.51.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.ja.md +30 -3
- package/README.md +30 -2
- package/dist/allow.d.ts +49 -0
- package/dist/allow.d.ts.map +1 -0
- package/dist/allow.js +111 -0
- package/dist/allow.js.map +1 -0
- package/dist/check-source.d.ts +13 -3
- package/dist/check-source.d.ts.map +1 -1
- package/dist/check-source.js +23 -6
- package/dist/check-source.js.map +1 -1
- package/dist/cli-text.d.ts +7 -1
- package/dist/cli-text.d.ts.map +1 -1
- package/dist/cli-text.js +8 -2
- package/dist/cli-text.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +12 -11
- package/dist/cli.js.map +1 -1
- package/dist/commands/eval.js +1 -1
- package/dist/commands/eval.js.map +1 -1
- package/dist/commands/suppressions.d.ts +4 -1
- package/dist/commands/suppressions.d.ts.map +1 -1
- package/dist/commands/suppressions.js +2 -2
- package/dist/commands/suppressions.js.map +1 -1
- package/dist/commands/test.js +1 -1
- package/dist/commands/test.js.map +1 -1
- package/dist/compound-head.d.ts +5 -2
- package/dist/compound-head.d.ts.map +1 -1
- package/dist/compound-head.js +17 -8
- package/dist/compound-head.js.map +1 -1
- package/dist/config/allow-problems.d.ts +8 -0
- package/dist/config/allow-problems.d.ts.map +1 -0
- package/dist/config/allow-problems.js +61 -0
- package/dist/config/allow-problems.js.map +1 -0
- package/dist/config/by-path-problems.d.ts +3 -0
- package/dist/config/by-path-problems.d.ts.map +1 -1
- package/dist/config/by-path-problems.js +21 -2
- package/dist/config/by-path-problems.js.map +1 -1
- package/dist/config/by-path-rules.d.ts +34 -0
- package/dist/config/by-path-rules.d.ts.map +1 -0
- package/dist/config/by-path-rules.js +53 -0
- package/dist/config/by-path-rules.js.map +1 -0
- package/dist/config/by-path.d.ts +15 -0
- package/dist/config/by-path.d.ts.map +1 -1
- package/dist/config/by-path.js.map +1 -1
- package/dist/config/consistent-problems.d.ts +5 -0
- package/dist/config/consistent-problems.d.ts.map +1 -0
- package/dist/config/consistent-problems.js +24 -0
- package/dist/config/consistent-problems.js.map +1 -0
- package/dist/config/load.d.ts +23 -1
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +63 -10
- package/dist/config/load.js.map +1 -1
- package/dist/config/option-problems.d.ts +6 -4
- package/dist/config/option-problems.d.ts.map +1 -1
- package/dist/config/option-problems.js +5 -2
- package/dist/config/option-problems.js.map +1 -1
- package/dist/config/prefer-problems.d.ts +5 -0
- package/dist/config/prefer-problems.d.ts.map +1 -0
- package/dist/config/prefer-problems.js +15 -0
- package/dist/config/prefer-problems.js.map +1 -0
- package/dist/config/prefer.d.ts +21 -0
- package/dist/config/prefer.d.ts.map +1 -0
- package/dist/config/prefer.js +35 -0
- package/dist/config/prefer.js.map +1 -0
- package/dist/config/term-problems.d.ts +5 -0
- package/dist/config/term-problems.d.ts.map +1 -0
- package/dist/config/term-problems.js +25 -0
- package/dist/config/term-problems.js.map +1 -0
- package/dist/config/warnings.d.ts +1 -1
- package/dist/config/warnings.d.ts.map +1 -1
- package/dist/config/warnings.js +9 -2
- package/dist/config/warnings.js.map +1 -1
- package/dist/cross-variants.d.ts +1 -1
- package/dist/cross-variants.d.ts.map +1 -1
- package/dist/cross-variants.js +4 -8
- package/dist/cross-variants.js.map +1 -1
- package/dist/cross-votes.d.ts +13 -0
- package/dist/cross-votes.d.ts.map +1 -1
- package/dist/cross-votes.js +25 -2
- package/dist/cross-votes.js.map +1 -1
- package/dist/custom/parse.d.ts +9 -0
- package/dist/custom/parse.d.ts.map +1 -1
- package/dist/custom/parse.js +11 -2
- package/dist/custom/parse.js.map +1 -1
- package/dist/custom/problems.d.ts.map +1 -1
- package/dist/custom/problems.js +9 -3
- package/dist/custom/problems.js.map +1 -1
- package/dist/custom/scope-field.d.ts +7 -0
- package/dist/custom/scope-field.d.ts.map +1 -0
- package/dist/custom/scope-field.js +14 -0
- package/dist/custom/scope-field.js.map +1 -0
- package/dist/date-format.d.ts +5 -3
- package/dist/date-format.d.ts.map +1 -1
- package/dist/date-format.js +30 -5
- package/dist/date-format.js.map +1 -1
- package/dist/derived/elapsed.d.ts +4 -1
- package/dist/derived/elapsed.d.ts.map +1 -1
- package/dist/derived/elapsed.js +11 -1
- package/dist/derived/elapsed.js.map +1 -1
- package/dist/detectors/acronym-context.d.ts +3 -1
- package/dist/detectors/acronym-context.d.ts.map +1 -1
- package/dist/detectors/acronym-context.js +7 -1
- package/dist/detectors/acronym-context.js.map +1 -1
- package/dist/detectors/acronym-gloss.d.ts +20 -7
- package/dist/detectors/acronym-gloss.d.ts.map +1 -1
- package/dist/detectors/acronym-gloss.js +50 -13
- package/dist/detectors/acronym-gloss.js.map +1 -1
- package/dist/detectors/bare-comparative.d.ts +4 -0
- package/dist/detectors/bare-comparative.d.ts.map +1 -1
- package/dist/detectors/bare-comparative.js +27 -3
- package/dist/detectors/bare-comparative.js.map +1 -1
- package/dist/detectors/blank-structure.d.ts +5 -1
- package/dist/detectors/blank-structure.d.ts.map +1 -1
- package/dist/detectors/blank-structure.js +13 -7
- package/dist/detectors/blank-structure.js.map +1 -1
- package/dist/detectors/bold-label.d.ts.map +1 -1
- package/dist/detectors/bold-label.js +12 -6
- package/dist/detectors/bold-label.js.map +1 -1
- package/dist/detectors/bracket-title-date.d.ts +6 -0
- package/dist/detectors/bracket-title-date.d.ts.map +1 -0
- package/dist/detectors/bracket-title-date.js +29 -0
- package/dist/detectors/bracket-title-date.js.map +1 -0
- package/dist/detectors/broken-link.d.ts.map +1 -1
- package/dist/detectors/broken-link.js +12 -1
- package/dist/detectors/broken-link.js.map +1 -1
- package/dist/detectors/capitalised-term.d.ts.map +1 -1
- package/dist/detectors/capitalised-term.js +24 -11
- package/dist/detectors/capitalised-term.js.map +1 -1
- package/dist/detectors/change-rate.d.ts.map +1 -1
- package/dist/detectors/change-rate.js +27 -4
- package/dist/detectors/change-rate.js.map +1 -1
- package/dist/detectors/char-shape.d.ts.map +1 -1
- package/dist/detectors/char-shape.js +12 -17
- package/dist/detectors/char-shape.js.map +1 -1
- package/dist/detectors/clause-shape.d.ts +4 -2
- package/dist/detectors/clause-shape.d.ts.map +1 -1
- package/dist/detectors/clause-shape.js +8 -4
- package/dist/detectors/clause-shape.js.map +1 -1
- package/dist/detectors/contraction-mix.d.ts.map +1 -1
- package/dist/detectors/contraction-mix.js +3 -2
- package/dist/detectors/contraction-mix.js.map +1 -1
- package/dist/detectors/contraction-set-apart.d.ts +7 -1
- package/dist/detectors/contraction-set-apart.d.ts.map +1 -1
- package/dist/detectors/contraction-set-apart.js +14 -1
- package/dist/detectors/contraction-set-apart.js.map +1 -1
- package/dist/detectors/coordinate-adjective.d.ts +5 -3
- package/dist/detectors/coordinate-adjective.d.ts.map +1 -1
- package/dist/detectors/coordinate-adjective.js +49 -1
- package/dist/detectors/coordinate-adjective.js.map +1 -1
- package/dist/detectors/count-per-section.d.ts.map +1 -1
- package/dist/detectors/count-per-section.js +29 -23
- package/dist/detectors/count-per-section.js.map +1 -1
- package/dist/detectors/counter-edge.d.ts +11 -0
- package/dist/detectors/counter-edge.d.ts.map +1 -1
- package/dist/detectors/counter-edge.js +17 -0
- package/dist/detectors/counter-edge.js.map +1 -1
- package/dist/detectors/cross-variant.d.ts.map +1 -1
- package/dist/detectors/cross-variant.js +14 -2
- package/dist/detectors/cross-variant.js.map +1 -1
- package/dist/detectors/custom.d.ts.map +1 -1
- package/dist/detectors/custom.js +6 -4
- package/dist/detectors/custom.js.map +1 -1
- package/dist/detectors/date-format.js +1 -1
- package/dist/detectors/date-format.js.map +1 -1
- package/dist/detectors/date-repeated-day.d.ts +11 -0
- package/dist/detectors/date-repeated-day.d.ts.map +1 -0
- package/dist/detectors/date-repeated-day.js +15 -0
- package/dist/detectors/date-repeated-day.js.map +1 -0
- package/dist/detectors/date-year.d.ts.map +1 -1
- package/dist/detectors/date-year.js +8 -1
- package/dist/detectors/date-year.js.map +1 -1
- package/dist/detectors/defined-term-form.d.ts.map +1 -1
- package/dist/detectors/defined-term-form.js +6 -3
- package/dist/detectors/defined-term-form.js.map +1 -1
- package/dist/detectors/definition-use.d.ts.map +1 -1
- package/dist/detectors/definition-use.js +7 -1
- package/dist/detectors/definition-use.js.map +1 -1
- package/dist/detectors/derived-numbers.d.ts.map +1 -1
- package/dist/detectors/derived-numbers.js +1 -0
- package/dist/detectors/derived-numbers.js.map +1 -1
- package/dist/detectors/document-shape.d.ts +1 -1
- package/dist/detectors/document-shape.d.ts.map +1 -1
- package/dist/detectors/document-shape.js +4 -1
- package/dist/detectors/document-shape.js.map +1 -1
- package/dist/detectors/email-letter.d.ts +3 -1
- package/dist/detectors/email-letter.d.ts.map +1 -1
- package/dist/detectors/email-letter.js +4 -2
- package/dist/detectors/email-letter.js.map +1 -1
- package/dist/detectors/empty-section.d.ts +1 -0
- package/dist/detectors/empty-section.d.ts.map +1 -1
- package/dist/detectors/empty-section.js +10 -1
- package/dist/detectors/empty-section.js.map +1 -1
- package/dist/detectors/en-shape.d.ts.map +1 -1
- package/dist/detectors/en-shape.js +15 -1
- package/dist/detectors/en-shape.js.map +1 -1
- package/dist/detectors/enumeration-marker.d.ts +7 -0
- package/dist/detectors/enumeration-marker.d.ts.map +1 -0
- package/dist/detectors/enumeration-marker.js +8 -0
- package/dist/detectors/enumeration-marker.js.map +1 -0
- package/dist/detectors/event-title-item.d.ts +8 -0
- package/dist/detectors/event-title-item.d.ts.map +1 -0
- package/dist/detectors/event-title-item.js +45 -0
- package/dist/detectors/event-title-item.js.map +1 -0
- package/dist/detectors/example-baseline.d.ts +5 -0
- package/dist/detectors/example-baseline.d.ts.map +1 -1
- package/dist/detectors/example-baseline.js +15 -1
- package/dist/detectors/example-baseline.js.map +1 -1
- package/dist/detectors/filler-word.d.ts +11 -0
- package/dist/detectors/filler-word.d.ts.map +1 -0
- package/dist/detectors/filler-word.js +73 -0
- package/dist/detectors/filler-word.js.map +1 -0
- package/dist/detectors/fullwidth-alnum.d.ts.map +1 -1
- package/dist/detectors/fullwidth-alnum.js +19 -0
- package/dist/detectors/fullwidth-alnum.js.map +1 -1
- package/dist/detectors/heading-case.d.ts.map +1 -1
- package/dist/detectors/heading-case.js +6 -1
- package/dist/detectors/heading-case.js.map +1 -1
- package/dist/detectors/heading-marker-no-space.d.ts +3 -0
- package/dist/detectors/heading-marker-no-space.d.ts.map +1 -0
- package/dist/detectors/heading-marker-no-space.js +49 -0
- package/dist/detectors/heading-marker-no-space.js.map +1 -0
- package/dist/detectors/hyphen-name-suffix.d.ts.map +1 -1
- package/dist/detectors/hyphen-name-suffix.js +3 -2
- package/dist/detectors/hyphen-name-suffix.js.map +1 -1
- package/dist/detectors/inline-item-label.d.ts +6 -0
- package/dist/detectors/inline-item-label.d.ts.map +1 -0
- package/dist/detectors/inline-item-label.js +68 -0
- package/dist/detectors/inline-item-label.js.map +1 -0
- package/dist/detectors/kanji-name-edge.d.ts +5 -0
- package/dist/detectors/kanji-name-edge.d.ts.map +1 -1
- package/dist/detectors/kanji-name-edge.js +9 -0
- package/dist/detectors/kanji-name-edge.js.map +1 -1
- package/dist/detectors/known-correction.d.ts.map +1 -1
- package/dist/detectors/known-correction.js +13 -1
- package/dist/detectors/known-correction.js.map +1 -1
- package/dist/detectors/link-definition.d.ts +3 -0
- package/dist/detectors/link-definition.d.ts.map +1 -0
- package/dist/detectors/link-definition.js +78 -0
- package/dist/detectors/link-definition.js.map +1 -0
- package/dist/detectors/list-item-asides.d.ts +7 -0
- package/dist/detectors/list-item-asides.d.ts.map +1 -0
- package/dist/detectors/list-item-asides.js +25 -0
- package/dist/detectors/list-item-asides.js.map +1 -0
- package/dist/detectors/list-item.d.ts +2 -0
- package/dist/detectors/list-item.d.ts.map +1 -1
- package/dist/detectors/list-item.js +6 -0
- package/dist/detectors/list-item.js.map +1 -1
- package/dist/detectors/list-items.d.ts.map +1 -1
- package/dist/detectors/list-items.js +12 -3
- package/dist/detectors/list-items.js.map +1 -1
- package/dist/detectors/list-opening-conjunction.d.ts +7 -0
- package/dist/detectors/list-opening-conjunction.d.ts.map +1 -0
- package/dist/detectors/list-opening-conjunction.js +22 -0
- package/dist/detectors/list-opening-conjunction.js.map +1 -0
- package/dist/detectors/list-parallel.d.ts.map +1 -1
- package/dist/detectors/list-parallel.js +11 -14
- package/dist/detectors/list-parallel.js.map +1 -1
- package/dist/detectors/list-run.d.ts.map +1 -1
- package/dist/detectors/list-run.js +15 -3
- package/dist/detectors/list-run.js.map +1 -1
- package/dist/detectors/list-verb-series.d.ts +6 -0
- package/dist/detectors/list-verb-series.d.ts.map +1 -0
- package/dist/detectors/list-verb-series.js +20 -0
- package/dist/detectors/list-verb-series.js.map +1 -0
- package/dist/detectors/mark-shape.d.ts +5 -2
- package/dist/detectors/mark-shape.d.ts.map +1 -1
- package/dist/detectors/mark-shape.js +12 -15
- package/dist/detectors/mark-shape.js.map +1 -1
- package/dist/detectors/markdown-slip.d.ts +5 -0
- package/dist/detectors/markdown-slip.d.ts.map +1 -1
- package/dist/detectors/markdown-slip.js +23 -0
- package/dist/detectors/markdown-slip.js.map +1 -1
- package/dist/detectors/marked-word.d.ts +10 -0
- package/dist/detectors/marked-word.d.ts.map +1 -0
- package/dist/detectors/marked-word.js +30 -0
- package/dist/detectors/marked-word.js.map +1 -0
- package/dist/detectors/middle-dot.d.ts +1 -1
- package/dist/detectors/middle-dot.d.ts.map +1 -1
- package/dist/detectors/middle-dot.js +21 -2
- package/dist/detectors/middle-dot.js.map +1 -1
- package/dist/detectors/missing-final-period.d.ts.map +1 -1
- package/dist/detectors/missing-final-period.js +8 -1
- package/dist/detectors/missing-final-period.js.map +1 -1
- package/dist/detectors/name-variant-two-things.d.ts +2 -1
- package/dist/detectors/name-variant-two-things.d.ts.map +1 -1
- package/dist/detectors/name-variant-two-things.js +30 -2
- package/dist/detectors/name-variant-two-things.js.map +1 -1
- package/dist/detectors/net-amount-mismatch.d.ts.map +1 -1
- package/dist/detectors/net-amount-mismatch.js +26 -4
- package/dist/detectors/net-amount-mismatch.js.map +1 -1
- package/dist/detectors/nominalization.d.ts.map +1 -1
- package/dist/detectors/nominalization.js +6 -1
- package/dist/detectors/nominalization.js.map +1 -1
- package/dist/detectors/number-style.d.ts +2 -0
- package/dist/detectors/number-style.d.ts.map +1 -1
- package/dist/detectors/number-style.js +5 -0
- package/dist/detectors/number-style.js.map +1 -1
- package/dist/detectors/ordinary-phrase.d.ts +5 -0
- package/dist/detectors/ordinary-phrase.d.ts.map +1 -1
- package/dist/detectors/ordinary-phrase.js +12 -0
- package/dist/detectors/ordinary-phrase.js.map +1 -1
- package/dist/detectors/organisation-run.d.ts +2 -0
- package/dist/detectors/organisation-run.d.ts.map +1 -1
- package/dist/detectors/organisation-run.js +7 -0
- package/dist/detectors/organisation-run.js.map +1 -1
- package/dist/detectors/orthographic-variant-kanji-word.d.ts +22 -0
- package/dist/detectors/orthographic-variant-kanji-word.d.ts.map +1 -0
- package/dist/detectors/orthographic-variant-kanji-word.js +27 -0
- package/dist/detectors/orthographic-variant-kanji-word.js.map +1 -0
- package/dist/detectors/orthographic-variant-open.d.ts.map +1 -1
- package/dist/detectors/orthographic-variant-open.js +2 -1
- package/dist/detectors/orthographic-variant-open.js.map +1 -1
- package/dist/detectors/orthographic-variant-text.d.ts +7 -0
- package/dist/detectors/orthographic-variant-text.d.ts.map +1 -0
- package/dist/detectors/orthographic-variant-text.js +14 -0
- package/dist/detectors/orthographic-variant-text.js.map +1 -0
- package/dist/detectors/orthographic-variant.d.ts.map +1 -1
- package/dist/detectors/orthographic-variant.js +22 -23
- package/dist/detectors/orthographic-variant.js.map +1 -1
- package/dist/detectors/orthography.d.ts.map +1 -1
- package/dist/detectors/orthography.js +12 -2
- package/dist/detectors/orthography.js.map +1 -1
- package/dist/detectors/oxford-comma.d.ts.map +1 -1
- package/dist/detectors/oxford-comma.js +14 -3
- package/dist/detectors/oxford-comma.js.map +1 -1
- package/dist/detectors/paragraph-run.d.ts +1 -1
- package/dist/detectors/paragraph-run.d.ts.map +1 -1
- package/dist/detectors/paragraph-run.js +4 -2
- package/dist/detectors/paragraph-run.js.map +1 -1
- package/dist/detectors/placeholder-text.d.ts.map +1 -1
- package/dist/detectors/placeholder-text.js +12 -4
- package/dist/detectors/placeholder-text.js.map +1 -1
- package/dist/detectors/placeholder.d.ts +1 -0
- package/dist/detectors/placeholder.d.ts.map +1 -1
- package/dist/detectors/placeholder.js +8 -0
- package/dist/detectors/placeholder.js.map +1 -1
- package/dist/detectors/pseudo-heading.d.ts +9 -0
- package/dist/detectors/pseudo-heading.d.ts.map +1 -0
- package/dist/detectors/pseudo-heading.js +54 -0
- package/dist/detectors/pseudo-heading.js.map +1 -0
- package/dist/detectors/quote-around.d.ts +1 -1
- package/dist/detectors/quote-around.d.ts.map +1 -1
- package/dist/detectors/quote-around.js +26 -5
- package/dist/detectors/quote-around.js.map +1 -1
- package/dist/detectors/quoted-label.d.ts +8 -0
- package/dist/detectors/quoted-label.d.ts.map +1 -0
- package/dist/detectors/quoted-label.js +18 -0
- package/dist/detectors/quoted-label.js.map +1 -0
- package/dist/detectors/ra-nuki.d.ts +1 -7
- package/dist/detectors/ra-nuki.d.ts.map +1 -1
- package/dist/detectors/ra-nuki.js +2 -27
- package/dist/detectors/ra-nuki.js.map +1 -1
- package/dist/detectors/register-required.d.ts +27 -0
- package/dist/detectors/register-required.d.ts.map +1 -0
- package/dist/detectors/register-required.js +33 -0
- package/dist/detectors/register-required.js.map +1 -0
- package/dist/detectors/register-voice.d.ts +13 -1
- package/dist/detectors/register-voice.d.ts.map +1 -1
- package/dist/detectors/register-voice.js +27 -0
- package/dist/detectors/register-voice.js.map +1 -1
- package/dist/detectors/registry/enumeration-marker.d.ts +3 -0
- package/dist/detectors/registry/enumeration-marker.d.ts.map +1 -0
- package/dist/detectors/registry/enumeration-marker.js +3 -0
- package/dist/detectors/registry/enumeration-marker.js.map +1 -0
- package/dist/detectors/registry/filler-word.d.ts +3 -0
- package/dist/detectors/registry/filler-word.d.ts.map +1 -0
- package/dist/detectors/registry/filler-word.js +3 -0
- package/dist/detectors/registry/filler-word.js.map +1 -0
- package/dist/detectors/registry/heading-marker-no-space.d.ts +3 -0
- package/dist/detectors/registry/heading-marker-no-space.d.ts.map +1 -0
- package/dist/detectors/registry/heading-marker-no-space.js +3 -0
- package/dist/detectors/registry/heading-marker-no-space.js.map +1 -0
- package/dist/detectors/registry/link-definition-unused.d.ts +3 -0
- package/dist/detectors/registry/link-definition-unused.d.ts.map +1 -0
- package/dist/detectors/registry/link-definition-unused.js +3 -0
- package/dist/detectors/registry/link-definition-unused.js.map +1 -0
- package/dist/detectors/registry/pseudo-heading.d.ts +3 -0
- package/dist/detectors/registry/pseudo-heading.d.ts.map +1 -0
- package/dist/detectors/registry/pseudo-heading.js +3 -0
- package/dist/detectors/registry/pseudo-heading.js.map +1 -0
- package/dist/detectors/registry/reversed-link.d.ts +3 -0
- package/dist/detectors/registry/reversed-link.d.ts.map +1 -0
- package/dist/detectors/registry/reversed-link.js +3 -0
- package/dist/detectors/registry/reversed-link.js.map +1 -0
- package/dist/detectors/registry/sa-ire.d.ts +3 -0
- package/dist/detectors/registry/sa-ire.d.ts.map +1 -0
- package/dist/detectors/registry/sa-ire.js +3 -0
- package/dist/detectors/registry/sa-ire.js.map +1 -0
- package/dist/detectors/registry/table-absorbed-line.d.ts +3 -0
- package/dist/detectors/registry/table-absorbed-line.d.ts.map +1 -0
- package/dist/detectors/registry/table-absorbed-line.js +3 -0
- package/dist/detectors/registry/table-absorbed-line.js.map +1 -0
- package/dist/detectors/registry/term-consistency.d.ts +3 -0
- package/dist/detectors/registry/term-consistency.d.ts.map +1 -0
- package/dist/detectors/registry/term-consistency.js +3 -0
- package/dist/detectors/registry/term-consistency.js.map +1 -0
- package/dist/detectors/registry/term-form.d.ts +3 -0
- package/dist/detectors/registry/term-form.d.ts.map +1 -0
- package/dist/detectors/registry/term-form.js +3 -0
- package/dist/detectors/registry/term-form.js.map +1 -0
- package/dist/detectors/relative-pronoun-mix.d.ts +1 -1
- package/dist/detectors/relative-pronoun-mix.d.ts.map +1 -1
- package/dist/detectors/relative-pronoun-mix.js +14 -3
- package/dist/detectors/relative-pronoun-mix.js.map +1 -1
- package/dist/detectors/release-notes.d.ts +7 -0
- package/dist/detectors/release-notes.d.ts.map +1 -0
- package/dist/detectors/release-notes.js +12 -0
- package/dist/detectors/release-notes.js.map +1 -0
- package/dist/detectors/request-owner.d.ts +5 -1
- package/dist/detectors/request-owner.d.ts.map +1 -1
- package/dist/detectors/request-owner.js +53 -1
- package/dist/detectors/request-owner.js.map +1 -1
- package/dist/detectors/reversed-link.d.ts +3 -0
- package/dist/detectors/reversed-link.d.ts.map +1 -0
- package/dist/detectors/reversed-link.js +31 -0
- package/dist/detectors/reversed-link.js.map +1 -0
- package/dist/detectors/sa-ire.d.ts +3 -0
- package/dist/detectors/sa-ire.d.ts.map +1 -0
- package/dist/detectors/sa-ire.js +5 -0
- package/dist/detectors/sa-ire.js.map +1 -0
- package/dist/detectors/sentence-counts.d.ts.map +1 -1
- package/dist/detectors/sentence-counts.js +19 -6
- package/dist/detectors/sentence-counts.js.map +1 -1
- package/dist/detectors/sentence-ending.d.ts.map +1 -1
- package/dist/detectors/sentence-ending.js +35 -11
- package/dist/detectors/sentence-ending.js.map +1 -1
- package/dist/detectors/sentence-length.d.ts.map +1 -1
- package/dist/detectors/sentence-length.js +11 -1
- package/dist/detectors/sentence-length.js.map +1 -1
- package/dist/detectors/sentence-rhythm.d.ts.map +1 -1
- package/dist/detectors/sentence-rhythm.js +6 -2
- package/dist/detectors/sentence-rhythm.js.map +1 -1
- package/dist/detectors/signals.js +2 -2
- package/dist/detectors/signals.js.map +1 -1
- package/dist/detectors/structure.d.ts +1 -0
- package/dist/detectors/structure.d.ts.map +1 -1
- package/dist/detectors/structure.js +5 -0
- package/dist/detectors/structure.js.map +1 -1
- package/dist/detectors/technical-docs.d.ts +8 -1
- package/dist/detectors/technical-docs.d.ts.map +1 -1
- package/dist/detectors/technical-docs.js +16 -3
- package/dist/detectors/technical-docs.js.map +1 -1
- package/dist/detectors/term-consistency.d.ts +4 -0
- package/dist/detectors/term-consistency.d.ts.map +1 -0
- package/dist/detectors/term-consistency.js +35 -0
- package/dist/detectors/term-consistency.js.map +1 -0
- package/dist/detectors/term-form.d.ts +4 -0
- package/dist/detectors/term-form.d.ts.map +1 -0
- package/dist/detectors/term-form.js +17 -0
- package/dist/detectors/term-form.js.map +1 -0
- package/dist/detectors/token-shape.d.ts.map +1 -1
- package/dist/detectors/token-shape.js +4 -1
- package/dist/detectors/token-shape.js.map +1 -1
- package/dist/detectors/unbalanced-bracket.d.ts +1 -1
- package/dist/detectors/unbalanced-bracket.d.ts.map +1 -1
- package/dist/detectors/unbalanced-bracket.js +4 -2
- package/dist/detectors/unbalanced-bracket.js.map +1 -1
- package/dist/detectors/unknown-word-context.d.ts +2 -0
- package/dist/detectors/unknown-word-context.d.ts.map +1 -1
- package/dist/detectors/unknown-word-context.js +3 -0
- package/dist/detectors/unknown-word-context.js.map +1 -1
- package/dist/detectors/unknown-word.d.ts.map +1 -1
- package/dist/detectors/unknown-word.js +7 -2
- package/dist/detectors/unknown-word.js.map +1 -1
- package/dist/detectors/vague-density.d.ts.map +1 -1
- package/dist/detectors/vague-density.js +10 -2
- package/dist/detectors/vague-density.js.map +1 -1
- package/dist/detectors/version-mismatch.d.ts.map +1 -1
- package/dist/detectors/version-mismatch.js +5 -1
- package/dist/detectors/version-mismatch.js.map +1 -1
- package/dist/detectors/weasel-word.d.ts.map +1 -1
- package/dist/detectors/weasel-word.js +11 -2
- package/dist/detectors/weasel-word.js.map +1 -1
- package/dist/document-prose.d.ts +17 -0
- package/dist/document-prose.d.ts.map +1 -0
- package/dist/document-prose.js +35 -0
- package/dist/document-prose.js.map +1 -0
- package/dist/document-scope.d.ts +16 -0
- package/dist/document-scope.d.ts.map +1 -0
- package/dist/document-scope.js +51 -0
- package/dist/document-scope.js.map +1 -0
- package/dist/document.d.ts +10 -1
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +26 -37
- package/dist/document.js.map +1 -1
- package/dist/enumeration-marks.d.ts +23 -0
- package/dist/enumeration-marks.d.ts.map +1 -0
- package/dist/enumeration-marks.js +184 -0
- package/dist/enumeration-marks.js.map +1 -0
- package/dist/facts/cross-facts.d.ts +1 -1
- package/dist/facts/cross-facts.d.ts.map +1 -1
- package/dist/facts/cross-facts.js +8 -3
- package/dist/facts/cross-facts.js.map +1 -1
- package/dist/facts/labelled-facts.d.ts.map +1 -1
- package/dist/facts/labelled-facts.js +7 -4
- package/dist/facts/labelled-facts.js.map +1 -1
- package/dist/file-header.d.ts +2 -6
- package/dist/file-header.d.ts.map +1 -1
- package/dist/file-header.js +1 -1
- package/dist/file-header.js.map +1 -1
- package/dist/files.d.ts +18 -1
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +58 -8
- package/dist/files.js.map +1 -1
- package/dist/gitignore.d.ts +30 -0
- package/dist/gitignore.d.ts.map +1 -0
- package/dist/gitignore.js +68 -0
- package/dist/gitignore.js.map +1 -0
- package/dist/grade/stamp.d.ts.map +1 -1
- package/dist/grade/stamp.js +5 -0
- package/dist/grade/stamp.js.map +1 -1
- package/dist/latin-word-boundary.d.ts +5 -0
- package/dist/latin-word-boundary.d.ts.map +1 -1
- package/dist/latin-word-boundary.js +11 -0
- package/dist/latin-word-boundary.js.map +1 -1
- package/dist/markdown-node.d.ts +1 -0
- package/dist/markdown-node.d.ts.map +1 -1
- package/dist/markdown-node.js.map +1 -1
- package/dist/name-separator.d.ts.map +1 -1
- package/dist/name-separator.js +27 -5
- package/dist/name-separator.js.map +1 -1
- package/dist/news-dateline.d.ts +7 -0
- package/dist/news-dateline.d.ts.map +1 -0
- package/dist/news-dateline.js +24 -0
- package/dist/news-dateline.js.map +1 -0
- package/dist/plugin.d.ts +24 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/reasons.d.ts +4 -0
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +4 -0
- package/dist/reasons.js.map +1 -1
- package/dist/render/explain.d.ts +3 -0
- package/dist/render/explain.d.ts.map +1 -1
- package/dist/render/explain.js +19 -1
- package/dist/render/explain.js.map +1 -1
- package/dist/render/rules-json.d.ts.map +1 -1
- package/dist/render/rules-json.js +12 -2
- package/dist/render/rules-json.js.map +1 -1
- package/dist/render/summary.d.ts +5 -2
- package/dist/render/summary.d.ts.map +1 -1
- package/dist/render/summary.js +25 -4
- package/dist/render/summary.js.map +1 -1
- package/dist/render/suppressions.d.ts +6 -1
- package/dist/render/suppressions.d.ts.map +1 -1
- package/dist/render/suppressions.js +76 -3
- package/dist/render/suppressions.js.map +1 -1
- package/dist/rule-load.d.ts.map +1 -1
- package/dist/rule-load.js +2 -1
- package/dist/rule-load.js.map +1 -1
- package/dist/run-in-title.d.ts +4 -0
- package/dist/run-in-title.d.ts.map +1 -0
- package/dist/run-in-title.js +82 -0
- package/dist/run-in-title.js.map +1 -0
- package/dist/run.d.ts +2 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +20 -8
- package/dist/run.js.map +1 -1
- package/dist/scope-markers.d.ts +9 -0
- package/dist/scope-markers.d.ts.map +1 -0
- package/dist/scope-markers.js +19 -0
- package/dist/scope-markers.js.map +1 -0
- package/dist/scope-problem-text.d.ts +4 -0
- package/dist/scope-problem-text.d.ts.map +1 -0
- package/dist/scope-problem-text.js +17 -0
- package/dist/scope-problem-text.js.map +1 -0
- package/dist/scoped-sentences.d.ts +21 -0
- package/dist/scoped-sentences.d.ts.map +1 -0
- package/dist/scoped-sentences.js +21 -0
- package/dist/scoped-sentences.js.map +1 -0
- package/dist/setting-problems.d.ts.map +1 -1
- package/dist/setting-problems.js +4 -0
- package/dist/setting-problems.js.map +1 -1
- package/dist/spelling.js +4 -4
- package/dist/spelling.js.map +1 -1
- package/dist/stet-body.d.ts +13 -0
- package/dist/stet-body.d.ts.map +1 -0
- package/dist/stet-body.js +49 -0
- package/dist/stet-body.js.map +1 -0
- package/dist/stet.d.ts +30 -4
- package/dist/stet.d.ts.map +1 -1
- package/dist/stet.js +78 -28
- package/dist/stet.js.map +1 -1
- package/dist/structure/alert-lines.d.ts +4 -0
- package/dist/structure/alert-lines.d.ts.map +1 -0
- package/dist/structure/alert-lines.js +19 -0
- package/dist/structure/alert-lines.js.map +1 -0
- package/dist/structure/catch-all-row-blank.d.ts +9 -0
- package/dist/structure/catch-all-row-blank.d.ts.map +1 -0
- package/dist/structure/catch-all-row-blank.js +19 -0
- package/dist/structure/catch-all-row-blank.js.map +1 -0
- package/dist/structure/change-rate-tied.d.ts +22 -0
- package/dist/structure/change-rate-tied.d.ts.map +1 -0
- package/dist/structure/change-rate-tied.js +85 -0
- package/dist/structure/change-rate-tied.js.map +1 -0
- package/dist/structure/cross-definitions.d.ts +1 -1
- package/dist/structure/cross-definitions.d.ts.map +1 -1
- package/dist/structure/cross-definitions.js +3 -9
- package/dist/structure/cross-definitions.js.map +1 -1
- package/dist/structure/defining-names.d.ts +1 -1
- package/dist/structure/defining-names.d.ts.map +1 -1
- package/dist/structure/defining-names.js +12 -1
- package/dist/structure/defining-names.js.map +1 -1
- package/dist/structure/net-amount.d.ts +16 -0
- package/dist/structure/net-amount.d.ts.map +1 -1
- package/dist/structure/net-amount.js +28 -1
- package/dist/structure/net-amount.js.map +1 -1
- package/dist/structure/period-label-conflict.d.ts +2 -2
- package/dist/structure/period-label-conflict.d.ts.map +1 -1
- package/dist/structure/period-label-conflict.js +17 -3
- package/dist/structure/period-label-conflict.js.map +1 -1
- package/dist/structure/serial-range.d.ts.map +1 -1
- package/dist/structure/serial-range.js +14 -6
- package/dist/structure/serial-range.js.map +1 -1
- package/dist/structure/version-mismatch.d.ts +6 -1
- package/dist/structure/version-mismatch.d.ts.map +1 -1
- package/dist/structure/version-mismatch.js +28 -6
- package/dist/structure/version-mismatch.js.map +1 -1
- package/dist/structure/weekday.d.ts.map +1 -1
- package/dist/structure/weekday.js +14 -1
- package/dist/structure/weekday.js.map +1 -1
- package/dist/table-cells.d.ts +1 -1
- package/dist/table-cells.d.ts.map +1 -1
- package/dist/table-cells.js.map +1 -1
- package/dist/term-form.d.ts +15 -0
- package/dist/term-form.d.ts.map +1 -0
- package/dist/term-form.js +72 -0
- package/dist/term-form.js.map +1 -0
- package/dist/term-groups.d.ts +33 -0
- package/dist/term-groups.d.ts.map +1 -0
- package/dist/term-groups.js +46 -0
- package/dist/term-groups.js.map +1 -0
- package/dist/text-scope.d.ts +35 -0
- package/dist/text-scope.d.ts.map +1 -0
- package/dist/text-scope.js +55 -0
- package/dist/text-scope.js.map +1 -0
- package/dist/topic-clause.d.ts.map +1 -1
- package/dist/topic-clause.js +85 -16
- package/dist/topic-clause.js.map +1 -1
- package/dist/unclosed-code-quote.d.ts +7 -0
- package/dist/unclosed-code-quote.d.ts.map +1 -0
- package/dist/unclosed-code-quote.js +37 -0
- package/dist/unclosed-code-quote.js.map +1 -0
- package/package.json +4 -3
- package/rules/adverb-overuse.yaml +2 -2
- package/rules/bold-density.yaml +2 -2
- package/rules/bold-label-list.yaml +2 -2
- package/rules/bracket-width-consistency.yaml +2 -2
- package/rules/broken-link.yaml +2 -2
- package/rules/change-rate-mismatch.yaml +2 -2
- package/rules/code-fence-language-mix.yaml +2 -2
- package/rules/comparative-without-baseline.yaml +2 -2
- package/rules/contraction-consistency.yaml +3 -3
- package/rules/cross-doc-duplicate-definition.yaml +2 -2
- package/rules/cross-doc-fact-conflict.yaml +2 -2
- package/rules/cross-doc-term-variant.yaml +4 -4
- package/rules/date-format-consistency.yaml +2 -2
- package/rules/date-weekday-mismatch.yaml +2 -2
- package/rules/date-without-year.yaml +2 -2
- package/rules/defined-term-form.yaml +2 -2
- package/rules/elapsed-years-mismatch.yaml +2 -2
- package/rules/empty-section.yaml +2 -2
- package/rules/empty-table-cell.yaml +2 -2
- package/rules/enumeration-marker-mix.yaml +102 -0
- package/rules/filler-word.yaml +74 -0
- package/rules/fullwidth-alnum-consistency.yaml +2 -2
- package/rules/heading-marker-no-space.yaml +79 -0
- package/rules/hyphen-as-dash.yaml +2 -2
- package/rules/known-misspelling.yaml +2 -2
- package/rules/latin-spacing.yaml +4 -4
- package/rules/link-definition-unused.yaml +107 -0
- package/rules/list-item-form-mix.yaml +2 -2
- package/rules/max-kanji-continuous.yaml +5 -2
- package/rules/max-sentence-length.yaml +2 -2
- package/rules/missing-final-period.yaml +2 -2
- package/rules/name-variant.yaml +2 -2
- package/rules/net-amount-mismatch.yaml +5 -5
- package/rules/no-doubled-joshi.yaml +2 -2
- package/rules/no-mixed-desumasu.yaml +62 -2
- package/rules/no-nakaguro-parallel.yaml +2 -2
- package/rules/nominalization.yaml +2 -2
- package/rules/number-style-consistency.yaml +2 -2
- package/rules/obligation-without-deadline.yaml +2 -2
- package/rules/one-sentence-paragraph-run.yaml +2 -2
- package/rules/orthographic-variant.yaml +2 -2
- package/rules/oxford-comma-consistency.yaml +2 -2
- package/rules/period-label-conflict.yaml +2 -2
- package/rules/preamble-length.yaml +2 -2
- package/rules/pseudo-heading.yaml +79 -0
- package/rules/quote-without-source.yaml +2 -2
- package/rules/repeated-sentence-ending.yaml +2 -2
- package/rules/request-without-deadline.yaml +2 -2
- package/rules/reversed-link.yaml +78 -0
- package/rules/sa-ire.yaml +43 -0
- package/rules/sentence-rhythm.yaml +2 -2
- package/rules/serial-range-reversed.yaml +4 -4
- package/rules/shell-prompt-mix.yaml +2 -2
- package/rules/table-absorbed-line.yaml +88 -0
- package/rules/teki-overuse.yaml +2 -2
- package/rules/term-consistency.yaml +56 -0
- package/rules/term-form.yaml +56 -0
- package/rules/title-case-consistency.yaml +4 -4
- package/rules/title-length.yaml +2 -2
- package/rules/topic-predicate-distance.yaml +2 -2
- package/rules/unbalanced-bracket.yaml +2 -2
- package/rules/undefined-acronym.yaml +4 -2
- package/rules/undefined-term.yaml +2 -2
- package/rules/unfilled-placeholder.yaml +2 -2
- package/rules/unknown-word.yaml +2 -2
- package/rules/use-before-definition.yaml +2 -2
- package/rules/vague-word-density.yaml +2 -2
- package/rules/version-mismatch.yaml +2 -2
- package/rules/weasel-word.yaml +3 -3
- package/rules/which-that-consistency.yaml +2 -2
- package/skills/chaff/SKILL.md +51 -7
- package/src/allow.ts +146 -0
- package/src/check-source.ts +33 -9
- package/src/cli-text.ts +13 -4
- package/src/cli.ts +16 -15
- package/src/commands/eval.ts +1 -1
- package/src/commands/suppressions.ts +3 -3
- package/src/commands/test.ts +1 -1
- package/src/compound-head.ts +17 -8
- package/src/config/allow-problems.ts +75 -0
- package/src/config/by-path-problems.ts +29 -3
- package/src/config/by-path-rules.ts +78 -0
- package/src/config/by-path.ts +9 -0
- package/src/config/consistent-problems.ts +36 -0
- package/src/config/load.ts +87 -15
- package/src/config/option-problems.ts +8 -5
- package/src/config/prefer-problems.ts +22 -0
- package/src/config/prefer.ts +52 -0
- package/src/config/term-problems.ts +38 -0
- package/src/config/warnings.ts +9 -2
- package/src/cross-variants.ts +4 -7
- package/src/cross-votes.ts +35 -4
- package/src/custom/parse.ts +16 -3
- package/src/custom/problems.ts +9 -3
- package/src/custom/scope-field.ts +16 -0
- package/src/date-format.ts +43 -8
- package/src/derived/elapsed.ts +17 -2
- package/src/detectors/acronym-context.ts +7 -1
- package/src/detectors/acronym-gloss.ts +59 -11
- package/src/detectors/bare-comparative.ts +35 -3
- package/src/detectors/blank-structure.ts +18 -9
- package/src/detectors/bold-label.ts +7 -2
- package/src/detectors/bracket-title-date.ts +36 -0
- package/src/detectors/broken-link.ts +14 -1
- package/src/detectors/capitalised-term.ts +18 -4
- package/src/detectors/change-rate.ts +29 -4
- package/src/detectors/char-shape.ts +13 -17
- package/src/detectors/clause-shape.ts +8 -4
- package/src/detectors/contraction-mix.ts +8 -2
- package/src/detectors/contraction-set-apart.ts +22 -2
- package/src/detectors/coordinate-adjective.ts +54 -1
- package/src/detectors/count-per-section.ts +13 -8
- package/src/detectors/counter-edge.ts +20 -0
- package/src/detectors/cross-variant.ts +16 -2
- package/src/detectors/custom.ts +6 -4
- package/src/detectors/date-format.ts +1 -1
- package/src/detectors/date-repeated-day.ts +20 -0
- package/src/detectors/date-year.ts +8 -1
- package/src/detectors/defined-term-form.ts +6 -3
- package/src/detectors/definition-use.ts +7 -1
- package/src/detectors/derived-numbers.ts +1 -0
- package/src/detectors/document-shape.ts +4 -1
- package/src/detectors/email-letter.ts +6 -2
- package/src/detectors/empty-section.ts +10 -2
- package/src/detectors/en-shape.ts +17 -1
- package/src/detectors/enumeration-marker.ts +14 -0
- package/src/detectors/event-title-item.ts +57 -0
- package/src/detectors/example-baseline.ts +16 -1
- package/src/detectors/filler-word.ts +96 -0
- package/src/detectors/fullwidth-alnum.ts +24 -0
- package/src/detectors/heading-case.ts +7 -1
- package/src/detectors/heading-marker-no-space.ts +62 -0
- package/src/detectors/hyphen-name-suffix.ts +3 -2
- package/src/detectors/inline-item-label.ts +98 -0
- package/src/detectors/kanji-name-edge.ts +11 -0
- package/src/detectors/known-correction.ts +17 -1
- package/src/detectors/link-definition.ts +91 -0
- package/src/detectors/list-item-asides.ts +29 -0
- package/src/detectors/list-item.ts +7 -0
- package/src/detectors/list-items.ts +13 -2
- package/src/detectors/list-opening-conjunction.ts +22 -0
- package/src/detectors/list-parallel.ts +11 -15
- package/src/detectors/list-run.ts +16 -3
- package/src/detectors/list-verb-series.ts +24 -0
- package/src/detectors/mark-shape.ts +15 -19
- package/src/detectors/markdown-slip.ts +25 -1
- package/src/detectors/marked-word.ts +40 -0
- package/src/detectors/middle-dot.ts +27 -2
- package/src/detectors/missing-final-period.ts +9 -1
- package/src/detectors/name-variant-two-things.ts +37 -2
- package/src/detectors/net-amount-mismatch.ts +41 -4
- package/src/detectors/nominalization.ts +8 -1
- package/src/detectors/number-style.ts +8 -0
- package/src/detectors/ordinary-phrase.ts +13 -0
- package/src/detectors/organisation-run.ts +9 -0
- package/src/detectors/orthographic-variant-kanji-word.ts +33 -0
- package/src/detectors/orthographic-variant-open.ts +2 -1
- package/src/detectors/orthographic-variant-text.ts +20 -0
- package/src/detectors/orthographic-variant.ts +25 -32
- package/src/detectors/orthography.ts +18 -2
- package/src/detectors/oxford-comma.ts +14 -2
- package/src/detectors/paragraph-run.ts +7 -10
- package/src/detectors/placeholder-text.ts +22 -5
- package/src/detectors/placeholder.ts +10 -0
- package/src/detectors/pseudo-heading.ts +59 -0
- package/src/detectors/quote-around.ts +31 -6
- package/src/detectors/quoted-label.ts +22 -0
- package/src/detectors/ra-nuki.ts +3 -34
- package/src/detectors/register-required.ts +56 -0
- package/src/detectors/register-voice.ts +36 -1
- package/src/detectors/registry/enumeration-marker.ts +4 -0
- package/src/detectors/registry/filler-word.ts +4 -0
- package/src/detectors/registry/heading-marker-no-space.ts +4 -0
- package/src/detectors/registry/link-definition-unused.ts +4 -0
- package/src/detectors/registry/pseudo-heading.ts +4 -0
- package/src/detectors/registry/reversed-link.ts +4 -0
- package/src/detectors/registry/sa-ire.ts +4 -0
- package/src/detectors/registry/table-absorbed-line.ts +4 -0
- package/src/detectors/registry/term-consistency.ts +4 -0
- package/src/detectors/registry/term-form.ts +4 -0
- package/src/detectors/relative-pronoun-mix.ts +18 -3
- package/src/detectors/release-notes.ts +19 -0
- package/src/detectors/request-owner.ts +62 -2
- package/src/detectors/reversed-link.ts +39 -0
- package/src/detectors/sa-ire.ts +7 -0
- package/src/detectors/sentence-counts.ts +28 -9
- package/src/detectors/sentence-ending.ts +53 -12
- package/src/detectors/sentence-length.ts +16 -2
- package/src/detectors/sentence-rhythm.ts +6 -2
- package/src/detectors/signals.ts +2 -2
- package/src/detectors/structure.ts +4 -0
- package/src/detectors/technical-docs.ts +27 -3
- package/src/detectors/term-consistency.ts +41 -0
- package/src/detectors/term-form.ts +17 -0
- package/src/detectors/token-shape.ts +4 -1
- package/src/detectors/unbalanced-bracket.ts +4 -2
- package/src/detectors/unknown-word-context.ts +6 -0
- package/src/detectors/unknown-word.ts +7 -1
- package/src/detectors/vague-density.ts +10 -2
- package/src/detectors/version-mismatch.ts +7 -1
- package/src/detectors/weasel-word.ts +13 -2
- package/src/document-prose.ts +43 -0
- package/src/document-scope.ts +66 -0
- package/src/document.ts +43 -50
- package/src/enumeration-marks.ts +233 -0
- package/src/facts/cross-facts.ts +10 -4
- package/src/facts/labelled-facts.ts +7 -4
- package/src/file-header.ts +3 -5
- package/src/files.ts +87 -8
- package/src/gitignore.ts +83 -0
- package/src/grade/stamp.ts +5 -0
- package/src/latin-word-boundary.ts +12 -0
- package/src/markdown-node.ts +1 -0
- package/src/name-separator.ts +29 -7
- package/src/news-dateline.ts +29 -0
- package/src/plugin.ts +21 -3
- package/src/reasons.ts +8 -0
- package/src/render/explain.ts +26 -1
- package/src/render/rules-json.ts +16 -2
- package/src/render/summary.ts +33 -4
- package/src/render/suppressions.ts +101 -4
- package/src/rule-load.ts +3 -2
- package/src/run-in-title.ts +91 -0
- package/src/run.ts +21 -8
- package/src/scope-markers.ts +25 -0
- package/src/scope-problem-text.ts +21 -0
- package/src/scoped-sentences.ts +41 -0
- package/src/setting-problems.ts +4 -0
- package/src/spelling.ts +4 -4
- package/src/stet-body.ts +74 -0
- package/src/stet.ts +113 -32
- package/src/structure/alert-lines.ts +19 -0
- package/src/structure/catch-all-row-blank.ts +22 -0
- package/src/structure/change-rate-tied.ts +113 -0
- package/src/structure/cross-definitions.ts +6 -9
- package/src/structure/defining-names.ts +14 -1
- package/src/structure/net-amount.ts +44 -5
- package/src/structure/period-label-conflict.ts +22 -7
- package/src/structure/serial-range.ts +14 -6
- package/src/structure/version-mismatch.ts +41 -8
- package/src/structure/weekday.ts +14 -1
- package/src/table-cells.ts +2 -2
- package/src/term-form.ts +99 -0
- package/src/term-groups.ts +68 -0
- package/src/text-scope.ts +79 -0
- package/src/topic-clause.ts +96 -17
- package/src/unclosed-code-quote.ts +42 -0
package/src/run.ts
CHANGED
|
@@ -53,9 +53,11 @@ export const levelFor = (rule: RuleDefinition, settings: Settings, experimental:
|
|
|
53
53
|
return "normal";
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
/** Why a rule at off did not run: chaff.yaml turned it off, the genre's preset did, it waits for a style, or it is experimental. */
|
|
57
|
-
const offSkip = (rule: RuleDefinition,
|
|
58
|
-
|
|
56
|
+
/** Why a rule at off did not run: a by_path entry or chaff.yaml turned it off, the genre's preset did, it waits for a style, or it is experimental. */
|
|
57
|
+
const offSkip = (rule: RuleDefinition, context: RunContext, preset: Settings, reasons: Reasons): Skipped => {
|
|
58
|
+
const { settings, genre } = context;
|
|
59
|
+
const byPath = context.levelsFrom?.[rule.id];
|
|
60
|
+
if (settings[rule.id] !== undefined) return { rule: rule.id, why: byPath === undefined ? reasons.turnedOff : reasons.turnedOffBy(byPath) };
|
|
59
61
|
if (preset[rule.id] !== undefined) return { rule: rule.id, why: reasons.presetOff(genre) };
|
|
60
62
|
if (rule.opt_in === true) return { rule: rule.id, why: reasons.optIn };
|
|
61
63
|
return { rule: rule.id, why: reasons.experimental, offUntilExperimental: true };
|
|
@@ -116,6 +118,17 @@ const documentNeed = (rule: RuleDefinition, doc: ProseDocument): string | undefi
|
|
|
116
118
|
return absent === undefined ? reasonsFor(doc).oneDocument : reasonsFor(doc).noLexicon(doc.language, absent);
|
|
117
119
|
};
|
|
118
120
|
|
|
121
|
+
/**
|
|
122
|
+
* 語彙表を要求する rule で、その言語に語彙表が無ければ動かせない。黙って通さない。
|
|
123
|
+
* A rule that reads only the team's list (team_list) has nothing to check while chaff.yaml lists nothing: its 0 findings would read as checked and fine.
|
|
124
|
+
*/
|
|
125
|
+
const listNeed = (rule: RuleDefinition, doc: ProseDocument): string | undefined => {
|
|
126
|
+
const absent = missingList(rule, doc.lexicons);
|
|
127
|
+
if (absent !== undefined) return reasonsFor(doc).noLexicon(doc.language, absent);
|
|
128
|
+
const listed = rule.word_list === undefined ? undefined : doc.lexicons[rule.word_list];
|
|
129
|
+
return rule.team_list !== undefined && (listed ?? []).length === 0 ? reasonsFor(doc).noTeamList(rule.team_list) : undefined;
|
|
130
|
+
};
|
|
131
|
+
|
|
119
132
|
/** 知らない要求は満たされていないものとして扱う。黙って無視すると、要求なしで動いてしまう。 */
|
|
120
133
|
const has = (capabilities: ProseDocument["capabilities"], need: string): boolean => {
|
|
121
134
|
if (need === "pos") return capabilities.pos;
|
|
@@ -281,6 +294,8 @@ export type RunContext = {
|
|
|
281
294
|
readonly optionLayers?: readonly OptionLayer[];
|
|
282
295
|
/** The detectors loaded from the code chaff.yaml names, by rule id. They come before chaff's own table. */
|
|
283
296
|
readonly detectors?: Readonly<Record<string, Detector>>;
|
|
297
|
+
/** For each rule a by_path entry set, which entry: a rule it turns off says so where the rules that did not run are listed. */
|
|
298
|
+
readonly levelsFrom?: Readonly<Record<string, string>>;
|
|
284
299
|
};
|
|
285
300
|
|
|
286
301
|
export const runRules = (
|
|
@@ -309,7 +324,7 @@ export const runRulesWith = (doc: ProseDocument, rules: readonly RuleDefinition[
|
|
|
309
324
|
const blocked = unmet(rule, doc);
|
|
310
325
|
if (blocked !== undefined) return { findings: acc.findings, skipped: [...acc.skipped, { rule: rule.id, why: blocked }] };
|
|
311
326
|
const level = levelFor(rule, settings, experimental, preset);
|
|
312
|
-
if (level === "off") return { findings: acc.findings, skipped: [...acc.skipped, offSkip(rule,
|
|
327
|
+
if (level === "off") return { findings: acc.findings, skipped: [...acc.skipped, offSkip(rule, context, preset, reasonsFor(doc))] };
|
|
313
328
|
const noTags = untagged(rule, doc);
|
|
314
329
|
if (noTags !== undefined) return { findings: acc.findings, skipped: [...acc.skipped, { rule: rule.id, why: noTags }] };
|
|
315
330
|
// 木は capability ではなく、adapter が structure を持つかで決まる。持たない言語で動かすと「参照先が無い」が 0 件に見える。
|
|
@@ -323,10 +338,8 @@ export const runRulesWith = (doc: ProseDocument, rules: readonly RuleDefinition[
|
|
|
323
338
|
const detector = detectors[rule.id] ?? DETECTORS[rule.how_to_find];
|
|
324
339
|
if (detector === undefined)
|
|
325
340
|
return { findings: acc.findings, skipped: [...acc.skipped, { rule: rule.id, why: reasonsFor(doc).noDetector(rule.how_to_find) }] };
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
if (absent !== undefined)
|
|
329
|
-
return { findings: acc.findings, skipped: [...acc.skipped, { rule: rule.id, why: reasonsFor(doc).noLexicon(doc.language, absent) }] };
|
|
341
|
+
const noList = listNeed(rule, doc);
|
|
342
|
+
if (noList !== undefined) return { findings: acc.findings, skipped: [...acc.skipped, { rule: rule.id, why: noList }] };
|
|
330
343
|
const options = {
|
|
331
344
|
limit: limitFor(rule, level, genre, limits),
|
|
332
345
|
lexicon: rule.word_list === undefined ? undefined : doc.lexicons[rule.word_list],
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Span } from "./plugin.ts";
|
|
2
|
+
|
|
3
|
+
// The marks of a heading or a quotation that are syntax, not words: what a rule limited to headings or quotations must
|
|
4
|
+
// not read (`## 概要` reads 概要). Positions are in the text given. Pure.
|
|
5
|
+
|
|
6
|
+
const QUOTE_MARKS = /^[ \t]*(?:>[ \t]?)+/gmu;
|
|
7
|
+
const ATX_OPENING = /^[ \t]*#{1,6}(?=[ \t]|$)/gmu;
|
|
8
|
+
const ATX_CLOSING = /(?<![ \t])[ \t]+#+[ \t]*$/gmu;
|
|
9
|
+
const SETEXT_UNDERLINE = /^[ \t]*(?:=+|-+)[ \t]*$/gmu;
|
|
10
|
+
|
|
11
|
+
const spansOf = (text: string, pattern: RegExp): Span[] =>
|
|
12
|
+
[...text.matchAll(pattern)].flatMap((match) => (match[0] === "" ? [] : [{ start: match.index, end: match.index + match[0].length }]));
|
|
13
|
+
|
|
14
|
+
/** The `>` opening each line of a quotation, nested ones too (`> > `). */
|
|
15
|
+
export const quoteMarkers = (text: string): Span[] => spansOf(text, QUOTE_MARKS);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* One heading's `#` run, its closing `#` run and a setext underline (`===`), its quotation marks already blanked. The
|
|
19
|
+
* `#` of `C#` is a word: a closing run follows a space.
|
|
20
|
+
*/
|
|
21
|
+
export const headingMarkers = (heading: string): Span[] => [
|
|
22
|
+
...spansOf(heading, ATX_OPENING),
|
|
23
|
+
...spansOf(heading, ATX_CLOSING),
|
|
24
|
+
...spansOf(heading, SETEXT_UNDERLINE),
|
|
25
|
+
];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Texts, UiLanguage } from "./ui.ts";
|
|
2
|
+
import { TEXT_SCOPES, type ScopeProblem } from "./text-scope.ts";
|
|
3
|
+
|
|
4
|
+
// What is wrong with a scope written in chaff.yaml (custom_rules or prefer), as one sentence in the reader's language.
|
|
5
|
+
|
|
6
|
+
const NAMES = TEXT_SCOPES.join(" / ");
|
|
7
|
+
|
|
8
|
+
const TEXT: Texts<Readonly<Record<ScopeProblem["kind"], (written: string) => string>>> = {
|
|
9
|
+
ja: {
|
|
10
|
+
unknown: (written) => `scope の ${written} は知りません(${NAMES}。外すものは ~quote のように前に ~ を付けます)`,
|
|
11
|
+
"not-a-list": (written) => `scope: ${written} は読めません。[heading] や [list, table]、[~quote] のように名前を並べてください`,
|
|
12
|
+
empty: (written) => `scope: ${written} では読む所が残りません。選んだものをすべて ~ で外しています`,
|
|
13
|
+
},
|
|
14
|
+
en: {
|
|
15
|
+
unknown: (written) => `unknown scope ${written} (${NAMES}; put ~ in front of one to leave it out, as in ~quote)`,
|
|
16
|
+
"not-a-list": (written) => `cannot read scope: ${written}. Write a list of names, such as [heading], [list, table] or [~quote]`,
|
|
17
|
+
empty: (written) => `scope: ${written} leaves nothing to read: every part it chooses is also left out with ~`,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const scopeProblemSentence = (kind: ScopeProblem["kind"], written: string, ui: UiLanguage): string => TEXT[ui][kind](written);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ProseDocument, ScopedSentence, ScopeSelector, Sentence, TableCell } from "./plugin.ts";
|
|
2
|
+
import { inScope, scopesOf, type ScopeRegions } from "./text-scope.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What a rule limited to some parts of a document (scope:) reads from: the body's sentences, the sentences of the headings
|
|
6
|
+
* and of the quotations (which the body leaves out), the table cells, and where the list items and quotations are.
|
|
7
|
+
*/
|
|
8
|
+
type ScopeSources = {
|
|
9
|
+
readonly body: readonly Sentence[];
|
|
10
|
+
readonly headings: readonly Sentence[];
|
|
11
|
+
readonly quoted: readonly Sentence[];
|
|
12
|
+
readonly cells: readonly TableCell[];
|
|
13
|
+
readonly regions: ScopeRegions;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** A table cell read as one sentence: a cell has no sentence ending to split at. */
|
|
17
|
+
const cellSentence = (cell: TableCell): Sentence => ({
|
|
18
|
+
span: { start: cell.start, end: cell.end },
|
|
19
|
+
text: cell.text,
|
|
20
|
+
...(cell.tokens === undefined ? {} : { tokens: cell.tokens }),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
/** Every sentence a scope can choose from, in the order of the document, with the parts it is in. */
|
|
24
|
+
export const scopedSentences = (sources: ScopeSources): ScopedSentence[] =>
|
|
25
|
+
[
|
|
26
|
+
...sources.body.map((sentence) => ({ sentence, scopes: scopesOf(sentence.span, sources.regions) })),
|
|
27
|
+
...sources.quoted.map((sentence) => ({ sentence, scopes: scopesOf(sentence.span, sources.regions) })),
|
|
28
|
+
...sources.headings.map((sentence) => ({ sentence, scopes: scopesOf(sentence.span, sources.regions, "heading") })),
|
|
29
|
+
...sources.cells.map((cell) => ({ sentence: cellSentence(cell), scopes: scopesOf(cell, sources.regions, "table") })),
|
|
30
|
+
].toSorted((left, right) => left.sentence.span.start - right.sentence.span.start);
|
|
31
|
+
|
|
32
|
+
/** A document built without its scoped sentences (a test's, a plugin's): the body alone, list items and reply quotes found in it. */
|
|
33
|
+
const bodyOnly = (doc: ProseDocument): ScopedSentence[] =>
|
|
34
|
+
scopedSentences({ body: doc.sentences, headings: [], quoted: [], cells: [], regions: { list: doc.listSpans, quote: doc.replyQuotes ?? [] } });
|
|
35
|
+
|
|
36
|
+
/** Every sentence of the document with the parts it is in. */
|
|
37
|
+
export const scopedSentencesOf = (doc: ProseDocument): readonly ScopedSentence[] => doc.scopedSentences?.() ?? bodyOnly(doc);
|
|
38
|
+
|
|
39
|
+
/** The sentences a rule with this scope reads. Without a scope, the body's sentences, as every rule has always read. */
|
|
40
|
+
export const sentencesInScope = (doc: ProseDocument, scope: ScopeSelector | undefined): readonly Sentence[] =>
|
|
41
|
+
scope === undefined ? doc.sentences : scopedSentencesOf(doc).flatMap((scoped) => (inScope(scope, scoped.scopes) ? [scoped.sentence] : []));
|
package/src/setting-problems.ts
CHANGED
|
@@ -4,6 +4,8 @@ import type { UiLanguage } from "./ui.ts";
|
|
|
4
4
|
import { styleProblems } from "./config/style.ts";
|
|
5
5
|
import { loadStyles } from "./style-load.ts";
|
|
6
6
|
import { customRuleProblems } from "./custom/problems.ts";
|
|
7
|
+
import { preferProblems } from "./config/prefer-problems.ts";
|
|
8
|
+
import { allowProblems } from "./config/allow-problems.ts";
|
|
7
9
|
import { extensionProblems } from "./extension/problem-text.ts";
|
|
8
10
|
import { GENRES } from "./genre.ts";
|
|
9
11
|
import { unknownGenres, writtenGenres } from "./genre-check.ts";
|
|
@@ -28,5 +30,7 @@ export const settingProblems = (command: string, genreFlag: string | undefined,
|
|
|
28
30
|
...profileProblems(command, config, text),
|
|
29
31
|
...styleProblems(config, [...loadStyles(), ...(config.extensions?.styles ?? [])], ui),
|
|
30
32
|
...customRuleProblems(config, ui),
|
|
33
|
+
...preferProblems(config, ui),
|
|
34
|
+
...allowProblems(config, ui),
|
|
31
35
|
...extensionProblems(config, ui),
|
|
32
36
|
];
|
package/src/spelling.ts
CHANGED
|
@@ -110,10 +110,10 @@ export const wordsToCheck = (text: string, minLength: number, maxLength: number)
|
|
|
110
110
|
.map((match) => ({ offset: match.index, word: match[0] }));
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
-
/** 頭の字を強調(**G**lobally)や角括弧(引用を変えた [e]xpressions)で分けた語の残りの、直前の形。 */
|
|
114
|
-
const SPLIT_HEAD = /(?:\p{L}[*_~]
|
|
115
|
-
/**
|
|
116
|
-
const SPLIT_LOOKBACK =
|
|
113
|
+
/** 頭の字を強調(**G**lobally、<strong>E</strong>dition)や角括弧(引用を変えた [e]xpressions)で分けた語の残りの、直前の形。 */
|
|
114
|
+
const SPLIT_HEAD = /(?:\p{L}(?:[*_~]+|<\/[a-z]+>)|\[\p{L}\])$/u;
|
|
115
|
+
/** 直前を見る字の数。強調の印か閉じのタグ(</strong>)と頭の字が収まればよい。 */
|
|
116
|
+
const SPLIT_LOOKBACK = 16;
|
|
117
117
|
|
|
118
118
|
/** source(Markdown のままの文書)の offset から始まる語が、頭の字を分けた語の残りか。 */
|
|
119
119
|
export const isSplitWord = (source: string, offset: number): boolean => SPLIT_HEAD.test(source.slice(Math.max(0, offset - SPLIT_LOOKBACK), offset));
|
package/src/stet-body.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { RULE_ID } from "./extension/plugin-name.ts";
|
|
2
|
+
|
|
3
|
+
/** What one stet comment says: the rules it names, the matched texts some of them are limited to, and why. */
|
|
4
|
+
export type StetBody = {
|
|
5
|
+
/** Every rule named, once, whether bare or with a matched text. */
|
|
6
|
+
readonly rules: readonly string[];
|
|
7
|
+
/** A rule named only as `rule["text"]`: the texts its silenced findings must have matched. A bare name lifts the limit. */
|
|
8
|
+
readonly matching: Readonly<Record<string, readonly string[]>>;
|
|
9
|
+
readonly reason: string | undefined;
|
|
10
|
+
/** Entries in the rule list that are not a rule name nor `rule["text"]`, as written. */
|
|
11
|
+
readonly malformed: readonly string[];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** 理由は em dash のあと。書かなくてもよいが、書かないと chaff suppressions に並ぶ。 */
|
|
15
|
+
const REASON_MARK = "—";
|
|
16
|
+
|
|
17
|
+
/** `["…"]` after a rule name. No nested quantifier: a long comment must not make the scan backtrack. */
|
|
18
|
+
const QUOTED = /\["[^"]*"\]/gu;
|
|
19
|
+
|
|
20
|
+
type Range = { readonly start: number; readonly end: number };
|
|
21
|
+
|
|
22
|
+
const quotedRanges = (body: string): Range[] => [...body.matchAll(QUOTED)].map((match) => ({ start: match.index, end: match.index + match[0].length }));
|
|
23
|
+
|
|
24
|
+
const isQuoted = (at: number, quoted: readonly Range[]): boolean => quoted.some((range) => at >= range.start && at < range.end);
|
|
25
|
+
|
|
26
|
+
/** Every index of `mark` in `body` outside a `["…"]`: a matched text may hold a comma or a dash. */
|
|
27
|
+
const marksOutside = (body: string, mark: string, quoted: readonly Range[]): number[] =>
|
|
28
|
+
Array.from({ length: body.length }, (_unused, index) => index).filter((at) => body[at] === mark && !isQuoted(at, quoted));
|
|
29
|
+
|
|
30
|
+
const splitAt = (text: string, cuts: readonly number[]): string[] =>
|
|
31
|
+
[...cuts, text.length].map((cut, index) => text.slice(index === 0 ? 0 : (cuts[index - 1] ?? 0) + 1, cut));
|
|
32
|
+
|
|
33
|
+
const reasonOf = (raw: string): string | undefined => {
|
|
34
|
+
// 残っているのはコメント終端の "--" だけ。正規表現で任意個の "-" を剥がすと、
|
|
35
|
+
// 長いダッシュ列でバックトラックする(そして著者が書いたダッシュまで消す)。
|
|
36
|
+
const tail = (raw.endsWith("--") ? raw.slice(0, -2) : raw).trim();
|
|
37
|
+
return tail.length === 0 ? undefined : tail;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type Entry = { readonly rule: string; readonly text: string | undefined } | { readonly malformed: string };
|
|
41
|
+
|
|
42
|
+
const entryOf = (piece: string): Entry => {
|
|
43
|
+
if (RULE_ID.test(piece)) return { rule: piece, text: undefined };
|
|
44
|
+
const open = piece.indexOf('["');
|
|
45
|
+
const rule = open === -1 ? "" : piece.slice(0, open);
|
|
46
|
+
const quoted = open === -1 ? "" : piece.slice(open);
|
|
47
|
+
return RULE_ID.test(rule) && quoted.endsWith('"]') && quoted.length >= 4 && !quoted.slice(2, -2).includes('"')
|
|
48
|
+
? { rule, text: quoted.slice(2, -2) }
|
|
49
|
+
: { malformed: piece };
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const matchingOf = (entries: readonly Entry[]): Record<string, string[]> => {
|
|
53
|
+
const named = entries.flatMap((entry) => ("rule" in entry ? [entry] : []));
|
|
54
|
+
const bare = new Set(named.filter((entry) => entry.text === undefined).map((entry) => entry.rule));
|
|
55
|
+
const limited = named.flatMap((entry) => (entry.text === undefined || bare.has(entry.rule) ? [] : [{ rule: entry.rule, text: entry.text }]));
|
|
56
|
+
return limited.reduce<Record<string, string[]>>((all, entry) => ({ ...all, [entry.rule]: [...(all[entry.rule] ?? []), entry.text] }), {});
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/** Reads the part of a stet comment after its colon: `rule-a, rule-b["text"] — reason`. */
|
|
60
|
+
export const readStetBody = (body: string): StetBody => {
|
|
61
|
+
const quoted = quotedRanges(body);
|
|
62
|
+
const at = marksOutside(body, REASON_MARK, quoted)[0];
|
|
63
|
+
const head = at === undefined ? body : body.slice(0, at);
|
|
64
|
+
const entries = splitAt(head, marksOutside(head, ",", quoted))
|
|
65
|
+
.map((piece) => piece.trim())
|
|
66
|
+
.filter((piece) => piece.length > 0)
|
|
67
|
+
.map(entryOf);
|
|
68
|
+
return {
|
|
69
|
+
rules: [...new Set(entries.flatMap((entry) => ("rule" in entry ? [entry.rule] : [])))],
|
|
70
|
+
matching: matchingOf(entries),
|
|
71
|
+
reason: at === undefined ? undefined : reasonOf(body.slice(at + REASON_MARK.length)),
|
|
72
|
+
malformed: entries.flatMap((entry) => ("malformed" in entry ? [entry.malformed] : [])),
|
|
73
|
+
};
|
|
74
|
+
};
|
package/src/stet.ts
CHANGED
|
@@ -1,16 +1,29 @@
|
|
|
1
|
-
import type { Finding, Span } from "./plugin.ts";
|
|
2
|
-
import { RULE_ID } from "./extension/plugin-name.ts";
|
|
1
|
+
import type { Finding, RuleDefinition, Span } from "./plugin.ts";
|
|
3
2
|
import { stetBlockEnd } from "./stet-block.ts";
|
|
3
|
+
import { readStetBody } from "./stet-body.ts";
|
|
4
4
|
import { lineStarts, placeOf } from "./position.ts";
|
|
5
5
|
import { parse } from "./markdown-read.ts";
|
|
6
6
|
|
|
7
7
|
export type Suppression = {
|
|
8
8
|
readonly rules: readonly string[];
|
|
9
|
+
/** A rule named only as `rule["text"]`: the matched texts its silenced findings must have. */
|
|
10
|
+
readonly matching: Readonly<Record<string, readonly string[]>>;
|
|
9
11
|
readonly reason: string | undefined;
|
|
10
12
|
readonly line: number;
|
|
11
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* The last line it covers. `stet` (scope next): the end of the block right below the comment. `stet-begin` (scope range):
|
|
15
|
+
* the line of its `stet-end`. Other scopes: the comment's last line.
|
|
16
|
+
*/
|
|
12
17
|
readonly blockEnd: number;
|
|
13
|
-
readonly scope: "next" | "section" | "file";
|
|
18
|
+
readonly scope: "next" | "section" | "file" | "range";
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** A stet that cannot do what it says, listed by `chaff suppressions` with the stets that give no reason. */
|
|
22
|
+
export type StetProblem = {
|
|
23
|
+
readonly kind: "unclosed" | "stray-end" | "no-rules" | "unknown-rule" | "no-matched-text";
|
|
24
|
+
readonly line: number;
|
|
25
|
+
/** The rule entry as written, for unknown-rule and no-matched-text. */
|
|
26
|
+
readonly rule?: string;
|
|
14
27
|
};
|
|
15
28
|
|
|
16
29
|
/**
|
|
@@ -22,28 +35,12 @@ export type Suppression = {
|
|
|
22
35
|
* 長い HTML コメントを 1 つ置かれるだけで検査が止まる。ここは ">" を含まない塊として
|
|
23
36
|
* 取り出し、あとはコードで割る。
|
|
24
37
|
*/
|
|
25
|
-
const PATTERN = /<!--\s*(stet|stet-section|stet-file)\s*:([^>]*)-->/gu;
|
|
26
|
-
|
|
27
|
-
const SCOPE: Readonly<Record<string, Suppression["scope"]>> = { stet: "next", "stet-section": "section", "stet-file": "file" };
|
|
38
|
+
const PATTERN = /<!--\s*(stet|stet-section|stet-file|stet-begin)\s*:([^>]*)-->/gu;
|
|
28
39
|
|
|
29
|
-
/**
|
|
30
|
-
const
|
|
40
|
+
/** A range's close carries nothing: what it closes and why are on its stet-begin. */
|
|
41
|
+
const END_PATTERN = /<!--\s*stet-end\s*-->/gu;
|
|
31
42
|
|
|
32
|
-
const
|
|
33
|
-
const at = body.indexOf(REASON_MARK);
|
|
34
|
-
const head = at === -1 ? body : body.slice(0, at);
|
|
35
|
-
// 残っているのはコメント終端の "--" だけ。正規表現で任意個の "-" を剥がすと、
|
|
36
|
-
// 長いダッシュ列でバックトラックする(そして著者が書いたダッシュまで消す)。
|
|
37
|
-
const raw = at === -1 ? "" : body.slice(at + REASON_MARK.length);
|
|
38
|
-
const tail = (raw.endsWith("--") ? raw.slice(0, -2) : raw).trim();
|
|
39
|
-
return {
|
|
40
|
-
rules: head
|
|
41
|
-
.split(",")
|
|
42
|
-
.map((rule) => rule.trim())
|
|
43
|
-
.filter((rule) => RULE_ID.test(rule)),
|
|
44
|
-
reason: tail.length === 0 ? undefined : tail,
|
|
45
|
-
};
|
|
46
|
-
};
|
|
43
|
+
const SCOPE: Readonly<Record<string, Suppression["scope"]>> = { stet: "next", "stet-section": "section", "stet-file": "file", "stet-begin": "range" };
|
|
47
44
|
|
|
48
45
|
const scopeOf = (match: RegExpMatchArray): Suppression["scope"] => SCOPE[match[1] ?? "stet"] ?? "next";
|
|
49
46
|
|
|
@@ -53,30 +50,109 @@ const lineFinder = (source: string): ((offset: number) => number) => {
|
|
|
53
50
|
return (offset) => placeOf(starts, offset).line;
|
|
54
51
|
};
|
|
55
52
|
|
|
56
|
-
|
|
53
|
+
type Read = Suppression & { readonly offset: number; readonly malformed: readonly string[] };
|
|
54
|
+
|
|
55
|
+
const readAll = (source: string, lineAt: (offset: number) => number): Read[] => {
|
|
57
56
|
const matches = [...source.matchAll(PATTERN)];
|
|
58
|
-
const lineAt = lineFinder(source);
|
|
59
57
|
// Only a plain stet needs the tree, to find the block it stops at; a stet-file alone does not pay for a parse.
|
|
60
58
|
const root = matches.some((match) => scopeOf(match) === "next") ? parse(source) : undefined;
|
|
61
59
|
return matches.map((match) => {
|
|
62
60
|
const comment = { start: match.index, end: match.index + match[0].length };
|
|
63
61
|
const scope = scopeOf(match);
|
|
64
62
|
return {
|
|
65
|
-
...
|
|
63
|
+
...readStetBody(match[2] ?? ""),
|
|
66
64
|
line: lineAt(match.index),
|
|
67
65
|
blockEnd: root !== undefined && scope === "next" ? stetBlockEnd(source, root, comment, lineAt) : lineAt(comment.end),
|
|
68
66
|
scope,
|
|
67
|
+
offset: match.index,
|
|
69
68
|
};
|
|
70
69
|
});
|
|
71
70
|
};
|
|
72
71
|
|
|
73
|
-
|
|
72
|
+
type Paired = { readonly closed: ReadonlyMap<Read, number>; readonly problems: readonly StetProblem[] };
|
|
73
|
+
|
|
74
|
+
/** Each stet-end closes the nearest open stet-begin above it, so ranges nest. What is left open, or closes nothing, is a problem. */
|
|
75
|
+
const pairRanges = (reads: readonly Read[], source: string, lineAt: (offset: number) => number): Paired => {
|
|
76
|
+
const ends = [...source.matchAll(END_PATTERN)].map((match) => ({ offset: match.index, line: lineAt(match.index) }));
|
|
77
|
+
const events = [...reads.filter((read) => read.scope === "range").map((read) => ({ offset: read.offset, begin: read })), ...ends].toSorted(
|
|
78
|
+
(left, right) => left.offset - right.offset,
|
|
79
|
+
);
|
|
80
|
+
// A stack, not a fold: a document can hold thousands of ranges, and copying the state per comment is quadratic.
|
|
81
|
+
const open: Read[] = [];
|
|
82
|
+
const closed = new Map<Read, number>();
|
|
83
|
+
const stray: number[] = [];
|
|
84
|
+
events.forEach((event) => {
|
|
85
|
+
if ("begin" in event) open.push(event.begin);
|
|
86
|
+
else {
|
|
87
|
+
const begin = open.pop();
|
|
88
|
+
if (begin === undefined) stray.push(event.line);
|
|
89
|
+
else closed.set(begin, event.line);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
const unclosed = open.map((read): StetProblem => ({ kind: "unclosed", line: read.line }));
|
|
93
|
+
return { closed, problems: [...unclosed, ...stray.map((line): StetProblem => ({ kind: "stray-end", line }))] };
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/** What chaff knows of each rule a stet may name: whether its findings carry the text they matched (`{matched}`). */
|
|
97
|
+
export type KnownRules = ReadonlyMap<string, { readonly showsMatched: boolean }>;
|
|
98
|
+
|
|
99
|
+
const showsMatched = (rule: Pick<RuleDefinition, "message" | "messages">): boolean =>
|
|
100
|
+
[rule.message, ...Object.values(rule.messages)].some((message) => Object.values(message).some((text) => text.includes("{matched}")));
|
|
101
|
+
|
|
102
|
+
export const knownRulesOf = (rules: readonly Pick<RuleDefinition, "id" | "message" | "messages">[]): KnownRules =>
|
|
103
|
+
new Map(rules.map((rule) => [rule.id, { showsMatched: showsMatched(rule) }]));
|
|
104
|
+
|
|
105
|
+
const ruleProblems = (read: Read, known: KnownRules | undefined): StetProblem[] => {
|
|
106
|
+
const malformed = read.malformed.map((rule): StetProblem => ({ kind: "unknown-rule", line: read.line, rule }));
|
|
107
|
+
const none: StetProblem[] = read.rules.length === 0 && read.malformed.length === 0 ? [{ kind: "no-rules", line: read.line }] : [];
|
|
108
|
+
if (known === undefined) return [...none, ...malformed];
|
|
109
|
+
const unknown = read.rules.filter((rule) => !known.has(rule)).map((rule): StetProblem => ({ kind: "unknown-rule", line: read.line, rule }));
|
|
110
|
+
const blind = Object.keys(read.matching)
|
|
111
|
+
.filter((rule) => known.get(rule)?.showsMatched === false)
|
|
112
|
+
.map((rule): StetProblem => ({ kind: "no-matched-text", line: read.line, rule }));
|
|
113
|
+
return [...none, ...malformed, ...unknown, ...blind];
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const toSuppression = (read: Read, blockEnd: number): Suppression => ({
|
|
117
|
+
rules: read.rules,
|
|
118
|
+
matching: read.matching,
|
|
119
|
+
reason: read.reason,
|
|
120
|
+
line: read.line,
|
|
121
|
+
blockEnd,
|
|
122
|
+
scope: read.scope,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
export type Parsed = { readonly suppressions: readonly Suppression[]; readonly problems: readonly StetProblem[] };
|
|
126
|
+
|
|
127
|
+
/** Every stet in the text, and what is wrong with any of them. A stet-begin with no stet-end silences nothing. */
|
|
128
|
+
export const readSuppressions = (source: string, known?: KnownRules): Parsed => {
|
|
129
|
+
const lineAt = lineFinder(source);
|
|
130
|
+
const reads = readAll(source, lineAt);
|
|
131
|
+
const paired = pairRanges(reads, source, lineAt);
|
|
132
|
+
const usable = reads.flatMap((read) => {
|
|
133
|
+
if (read.scope !== "range") return [toSuppression(read, read.blockEnd)];
|
|
134
|
+
const end = paired.closed.get(read);
|
|
135
|
+
return end === undefined ? [] : [toSuppression(read, end)];
|
|
136
|
+
});
|
|
137
|
+
const problems = [...paired.problems, ...reads.flatMap((read) => ruleProblems(read, known))].toSorted((left, right) => left.line - right.line);
|
|
138
|
+
return { suppressions: usable, problems };
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export const parseSuppressions = (source: string): Suppression[] => [...readSuppressions(source).suppressions];
|
|
142
|
+
|
|
143
|
+
/** A finding's matched text is its `matched` value: what a rule shows as {matched} in its message. */
|
|
144
|
+
const matchesText = (suppression: Suppression, finding: Finding): boolean => {
|
|
145
|
+
const texts = suppression.matching[finding.rule];
|
|
146
|
+
return texts === undefined || texts.includes(String(finding.values["matched"] ?? ""));
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/** stet が効く範囲。next は直後の塊(段落・見出し・箇条書き・表)の終わりまで、range は stet-end まで、section は次の見出しまで、file は全体。 */
|
|
74
150
|
const covers = (suppression: Suppression, finding: Finding, sectionEnds: readonly number[], lastLine: number): boolean => {
|
|
75
|
-
if (!suppression.rules.includes(finding.rule)) return false;
|
|
151
|
+
if (!suppression.rules.includes(finding.rule) || !matchesText(suppression, finding)) return false;
|
|
76
152
|
if (suppression.scope === "file") return true;
|
|
77
153
|
// 抑制は「この先の箇所」に対して書く。遡って効くと、意図せず黙る範囲が広がる。
|
|
78
154
|
if (finding.line < suppression.line) return false;
|
|
79
|
-
if (suppression.scope === "next") return finding.line <= suppression.blockEnd;
|
|
155
|
+
if (suppression.scope === "next" || suppression.scope === "range") return finding.line <= suppression.blockEnd;
|
|
80
156
|
return finding.line <= (sectionEnds.find((line) => line > suppression.line) ?? lastLine);
|
|
81
157
|
};
|
|
82
158
|
|
|
@@ -88,10 +164,13 @@ export type Applied = {
|
|
|
88
164
|
readonly unusedReasonless: readonly Suppression[];
|
|
89
165
|
/** Every rule a stet in the document names, whether or not it silenced anything. */
|
|
90
166
|
readonly named: readonly string[];
|
|
167
|
+
/** Every stet-begin … stet-end in the document, for `chaff suppressions` to list with its lines and reason. */
|
|
168
|
+
readonly ranges: readonly Suppression[];
|
|
169
|
+
readonly problems: readonly StetProblem[];
|
|
91
170
|
};
|
|
92
171
|
|
|
93
|
-
export const applySuppressions = (source: string, findings: readonly Finding[], sections: readonly Span[]): Applied => {
|
|
94
|
-
const suppressions =
|
|
172
|
+
export const applySuppressions = (source: string, findings: readonly Finding[], sections: readonly Span[], known?: KnownRules): Applied => {
|
|
173
|
+
const { suppressions, problems } = readSuppressions(source, known);
|
|
95
174
|
const lineAt = lineFinder(source);
|
|
96
175
|
const sectionEnds = sections.map((span) => lineAt(span.end));
|
|
97
176
|
const lastLine = source.split("\n").length;
|
|
@@ -101,5 +180,7 @@ export const applySuppressions = (source: string, findings: readonly Finding[],
|
|
|
101
180
|
suppressed: matched.flatMap((entry) => (entry.suppression === undefined ? [] : [{ finding: entry.finding, suppression: entry.suppression }])),
|
|
102
181
|
unusedReasonless: suppressions.filter((entry) => entry.reason === undefined),
|
|
103
182
|
named: [...new Set(suppressions.flatMap((entry) => entry.rules))],
|
|
183
|
+
ranges: suppressions.filter((entry) => entry.scope === "range"),
|
|
184
|
+
problems,
|
|
104
185
|
};
|
|
105
186
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Line } from "./lines.ts";
|
|
2
|
+
|
|
3
|
+
// The lines of a GitHub alert (`> [!NOTE]`, `> [!IMPORTANT]`): an editorial note set apart from the text around it.
|
|
4
|
+
// Pure: reads the document's lines only.
|
|
5
|
+
|
|
6
|
+
const QUOTED = /^[ \t]*>/u;
|
|
7
|
+
const ALERT_OPENER = /^[ \t]*>[ \t]*\[![A-Za-z]+\][ \t]*$/u;
|
|
8
|
+
|
|
9
|
+
/** The numbers of the lines inside an alert, its opening `> [!NOTE]` line included. */
|
|
10
|
+
export const alertLineNumbers = (lines: readonly Line[]): Set<number> => {
|
|
11
|
+
const numbers = new Set<number>();
|
|
12
|
+
const open = { alert: false };
|
|
13
|
+
lines.forEach((line) => {
|
|
14
|
+
if (!QUOTED.test(line.text)) open.alert = false;
|
|
15
|
+
else if (ALERT_OPENER.test(line.text)) open.alert = true;
|
|
16
|
+
if (open.alert) numbers.add(line.number);
|
|
17
|
+
});
|
|
18
|
+
return numbers;
|
|
19
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// The last row of an if-then table that catches every case the rows above leave (| none of the above apply | | 10 percent |):
|
|
2
|
+
// the conditions it leaves blank do not apply to it. Pure; the caller passes the catch-all words.
|
|
3
|
+
|
|
4
|
+
const EMPHASIS = /[*_]/gu;
|
|
5
|
+
const LATIN_LETTER = /\p{Script=Latin}/u;
|
|
6
|
+
|
|
7
|
+
/** Whether a row's label opens with a catch-all word (none of the above, otherwise, 上記以外) standing as a word of its own. */
|
|
8
|
+
export const isCatchAllLabel = (cell: string | undefined, catchAllWords: readonly string[]): boolean => {
|
|
9
|
+
const label = (cell ?? "").replace(EMPHASIS, "").trim().toLowerCase();
|
|
10
|
+
return catchAllWords.some((word) => {
|
|
11
|
+
const target = word.toLowerCase();
|
|
12
|
+
return target !== "" && label.startsWith(target) && !LATIN_LETTER.test(label.charAt(target.length));
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Whether the blank at `column` is a condition a catch-all row leaves out: the row's first cell opens with a catch-all word
|
|
18
|
+
* and a later cell is filled, its outcome. A blank in the outcome itself, the row's last filled place, is still a gap. Cells
|
|
19
|
+
* are undefined when blank.
|
|
20
|
+
*/
|
|
21
|
+
export const isCatchAllRowGap = (cells: readonly (string | undefined)[], column: number, catchAllWords: readonly string[]): boolean =>
|
|
22
|
+
cells[column] === undefined && cells.slice(column + 1).some((cell) => cell !== undefined) && isCatchAllLabel(cells[0], catchAllWords);
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// change-rate-mismatch: the earlier value written without its noun ("1,300 companies, up 20% from 1,000", "Visits reached
|
|
2
|
+
// 186,400, up 12% from 152,800 the year before"). The shape "<value>, <direction> <rate> <from> <value>" ties the two
|
|
3
|
+
// numbers to one quantity, so the bare one is read in the other's unit. Pure; the detector supplies the parts.
|
|
4
|
+
import type { Span } from "../plugin.ts";
|
|
5
|
+
import type { BaseMark, Direction, Figure, Rate } from "./change-rate.ts";
|
|
6
|
+
|
|
7
|
+
export type TieText = {
|
|
8
|
+
readonly source: string;
|
|
9
|
+
readonly rates: readonly Rate[];
|
|
10
|
+
readonly directions: readonly Direction[];
|
|
11
|
+
/** Words that mark the earlier value ("from"); only those standing before the value are read. */
|
|
12
|
+
readonly marks: readonly BaseMark[];
|
|
13
|
+
/** Numbers counted with the word after them ("1,300 companies"), whose value is the number as written. */
|
|
14
|
+
readonly counted: readonly Figure[];
|
|
15
|
+
/** Spans of the tree's quantities ($1,000, 20%): a number inside one has a unit of its own. */
|
|
16
|
+
readonly quantities: readonly Span[];
|
|
17
|
+
/** The marks and words of a percentage (%, percent), which the tree leaves outside the rate's span. */
|
|
18
|
+
readonly percentWords: readonly string[];
|
|
19
|
+
/** Words of magnitude (million): a number followed by one is not its written value. */
|
|
20
|
+
readonly multipliers: readonly string[];
|
|
21
|
+
/** Whether the word starting at offset is a noun; undefined when the tagger did not say. */
|
|
22
|
+
readonly isNounAt: (offset: number) => boolean | undefined;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type Bare = Span & { readonly value: number; readonly step: number };
|
|
26
|
+
|
|
27
|
+
const NUMBER = String.raw`(\d{1,3}(?:,\d{3})+|\d+)(?:\.(\d+))?`;
|
|
28
|
+
const NUMBER_AT_END = new RegExp(String.raw`(?<![\w.,$€£¥-])${NUMBER}$`, "u");
|
|
29
|
+
const NUMBER_AT_START = new RegExp(String.raw`^\s+${NUMBER}(?![\d%]|[.,]\d)`, "u");
|
|
30
|
+
const COMMA_AT_END = /,\s+$/u;
|
|
31
|
+
const SPACE = /^\s+$/u;
|
|
32
|
+
const WORD_AFTER = /^(\s+)([A-Za-z]+)/u;
|
|
33
|
+
const ONE_WORD = /^\s+[A-Za-z]+$/u;
|
|
34
|
+
const YEAR = /^(?:1[89]|2[01])\d{2}$/u;
|
|
35
|
+
const DECIMAL_BASE = 10;
|
|
36
|
+
/** How far from the rate's words a value is looked for: a number and one word, then the comma; or space and a number. */
|
|
37
|
+
const CURRENT_WINDOW = 64;
|
|
38
|
+
|
|
39
|
+
const bareOf = (span: Span, digits: string, decimals: string): Bare => {
|
|
40
|
+
const written = [digits.replaceAll(",", ""), decimals].filter((part) => part !== "").join(".");
|
|
41
|
+
return { ...span, value: Number(written), step: DECIMAL_BASE ** -decimals.length };
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** A number written plainly: not a year, no word of magnitude after it, not inside one of the tree's quantities. */
|
|
45
|
+
const isPlain = (text: TieText, bare: Bare): boolean => {
|
|
46
|
+
const word = WORD_AFTER.exec(text.source.slice(bare.end))?.[2]?.toLowerCase() ?? "";
|
|
47
|
+
const inQuantity = text.quantities.some((span) => span.start < bare.end && bare.start < span.end);
|
|
48
|
+
return !inQuantity && !text.multipliers.includes(word) && !YEAR.test(text.source.slice(bare.start, bare.end));
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/** The number right after the mark of the earlier value ("from 1,000"). */
|
|
52
|
+
const baseAfter = (text: TieText, mark: BaseMark): Bare | undefined => {
|
|
53
|
+
const match = NUMBER_AT_START.exec(text.source.slice(mark.end, mark.end + CURRENT_WINDOW));
|
|
54
|
+
if (match === null) return undefined;
|
|
55
|
+
const end = mark.end + match[0].length;
|
|
56
|
+
const start = end - match[0].trimStart().length;
|
|
57
|
+
const bare = bareOf({ start, end }, match[1] ?? "", match[2] ?? "");
|
|
58
|
+
return isPlain(text, bare) ? bare : undefined;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/** The current value right before ", <direction>": a counted figure ("1,300 companies") or a bare number ("186,400"). */
|
|
62
|
+
const currentBefore = (text: TieText, direction: Direction): Figure | Bare | undefined => {
|
|
63
|
+
const from = Math.max(0, direction.start - CURRENT_WINDOW);
|
|
64
|
+
const comma = COMMA_AT_END.exec(text.source.slice(from, direction.start));
|
|
65
|
+
if (comma === null) return undefined;
|
|
66
|
+
const end = from + comma.index;
|
|
67
|
+
const counted = text.counted.find((figure) => figure.end < end && end - figure.end <= CURRENT_WINDOW && ONE_WORD.test(text.source.slice(figure.end, end)));
|
|
68
|
+
if (counted !== undefined) return counted;
|
|
69
|
+
const match = NUMBER_AT_END.exec(text.source.slice(from, end));
|
|
70
|
+
if (match === null || match.index === 0) return undefined;
|
|
71
|
+
const bare = bareOf({ start: from + match.index, end }, match[1] ?? "", match[2] ?? "");
|
|
72
|
+
return isPlain(text, bare) ? bare : undefined;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/** Only space, after the rate's mark of percentage, between the rate and the word after it ("20% from"). */
|
|
76
|
+
const followsRate = (text: TieText, rate: Rate, word: Span): boolean => {
|
|
77
|
+
const gap = text.source.slice(rate.end, word.start).trimStart();
|
|
78
|
+
const unit = text.percentWords.find((percent) => gap.startsWith(percent)) ?? "";
|
|
79
|
+
return SPACE.test(gap.slice(unit.length));
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const isFigure = (value: Figure | Bare): value is Figure => "unit" in value;
|
|
83
|
+
|
|
84
|
+
/** A number already counted with a noun of its own ("from 1,000 dollars"), not with a word the tagger calls no noun ("the"). */
|
|
85
|
+
const countedWithNoun = (text: TieText, bare: Bare): boolean => {
|
|
86
|
+
const counted = text.counted.find((figure) => figure.start === bare.start);
|
|
87
|
+
const word = WORD_AFTER.exec(text.source.slice(bare.end));
|
|
88
|
+
return counted !== undefined && text.isNounAt(bare.end + (word?.[1]?.length ?? 0)) !== false;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The figures one rate ties: the bare earlier value in the counted current value's unit, or both bare values in a unit of
|
|
93
|
+
* their own. An earlier value counted with a noun of its own is left as it is.
|
|
94
|
+
*/
|
|
95
|
+
const tieAt = (text: TieText, rate: Rate): Figure[] => {
|
|
96
|
+
const direction = text.directions.find((word) => word.end <= rate.start && SPACE.test(text.source.slice(word.end, rate.start)));
|
|
97
|
+
const mark = text.marks.find((word) => word.position === "before" && rate.end <= word.start && followsRate(text, rate, word));
|
|
98
|
+
const base = mark === undefined ? undefined : baseAfter(text, mark);
|
|
99
|
+
const current = direction === undefined ? undefined : currentBefore(text, direction);
|
|
100
|
+
if (base === undefined || current === undefined || countedWithNoun(text, base)) return [];
|
|
101
|
+
if (isFigure(current)) return [{ ...base, unit: current.unit }];
|
|
102
|
+
const unit = `tied|${String(rate.start)}`;
|
|
103
|
+
return [
|
|
104
|
+
{ ...current, unit },
|
|
105
|
+
{ ...base, unit },
|
|
106
|
+
];
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/** The figures, with each tied value added or put in place of the one read at the same place. */
|
|
110
|
+
export const withTiedFigures = (text: TieText, figures: readonly Figure[]): Figure[] => {
|
|
111
|
+
const tied = text.rates.flatMap((rate) => tieAt(text, rate));
|
|
112
|
+
return [...figures.filter((figure) => !tied.some((one) => one.start === figure.start)), ...tied];
|
|
113
|
+
};
|