chaffjs 0.20.0 → 0.22.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 +7 -5
- package/dist/api.d.ts +16 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js.map +1 -1
- package/dist/cli-text.d.ts +2 -0
- package/dist/cli-text.d.ts.map +1 -1
- package/dist/cli-text.js +18 -5
- package/dist/cli-text.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +8 -11
- package/dist/cli.js.map +1 -1
- package/dist/command-help.d.ts +7 -0
- package/dist/command-help.d.ts.map +1 -0
- package/dist/command-help.js +18 -0
- package/dist/command-help.js.map +1 -0
- package/dist/commands/eval.js +2 -2
- package/dist/commands/eval.js.map +1 -1
- package/dist/commands/fix-plan.d.ts.map +1 -1
- package/dist/commands/fix-plan.js +11 -1
- package/dist/commands/fix-plan.js.map +1 -1
- package/dist/commands/help.d.ts +4 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +7 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/init-command.d.ts +4 -0
- package/dist/commands/init-command.d.ts.map +1 -0
- package/dist/commands/init-command.js +15 -0
- package/dist/commands/init-command.js.map +1 -0
- package/dist/commands/plugin-init.d.ts +20 -0
- package/dist/commands/plugin-init.d.ts.map +1 -0
- package/dist/commands/plugin-init.js +129 -0
- package/dist/commands/plugin-init.js.map +1 -0
- package/dist/commands/plugin-test.d.ts +11 -0
- package/dist/commands/plugin-test.d.ts.map +1 -0
- package/dist/commands/plugin-test.js +81 -0
- package/dist/commands/plugin-test.js.map +1 -0
- package/dist/config/load.d.ts +2 -0
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +1 -0
- package/dist/config/load.js.map +1 -1
- package/dist/config/option-problems.js +2 -2
- package/dist/config/option-problems.js.map +1 -1
- package/dist/config/rule-problems.js +2 -2
- package/dist/config/rule-problems.js.map +1 -1
- package/dist/custom/checked.d.ts +9 -0
- package/dist/custom/checked.d.ts.map +1 -0
- package/dist/custom/checked.js +3 -0
- package/dist/custom/checked.js.map +1 -0
- package/dist/custom/dsl-fields.d.ts +27 -0
- package/dist/custom/dsl-fields.d.ts.map +1 -0
- package/dist/custom/dsl-fields.js +86 -0
- package/dist/custom/dsl-fields.js.map +1 -0
- package/dist/custom/load.d.ts.map +1 -1
- package/dist/custom/load.js +2 -0
- package/dist/custom/load.js.map +1 -1
- package/dist/custom/parse.d.ts +14 -3
- package/dist/custom/parse.d.ts.map +1 -1
- package/dist/custom/parse.js +44 -40
- package/dist/custom/parse.js.map +1 -1
- package/dist/custom/problems.d.ts.map +1 -1
- package/dist/custom/problems.js +10 -1
- package/dist/custom/problems.js.map +1 -1
- package/dist/detectors/amount-for-count.d.ts +21 -0
- package/dist/detectors/amount-for-count.d.ts.map +1 -0
- package/dist/detectors/amount-for-count.js +55 -0
- package/dist/detectors/amount-for-count.js.map +1 -0
- package/dist/detectors/blank-structure.d.ts.map +1 -1
- package/dist/detectors/blank-structure.js +6 -4
- package/dist/detectors/blank-structure.js.map +1 -1
- package/dist/detectors/clause-shape.d.ts +22 -0
- package/dist/detectors/clause-shape.d.ts.map +1 -0
- package/dist/detectors/clause-shape.js +149 -0
- package/dist/detectors/clause-shape.js.map +1 -0
- package/dist/detectors/code-fences.d.ts +34 -0
- package/dist/detectors/code-fences.d.ts.map +1 -0
- package/dist/detectors/code-fences.js +100 -0
- package/dist/detectors/code-fences.js.map +1 -0
- package/dist/detectors/cross-definitions.d.ts +4 -0
- package/dist/detectors/cross-definitions.d.ts.map +1 -0
- package/dist/detectors/cross-definitions.js +43 -0
- package/dist/detectors/cross-definitions.js.map +1 -0
- package/dist/detectors/cross-facts.d.ts +4 -0
- package/dist/detectors/cross-facts.d.ts.map +1 -0
- package/dist/detectors/cross-facts.js +53 -0
- package/dist/detectors/cross-facts.js.map +1 -0
- package/dist/detectors/cross-registry/cross-doc-duplicate-definition.d.ts +3 -0
- package/dist/detectors/cross-registry/cross-doc-duplicate-definition.d.ts.map +1 -0
- package/dist/detectors/cross-registry/cross-doc-duplicate-definition.js +3 -0
- package/dist/detectors/cross-registry/cross-doc-duplicate-definition.js.map +1 -0
- package/dist/detectors/cross-registry/cross-doc-fact-conflict.d.ts +3 -0
- package/dist/detectors/cross-registry/cross-doc-fact-conflict.d.ts.map +1 -0
- package/dist/detectors/cross-registry/cross-doc-fact-conflict.js +3 -0
- package/dist/detectors/cross-registry/cross-doc-fact-conflict.js.map +1 -0
- package/dist/detectors/currency-notation.d.ts +29 -0
- package/dist/detectors/currency-notation.d.ts.map +1 -0
- package/dist/detectors/currency-notation.js +58 -0
- package/dist/detectors/currency-notation.js.map +1 -0
- package/dist/detectors/custom.d.ts.map +1 -1
- package/dist/detectors/custom.js +4 -1
- package/dist/detectors/custom.js.map +1 -1
- package/dist/detectors/dangling-opener.d.ts +14 -0
- package/dist/detectors/dangling-opener.d.ts.map +1 -0
- package/dist/detectors/dangling-opener.js +55 -0
- package/dist/detectors/dangling-opener.js.map +1 -0
- package/dist/detectors/defined-term-form.d.ts +25 -0
- package/dist/detectors/defined-term-form.d.ts.map +1 -0
- package/dist/detectors/defined-term-form.js +170 -0
- package/dist/detectors/defined-term-form.js.map +1 -0
- package/dist/detectors/email-letter.d.ts +46 -0
- package/dist/detectors/email-letter.d.ts.map +1 -0
- package/dist/detectors/email-letter.js +234 -0
- package/dist/detectors/email-letter.js.map +1 -0
- package/dist/detectors/footnote-mismatch.d.ts +11 -0
- package/dist/detectors/footnote-mismatch.d.ts.map +1 -0
- package/dist/detectors/footnote-mismatch.js +55 -0
- package/dist/detectors/footnote-mismatch.js.map +1 -0
- package/dist/detectors/form-minority.d.ts +13 -0
- package/dist/detectors/form-minority.d.ts.map +1 -0
- package/dist/detectors/form-minority.js +19 -0
- package/dist/detectors/form-minority.js.map +1 -0
- package/dist/detectors/heading-end-mark.d.ts +10 -0
- package/dist/detectors/heading-end-mark.d.ts.map +1 -0
- package/dist/detectors/heading-end-mark.js +59 -0
- package/dist/detectors/heading-end-mark.js.map +1 -0
- package/dist/detectors/impossible-date.d.ts +20 -0
- package/dist/detectors/impossible-date.d.ts.map +1 -0
- package/dist/detectors/impossible-date.js +105 -0
- package/dist/detectors/impossible-date.js.map +1 -0
- package/dist/detectors/impossible-time.d.ts +18 -0
- package/dist/detectors/impossible-time.d.ts.map +1 -0
- package/dist/detectors/impossible-time.js +116 -0
- package/dist/detectors/impossible-time.js.map +1 -0
- package/dist/detectors/link-shape.d.ts +11 -0
- package/dist/detectors/link-shape.d.ts.map +1 -0
- package/dist/detectors/link-shape.js +56 -0
- package/dist/detectors/link-shape.js.map +1 -0
- package/dist/detectors/list-marker.d.ts +7 -0
- package/dist/detectors/list-marker.d.ts.map +1 -0
- package/dist/detectors/list-marker.js +50 -0
- package/dist/detectors/list-marker.js.map +1 -0
- package/dist/detectors/mark-shape.d.ts +53 -0
- package/dist/detectors/mark-shape.d.ts.map +1 -0
- package/dist/detectors/mark-shape.js +160 -0
- package/dist/detectors/mark-shape.js.map +1 -0
- package/dist/detectors/markdown-slip.d.ts +19 -0
- package/dist/detectors/markdown-slip.d.ts.map +1 -0
- package/dist/detectors/markdown-slip.js +122 -0
- package/dist/detectors/markdown-slip.js.map +1 -0
- package/dist/detectors/numeral-opener.d.ts +10 -0
- package/dist/detectors/numeral-opener.d.ts.map +1 -0
- package/dist/detectors/numeral-opener.js +65 -0
- package/dist/detectors/numeral-opener.js.map +1 -0
- package/dist/detectors/ordinal-suffix.d.ts +12 -0
- package/dist/detectors/ordinal-suffix.d.ts.map +1 -0
- package/dist/detectors/ordinal-suffix.js +33 -0
- package/dist/detectors/ordinal-suffix.js.map +1 -0
- package/dist/detectors/range-notation.d.ts +15 -0
- package/dist/detectors/range-notation.d.ts.map +1 -0
- package/dist/detectors/range-notation.js +58 -0
- package/dist/detectors/range-notation.js.map +1 -0
- package/dist/detectors/registry/adverb-polarity.d.ts +3 -0
- package/dist/detectors/registry/adverb-polarity.d.ts.map +1 -0
- package/dist/detectors/registry/adverb-polarity.js +3 -0
- package/dist/detectors/registry/adverb-polarity.js.map +1 -0
- package/dist/detectors/registry/amount-for-count.d.ts +3 -0
- package/dist/detectors/registry/amount-for-count.d.ts.map +1 -0
- package/dist/detectors/registry/amount-for-count.js +3 -0
- package/dist/detectors/registry/amount-for-count.js.map +1 -0
- package/dist/detectors/registry/attachment-missing.d.ts +3 -0
- package/dist/detectors/registry/attachment-missing.d.ts.map +1 -0
- package/dist/detectors/registry/attachment-missing.js +3 -0
- package/dist/detectors/registry/attachment-missing.js.map +1 -0
- package/dist/detectors/registry/bare-url-mix.d.ts +3 -0
- package/dist/detectors/registry/bare-url-mix.d.ts.map +1 -0
- package/dist/detectors/registry/bare-url-mix.js +3 -0
- package/dist/detectors/registry/bare-url-mix.js.map +1 -0
- package/dist/detectors/registry/caps-shouting.d.ts +3 -0
- package/dist/detectors/registry/caps-shouting.d.ts.map +1 -0
- package/dist/detectors/registry/caps-shouting.js +3 -0
- package/dist/detectors/registry/caps-shouting.js.map +1 -0
- package/dist/detectors/registry/code-fence-language.d.ts +3 -0
- package/dist/detectors/registry/code-fence-language.d.ts.map +1 -0
- package/dist/detectors/registry/code-fence-language.js +3 -0
- package/dist/detectors/registry/code-fence-language.js.map +1 -0
- package/dist/detectors/registry/currency-notation.d.ts +3 -0
- package/dist/detectors/registry/currency-notation.d.ts.map +1 -0
- package/dist/detectors/registry/currency-notation.js +3 -0
- package/dist/detectors/registry/currency-notation.js.map +1 -0
- package/dist/detectors/registry/dangling-opener.d.ts +3 -0
- package/dist/detectors/registry/dangling-opener.d.ts.map +1 -0
- package/dist/detectors/registry/dangling-opener.js +3 -0
- package/dist/detectors/registry/dangling-opener.js.map +1 -0
- package/dist/detectors/registry/defined-name-repeated.d.ts +3 -0
- package/dist/detectors/registry/defined-name-repeated.d.ts.map +1 -0
- package/dist/detectors/registry/defined-name-repeated.js +3 -0
- package/dist/detectors/registry/defined-name-repeated.js.map +1 -0
- package/dist/detectors/registry/defined-term-form.d.ts +3 -0
- package/dist/detectors/registry/defined-term-form.d.ts.map +1 -0
- package/dist/detectors/registry/defined-term-form.js +3 -0
- package/dist/detectors/registry/defined-term-form.js.map +1 -0
- package/dist/detectors/registry/email-frame.d.ts +3 -0
- package/dist/detectors/registry/email-frame.d.ts.map +1 -0
- package/dist/detectors/registry/email-frame.js +3 -0
- package/dist/detectors/registry/email-frame.js.map +1 -0
- package/dist/detectors/registry/email-subject.d.ts +3 -0
- package/dist/detectors/registry/email-subject.d.ts.map +1 -0
- package/dist/detectors/registry/email-subject.js +3 -0
- package/dist/detectors/registry/email-subject.js.map +1 -0
- package/dist/detectors/registry/ending-run.d.ts +3 -0
- package/dist/detectors/registry/ending-run.d.ts.map +1 -0
- package/dist/detectors/registry/ending-run.js +3 -0
- package/dist/detectors/registry/ending-run.js.map +1 -0
- package/dist/detectors/registry/footnote-mismatch.d.ts +3 -0
- package/dist/detectors/registry/footnote-mismatch.d.ts.map +1 -0
- package/dist/detectors/registry/footnote-mismatch.js +3 -0
- package/dist/detectors/registry/footnote-mismatch.js.map +1 -0
- package/dist/detectors/registry/heading-command.d.ts +3 -0
- package/dist/detectors/registry/heading-command.d.ts.map +1 -0
- package/dist/detectors/registry/heading-command.js +3 -0
- package/dist/detectors/registry/heading-command.js.map +1 -0
- package/dist/detectors/registry/heading-end-punctuation.d.ts +3 -0
- package/dist/detectors/registry/heading-end-punctuation.d.ts.map +1 -0
- package/dist/detectors/registry/heading-end-punctuation.js +3 -0
- package/dist/detectors/registry/heading-end-punctuation.js.map +1 -0
- package/dist/detectors/registry/hyphen-dash.d.ts +3 -0
- package/dist/detectors/registry/hyphen-dash.d.ts.map +1 -0
- package/dist/detectors/registry/hyphen-dash.js +3 -0
- package/dist/detectors/registry/hyphen-dash.js.map +1 -0
- package/dist/detectors/registry/image-file-name-alt.d.ts +3 -0
- package/dist/detectors/registry/image-file-name-alt.d.ts.map +1 -0
- package/dist/detectors/registry/image-file-name-alt.js +3 -0
- package/dist/detectors/registry/image-file-name-alt.js.map +1 -0
- package/dist/detectors/registry/impossible-date.d.ts +3 -0
- package/dist/detectors/registry/impossible-date.d.ts.map +1 -0
- package/dist/detectors/registry/impossible-date.js +3 -0
- package/dist/detectors/registry/impossible-date.js.map +1 -0
- package/dist/detectors/registry/impossible-time.d.ts +3 -0
- package/dist/detectors/registry/impossible-time.d.ts.map +1 -0
- package/dist/detectors/registry/impossible-time.js +3 -0
- package/dist/detectors/registry/impossible-time.js.map +1 -0
- package/dist/detectors/registry/latin-abbreviation.d.ts +3 -0
- package/dist/detectors/registry/latin-abbreviation.d.ts.map +1 -0
- package/dist/detectors/registry/latin-abbreviation.js +3 -0
- package/dist/detectors/registry/latin-abbreviation.js.map +1 -0
- package/dist/detectors/registry/link-text-url-mismatch.d.ts +3 -0
- package/dist/detectors/registry/link-text-url-mismatch.d.ts.map +1 -0
- package/dist/detectors/registry/link-text-url-mismatch.js +3 -0
- package/dist/detectors/registry/link-text-url-mismatch.js.map +1 -0
- package/dist/detectors/registry/list-marker.d.ts +3 -0
- package/dist/detectors/registry/list-marker.d.ts.map +1 -0
- package/dist/detectors/registry/list-marker.js +3 -0
- package/dist/detectors/registry/list-marker.js.map +1 -0
- package/dist/detectors/registry/mark-consistency.d.ts +3 -0
- package/dist/detectors/registry/mark-consistency.d.ts.map +1 -0
- package/dist/detectors/registry/mark-consistency.js +3 -0
- package/dist/detectors/registry/mark-consistency.js.map +1 -0
- package/dist/detectors/registry/numeral-opener.d.ts +3 -0
- package/dist/detectors/registry/numeral-opener.d.ts.map +1 -0
- package/dist/detectors/registry/numeral-opener.js +3 -0
- package/dist/detectors/registry/numeral-opener.js.map +1 -0
- package/dist/detectors/registry/ordinal-suffix.d.ts +3 -0
- package/dist/detectors/registry/ordinal-suffix.d.ts.map +1 -0
- package/dist/detectors/registry/ordinal-suffix.js +3 -0
- package/dist/detectors/registry/ordinal-suffix.js.map +1 -0
- package/dist/detectors/registry/origin-particle.d.ts +3 -0
- package/dist/detectors/registry/origin-particle.d.ts.map +1 -0
- package/dist/detectors/registry/origin-particle.js +3 -0
- package/dist/detectors/registry/origin-particle.js.map +1 -0
- package/dist/detectors/registry/range-notation.d.ts +3 -0
- package/dist/detectors/registry/range-notation.d.ts.map +1 -0
- package/dist/detectors/registry/range-notation.js +3 -0
- package/dist/detectors/registry/range-notation.js.map +1 -0
- package/dist/detectors/registry/relative-pronoun-mix.d.ts +3 -0
- package/dist/detectors/registry/relative-pronoun-mix.d.ts.map +1 -0
- package/dist/detectors/registry/relative-pronoun-mix.js +3 -0
- package/dist/detectors/registry/relative-pronoun-mix.js.map +1 -0
- package/dist/detectors/registry/request-without-deadline.d.ts +3 -0
- package/dist/detectors/registry/request-without-deadline.d.ts.map +1 -0
- package/dist/detectors/registry/request-without-deadline.js +3 -0
- package/dist/detectors/registry/request-without-deadline.js.map +1 -0
- package/dist/detectors/registry/sentence-spacing.d.ts +3 -0
- package/dist/detectors/registry/sentence-spacing.d.ts.map +1 -0
- package/dist/detectors/registry/sentence-spacing.js +3 -0
- package/dist/detectors/registry/sentence-spacing.js.map +1 -0
- package/dist/detectors/registry/share-over-hundred.d.ts +3 -0
- package/dist/detectors/registry/share-over-hundred.d.ts.map +1 -0
- package/dist/detectors/registry/share-over-hundred.js +3 -0
- package/dist/detectors/registry/share-over-hundred.js.map +1 -0
- package/dist/detectors/registry/shell-prompt.d.ts +3 -0
- package/dist/detectors/registry/shell-prompt.d.ts.map +1 -0
- package/dist/detectors/registry/shell-prompt.js +3 -0
- package/dist/detectors/registry/shell-prompt.js.map +1 -0
- package/dist/detectors/registry/step-reference.d.ts +3 -0
- package/dist/detectors/registry/step-reference.d.ts.map +1 -0
- package/dist/detectors/registry/step-reference.js +3 -0
- package/dist/detectors/registry/step-reference.js.map +1 -0
- package/dist/detectors/registry/step-statement.d.ts +3 -0
- package/dist/detectors/registry/step-statement.d.ts.map +1 -0
- package/dist/detectors/registry/step-statement.js +3 -0
- package/dist/detectors/registry/step-statement.js.map +1 -0
- package/dist/detectors/registry/table-row-overflow.d.ts +3 -0
- package/dist/detectors/registry/table-row-overflow.d.ts.map +1 -0
- package/dist/detectors/registry/table-row-overflow.js +3 -0
- package/dist/detectors/registry/table-row-overflow.js.map +1 -0
- package/dist/detectors/registry/toc-heading.d.ts +3 -0
- package/dist/detectors/registry/toc-heading.d.ts.map +1 -0
- package/dist/detectors/registry/toc-heading.js +3 -0
- package/dist/detectors/registry/toc-heading.js.map +1 -0
- package/dist/detectors/registry/unclosed-code-fence.d.ts +3 -0
- package/dist/detectors/registry/unclosed-code-fence.d.ts.map +1 -0
- package/dist/detectors/registry/unclosed-code-fence.js +3 -0
- package/dist/detectors/registry/unclosed-code-fence.js.map +1 -0
- package/dist/detectors/registry/unpaired-parallel.d.ts +3 -0
- package/dist/detectors/registry/unpaired-parallel.d.ts.map +1 -0
- package/dist/detectors/registry/unpaired-parallel.js +3 -0
- package/dist/detectors/registry/unpaired-parallel.js.map +1 -0
- package/dist/detectors/registry/unrendered-emphasis.d.ts +3 -0
- package/dist/detectors/registry/unrendered-emphasis.d.ts.map +1 -0
- package/dist/detectors/registry/unrendered-emphasis.js +3 -0
- package/dist/detectors/registry/unrendered-emphasis.js.map +1 -0
- package/dist/detectors/relative-pronoun-mix.d.ts +19 -0
- package/dist/detectors/relative-pronoun-mix.d.ts.map +1 -0
- package/dist/detectors/relative-pronoun-mix.js +60 -0
- package/dist/detectors/relative-pronoun-mix.js.map +1 -0
- package/dist/detectors/request-owner.d.ts +23 -0
- package/dist/detectors/request-owner.d.ts.map +1 -0
- package/dist/detectors/request-owner.js +110 -0
- package/dist/detectors/request-owner.js.map +1 -0
- package/dist/detectors/share-over-hundred.d.ts +20 -0
- package/dist/detectors/share-over-hundred.d.ts.map +1 -0
- package/dist/detectors/share-over-hundred.js +55 -0
- package/dist/detectors/share-over-hundred.js.map +1 -0
- package/dist/detectors/step-reference.d.ts +20 -0
- package/dist/detectors/step-reference.d.ts.map +1 -0
- package/dist/detectors/step-reference.js +57 -0
- package/dist/detectors/step-reference.js.map +1 -0
- package/dist/detectors/technical-docs.d.ts +32 -0
- package/dist/detectors/technical-docs.d.ts.map +1 -0
- package/dist/detectors/technical-docs.js +199 -0
- package/dist/detectors/technical-docs.js.map +1 -0
- package/dist/detectors/toc-heading.d.ts +10 -0
- package/dist/detectors/toc-heading.d.ts.map +1 -0
- package/dist/detectors/toc-heading.js +99 -0
- package/dist/detectors/toc-heading.js.map +1 -0
- package/dist/extension/pack-read.d.ts +21 -0
- package/dist/extension/pack-read.d.ts.map +1 -0
- package/dist/extension/pack-read.js +117 -0
- package/dist/extension/pack-read.js.map +1 -0
- package/dist/extension/plugin-load.d.ts.map +1 -1
- package/dist/extension/plugin-load.js +44 -10
- package/dist/extension/plugin-load.js.map +1 -1
- package/dist/extension/plugin-parse.d.ts.map +1 -1
- package/dist/extension/plugin-parse.js +10 -3
- package/dist/extension/plugin-parse.js.map +1 -1
- package/dist/facts/address-values.d.ts +5 -0
- package/dist/facts/address-values.d.ts.map +1 -0
- package/dist/facts/address-values.js +64 -0
- package/dist/facts/address-values.js.map +1 -0
- package/dist/facts/cross-facts.d.ts +20 -0
- package/dist/facts/cross-facts.d.ts.map +1 -0
- package/dist/facts/cross-facts.js +41 -0
- package/dist/facts/cross-facts.js.map +1 -0
- package/dist/fix-plan/chosen-depth.d.ts +10 -0
- package/dist/fix-plan/chosen-depth.d.ts.map +1 -0
- package/dist/fix-plan/chosen-depth.js +24 -0
- package/dist/fix-plan/chosen-depth.js.map +1 -0
- package/dist/fix-plan/mode.d.ts +13 -4
- package/dist/fix-plan/mode.d.ts.map +1 -1
- package/dist/fix-plan/mode.js +38 -7
- package/dist/fix-plan/mode.js.map +1 -1
- package/dist/fix-plan/plan.d.ts +20 -0
- package/dist/fix-plan/plan.d.ts.map +1 -1
- package/dist/fix-plan/plan.js +23 -5
- package/dist/fix-plan/plan.js.map +1 -1
- package/dist/fix-plan/render.d.ts.map +1 -1
- package/dist/fix-plan/render.js +24 -0
- package/dist/fix-plan/render.js.map +1 -1
- package/dist/fix-plan/text.d.ts +8 -0
- package/dist/fix-plan/text.d.ts.map +1 -1
- package/dist/fix-plan/text.js +36 -10
- package/dist/fix-plan/text.js.map +1 -1
- package/dist/genre-load.d.ts +1 -1
- package/dist/genre-load.d.ts.map +1 -1
- package/dist/genre-load.js +7 -4
- package/dist/genre-load.js.map +1 -1
- package/dist/genre-parse.d.ts +6 -0
- package/dist/genre-parse.d.ts.map +1 -1
- package/dist/genre-parse.js +18 -0
- package/dist/genre-parse.js.map +1 -1
- package/dist/init.js +10 -10
- package/dist/init.js.map +1 -1
- package/dist/known-genres.d.ts +8 -0
- package/dist/known-genres.d.ts.map +1 -0
- package/dist/known-genres.js +17 -0
- package/dist/known-genres.js.map +1 -0
- package/dist/link-shape.d.ts +20 -0
- package/dist/link-shape.d.ts.map +1 -0
- package/dist/link-shape.js +58 -0
- package/dist/link-shape.js.map +1 -0
- package/dist/list-marks.d.ts +21 -0
- package/dist/list-marks.d.ts.map +1 -0
- package/dist/list-marks.js +82 -0
- package/dist/list-marks.js.map +1 -0
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +15 -4
- package/dist/reasons.js.map +1 -1
- package/dist/render/explain.d.ts.map +1 -1
- package/dist/render/explain.js +11 -2
- package/dist/render/explain.js.map +1 -1
- package/dist/render/friendly.js +1 -1
- package/dist/render/friendly.js.map +1 -1
- package/dist/render/rules-json.d.ts.map +1 -1
- package/dist/render/rules-json.js +12 -3
- package/dist/render/rules-json.js.map +1 -1
- package/dist/render/rules-table.js +6 -6
- package/dist/render/rules-table.js.map +1 -1
- package/dist/render/semantic.js +2 -2
- package/dist/render/semantic.js.map +1 -1
- package/dist/render/suppressions.js +2 -2
- package/dist/render/suppressions.js.map +1 -1
- package/dist/rewrite-depth.d.ts +22 -0
- package/dist/rewrite-depth.d.ts.map +1 -0
- package/dist/rewrite-depth.js +42 -0
- package/dist/rewrite-depth.js.map +1 -0
- package/dist/rule-fields.d.ts +28 -0
- package/dist/rule-fields.d.ts.map +1 -0
- package/dist/rule-fields.js +85 -0
- package/dist/rule-fields.js.map +1 -0
- package/dist/rule-guide.d.ts +3 -0
- package/dist/rule-guide.d.ts.map +1 -1
- package/dist/rule-guide.js +6 -0
- package/dist/rule-guide.js.map +1 -1
- package/dist/rule-load.d.ts.map +1 -1
- package/dist/rule-load.js +13 -5
- package/dist/rule-load.js.map +1 -1
- package/dist/rule-offs.d.ts +14 -0
- package/dist/rule-offs.d.ts.map +1 -0
- package/dist/rule-offs.js +45 -0
- package/dist/rule-offs.js.map +1 -0
- package/dist/structure/build.d.ts.map +1 -1
- package/dist/structure/build.js +14 -1
- package/dist/structure/build.js.map +1 -1
- package/dist/structure/cross-definitions.d.ts +23 -0
- package/dist/structure/cross-definitions.d.ts.map +1 -0
- package/dist/structure/cross-definitions.js +34 -0
- package/dist/structure/cross-definitions.js.map +1 -0
- package/genres.yaml +14 -313
- package/package.json +3 -3
- package/rules/absolute-exception.yaml +3 -1
- package/rules/abstract-length.yaml +7 -1
- package/rules/acronym-expansion-conflict.yaml +2 -1
- package/rules/adverb-overuse.yaml +7 -1
- package/rules/adverb-without-negation.yaml +60 -0
- package/rules/adversative-ga-repeat.yaml +2 -1
- package/rules/agentless-passive.yaml +10 -1
- package/rules/agreement-slip.yaml +4 -1
- package/rules/ai-generated-composite.yaml +6 -1
- package/rules/ai-structure.yaml +8 -2
- package/rules/ai-tell.yaml +7 -1
- package/rules/all-caps-shouting.yaml +61 -0
- package/rules/announced-count-mismatch.yaml +3 -1
- package/rules/announcing-opener.yaml +7 -1
- package/rules/article-sound.yaml +6 -2
- package/rules/assistant-residue.yaml +4 -1
- package/rules/attachment-not-attached.yaml +112 -0
- package/rules/baito-keigo.yaml +64 -0
- package/rules/bare-url-mix.yaml +86 -0
- package/rules/bold-density.yaml +1 -0
- package/rules/bold-label-list.yaml +9 -1
- package/rules/bracket-nesting.yaml +2 -1
- package/rules/bracket-width-consistency.yaml +64 -0
- package/rules/broken-link.yaml +1 -1
- package/rules/chat-citation-residue.yaml +2 -1
- package/rules/citation-reference-mismatch.yaml +7 -1
- package/rules/citation-style-mix.yaml +7 -1
- package/rules/clause-chain.yaml +6 -1
- package/rules/cliche.yaml +67 -0
- package/rules/closing-cliche.yaml +7 -0
- package/rules/code-fence-language-mix.yaml +176 -0
- package/rules/colloquial-opener.yaml +62 -0
- package/rules/colon-lead-in.yaml +7 -1
- package/rules/concrete-evidence-density.yaml +6 -0
- package/rules/contraction-consistency.yaml +4 -1
- package/rules/contrast-framing.yaml +7 -1
- package/rules/cross-doc-duplicate-definition.yaml +70 -0
- package/rules/cross-doc-fact-conflict.yaml +64 -0
- package/rules/currency-notation-consistency.yaml +77 -0
- package/rules/cushion-phrase-density.yaml +8 -1
- package/rules/dangling-figure-reference.yaml +3 -1
- package/rules/dangling-participle.yaml +58 -0
- package/rules/dangling-reference.yaml +3 -1
- package/rules/date-format-consistency.yaml +3 -2
- package/rules/date-order.yaml +3 -1
- package/rules/date-range-reversed.yaml +3 -1
- package/rules/date-weekday-mismatch.yaml +3 -1
- package/rules/date-without-year.yaml +4 -3
- package/rules/defined-name-repeated.yaml +97 -0
- package/rules/defined-term-form.yaml +113 -0
- package/rules/demonstrative-opener-run.yaml +2 -1
- package/rules/double-keigo.yaml +6 -1
- package/rules/double-negative.yaml +5 -1
- package/rules/doubled-nado.yaml +2 -1
- package/rules/doubled-punctuation.yaml +1 -1
- package/rules/doubled-word.yaml +4 -1
- package/rules/duplicate-definition.yaml +3 -1
- package/rules/duplicate-heading.yaml +1 -1
- package/rules/duration-mismatch.yaml +2 -1
- package/rules/elapsed-years-mismatch.yaml +4 -1
- package/rules/email-greeting-closing.yaml +122 -0
- package/rules/email-subject-length.yaml +112 -0
- package/rules/emoji-density.yaml +3 -1
- package/rules/emoji-heading.yaml +7 -1
- package/rules/empty-intensifier.yaml +4 -0
- package/rules/empty-list-item.yaml +2 -1
- package/rules/empty-section.yaml +1 -1
- package/rules/empty-table-cell.yaml +2 -1
- package/rules/excessive-hedging.yaml +7 -1
- package/rules/exclamation-width-consistency.yaml +64 -0
- package/rules/expletive-construction.yaml +7 -1
- package/rules/fact-conflict.yaml +4 -1
- package/rules/figure-reference-order.yaml +7 -1
- package/rules/footnote-mismatch.yaml +91 -0
- package/rules/fullwidth-alnum-consistency.yaml +2 -2
- package/rules/hankaku-kana.yaml +1 -1
- package/rules/heading-command-missing.yaml +109 -0
- package/rules/heading-echo.yaml +6 -1
- package/rules/heading-end-punctuation-mix.yaml +158 -0
- package/rules/heading-level-skip.yaml +3 -3
- package/rules/heading-numbering-mix.yaml +4 -3
- package/rules/hiragana-fukushi.yaml +4 -1
- package/rules/homophone-slip.yaml +5 -1
- package/rules/humble-for-others.yaml +63 -0
- package/rules/hyphen-as-dash.yaml +59 -0
- package/rules/idiom-misuse.yaml +4 -1
- package/rules/image-file-name-alt.yaml +83 -0
- package/rules/impossible-date.yaml +79 -0
- package/rules/impossible-time.yaml +76 -0
- package/rules/internal-jargon.yaml +1 -1
- package/rules/invisible-character.yaml +1 -1
- package/rules/katakana-density.yaml +2 -1
- package/rules/katakana-long-vowel.yaml +1 -1
- package/rules/known-misspelling.yaml +2 -1
- package/rules/kutoten-consistency.yaml +1 -1
- package/rules/latin-abbreviation-form.yaml +58 -0
- package/rules/latin-spacing.yaml +6 -2
- package/rules/less-for-fewer.yaml +59 -0
- package/rules/link-text-url-mismatch.yaml +72 -0
- package/rules/list-item-form-mix.yaml +7 -1
- package/rules/list-marker-mix.yaml +111 -0
- package/rules/max-kanji-continuous.yaml +10 -2
- package/rules/max-paragraph-length.yaml +4 -1
- package/rules/max-sentence-length.yaml +29 -21
- package/rules/max-ten.yaml +4 -1
- package/rules/misconversion.yaml +2 -1
- package/rules/modal-conflict.yaml +2 -1
- package/rules/name-variant.yaml +4 -3
- package/rules/ngram-repetition.yaml +5 -0
- package/rules/no-doubled-joshi.yaml +5 -1
- package/rules/no-em-dash.yaml +4 -1
- package/rules/no-lead.yaml +6 -1
- package/rules/no-mixed-desumasu.yaml +5 -2
- package/rules/no-nakaguro-parallel.yaml +3 -0
- package/rules/nominalization.yaml +5 -1
- package/rules/nonstandard-word.yaml +80 -0
- package/rules/number-style-consistency.yaml +6 -1
- package/rules/number-without-unit.yaml +2 -1
- package/rules/numbering-gap.yaml +1 -1
- package/rules/numeral-sentence-start.yaml +56 -0
- package/rules/one-sentence-paragraph-run.yaml +5 -1
- package/rules/ordinal-suffix-mismatch.yaml +65 -0
- package/rules/orthographic-variant.yaml +4 -1
- package/rules/outside-announced-list.yaml +2 -1
- package/rules/oxford-comma-consistency.yaml +3 -1
- package/rules/padded-intro.yaml +7 -0
- package/rules/paragraph-length-variance.yaml +7 -1
- package/rules/paragraph-restatement.yaml +6 -1
- package/rules/percent-sum-mismatch.yaml +3 -1
- package/rules/person-consistency.yaml +4 -1
- package/rules/preamble-length.yaml +6 -0
- package/rules/preferred-term.yaml +1 -1
- package/rules/proper-noun-density.yaml +8 -1
- package/rules/quote-style-consistency.yaml +66 -0
- package/rules/ra-nuki.yaml +4 -1
- package/rules/range-notation-consistency.yaml +73 -0
- package/rules/redundant-expression.yaml +4 -1
- package/rules/reference-title-mismatch.yaml +4 -3
- package/rules/reference-topic-missing.yaml +2 -1
- package/rules/relative-date-mismatch.yaml +2 -1
- package/rules/repeated-conjunction.yaml +4 -1
- package/rules/repeated-sentence-ending.yaml +62 -0
- package/rules/repeated-sentence-head.yaml +4 -0
- package/rules/request-without-deadline.yaml +92 -0
- package/rules/required-sections.yaml +1 -1
- package/rules/requirement-modal.yaml +1 -1
- package/rules/requirement-smell.yaml +12 -4
- package/rules/rule-of-three.yaml +8 -1
- package/rules/sasete-itadaku.yaml +7 -1
- package/rules/section-length-uniformity.yaml +7 -1
- package/rules/sentence-initial-conjunction-run.yaml +5 -1
- package/rules/sentence-initial-so.yaml +6 -1
- package/rules/sentence-rhythm.yaml +8 -1
- package/rules/sentence-spacing-consistency.yaml +63 -0
- package/rules/share-over-hundred.yaml +65 -0
- package/rules/shell-prompt-mix.yaml +128 -0
- package/rules/space-before-punctuation.yaml +1 -1
- package/rules/spelling-consistency.yaml +3 -1
- package/rules/step-reference-missing.yaml +85 -0
- package/rules/step-statement-mix.yaml +76 -0
- package/rules/stock-transition.yaml +8 -1
- package/rules/stray-space.yaml +2 -2
- package/rules/summary-fact-mismatch.yaml +4 -1
- package/rules/table-header-variant.yaml +2 -1
- package/rules/table-row-overflow.yaml +90 -0
- package/rules/taigen-dome-in-prose.yaml +6 -0
- package/rules/tari-unpaired.yaml +58 -0
- package/rules/teki-overuse.yaml +2 -1
- package/rules/title-case-consistency.yaml +1 -1
- package/rules/title-length.yaml +7 -1
- package/rules/toc-heading-mismatch.yaml +136 -0
- package/rules/topic-predicate-distance.yaml +6 -1
- package/rules/total-mismatch.yaml +3 -1
- package/rules/translationese-density.yaml +4 -1
- package/rules/unbalanced-bracket.yaml +3 -3
- package/rules/unclosed-code-fence.yaml +107 -0
- package/rules/uncomparable-graded.yaml +65 -0
- package/rules/undefined-acronym.yaml +8 -1
- package/rules/unfilled-placeholder.yaml +1 -1
- package/rules/unit-mismatch.yaml +2 -1
- package/rules/unknown-word.yaml +4 -1
- package/rules/unqualified-superlative.yaml +6 -1
- package/rules/unrendered-emphasis.yaml +73 -0
- package/rules/unused-definition.yaml +4 -3
- package/rules/url-run-on.yaml +1 -1
- package/rules/use-before-definition.yaml +4 -3
- package/rules/vague-figure-reference.yaml +3 -1
- package/rules/vague-link-text.yaml +2 -1
- package/rules/vague-word-density.yaml +2 -1
- package/rules/very-adjective.yaml +5 -1
- package/rules/weasel-word.yaml +6 -1
- package/rules/which-that-consistency.yaml +64 -0
- package/rules/wordy-phrase.yaml +6 -1
- package/rules/yori-as-from.yaml +61 -0
- package/skills/chaff/SKILL.md +7 -7
- package/src/api.ts +13 -1
- package/src/cli-text.ts +22 -7
- package/src/cli.ts +8 -9
- package/src/command-help.ts +26 -0
- package/src/commands/eval.ts +2 -2
- package/src/commands/fix-plan.ts +13 -1
- package/src/commands/help.ts +8 -0
- package/src/commands/init-command.ts +13 -0
- package/src/commands/plugin-init.ts +150 -0
- package/src/commands/plugin-test.ts +111 -0
- package/src/config/load.ts +3 -0
- package/src/config/option-problems.ts +2 -2
- package/src/config/rule-problems.ts +2 -2
- package/src/custom/checked.ts +8 -0
- package/src/custom/dsl-fields.ts +102 -0
- package/src/custom/load.ts +2 -0
- package/src/custom/parse.ts +72 -50
- package/src/custom/problems.ts +16 -2
- package/src/detectors/amount-for-count.ts +90 -0
- package/src/detectors/blank-structure.ts +12 -4
- package/src/detectors/clause-shape.ts +199 -0
- package/src/detectors/code-fences.ts +113 -0
- package/src/detectors/cross-definitions.ts +49 -0
- package/src/detectors/cross-facts.ts +60 -0
- package/src/detectors/cross-registry/cross-doc-duplicate-definition.ts +4 -0
- package/src/detectors/cross-registry/cross-doc-fact-conflict.ts +4 -0
- package/src/detectors/currency-notation.ts +90 -0
- package/src/detectors/custom.ts +10 -2
- package/src/detectors/dangling-opener.ts +74 -0
- package/src/detectors/defined-term-form.ts +200 -0
- package/src/detectors/email-letter.ts +262 -0
- package/src/detectors/footnote-mismatch.ts +72 -0
- package/src/detectors/form-minority.ts +21 -0
- package/src/detectors/heading-end-mark.ts +82 -0
- package/src/detectors/impossible-date.ts +141 -0
- package/src/detectors/impossible-time.ts +151 -0
- package/src/detectors/link-shape.ts +70 -0
- package/src/detectors/list-marker.ts +60 -0
- package/src/detectors/mark-shape.ts +202 -0
- package/src/detectors/markdown-slip.ts +140 -0
- package/src/detectors/numeral-opener.ts +72 -0
- package/src/detectors/ordinal-suffix.ts +40 -0
- package/src/detectors/range-notation.ts +76 -0
- package/src/detectors/registry/adverb-polarity.ts +4 -0
- package/src/detectors/registry/amount-for-count.ts +4 -0
- package/src/detectors/registry/attachment-missing.ts +4 -0
- package/src/detectors/registry/bare-url-mix.ts +4 -0
- package/src/detectors/registry/caps-shouting.ts +4 -0
- package/src/detectors/registry/code-fence-language.ts +4 -0
- package/src/detectors/registry/currency-notation.ts +4 -0
- package/src/detectors/registry/dangling-opener.ts +4 -0
- package/src/detectors/registry/defined-name-repeated.ts +4 -0
- package/src/detectors/registry/defined-term-form.ts +4 -0
- package/src/detectors/registry/email-frame.ts +4 -0
- package/src/detectors/registry/email-subject.ts +4 -0
- package/src/detectors/registry/ending-run.ts +4 -0
- package/src/detectors/registry/footnote-mismatch.ts +4 -0
- package/src/detectors/registry/heading-command.ts +4 -0
- package/src/detectors/registry/heading-end-punctuation.ts +4 -0
- package/src/detectors/registry/hyphen-dash.ts +4 -0
- package/src/detectors/registry/image-file-name-alt.ts +4 -0
- package/src/detectors/registry/impossible-date.ts +4 -0
- package/src/detectors/registry/impossible-time.ts +4 -0
- package/src/detectors/registry/latin-abbreviation.ts +4 -0
- package/src/detectors/registry/link-text-url-mismatch.ts +4 -0
- package/src/detectors/registry/list-marker.ts +4 -0
- package/src/detectors/registry/mark-consistency.ts +4 -0
- package/src/detectors/registry/numeral-opener.ts +4 -0
- package/src/detectors/registry/ordinal-suffix.ts +4 -0
- package/src/detectors/registry/origin-particle.ts +4 -0
- package/src/detectors/registry/range-notation.ts +4 -0
- package/src/detectors/registry/relative-pronoun-mix.ts +4 -0
- package/src/detectors/registry/request-without-deadline.ts +4 -0
- package/src/detectors/registry/sentence-spacing.ts +4 -0
- package/src/detectors/registry/share-over-hundred.ts +4 -0
- package/src/detectors/registry/shell-prompt.ts +4 -0
- package/src/detectors/registry/step-reference.ts +4 -0
- package/src/detectors/registry/step-statement.ts +4 -0
- package/src/detectors/registry/table-row-overflow.ts +4 -0
- package/src/detectors/registry/toc-heading.ts +4 -0
- package/src/detectors/registry/unclosed-code-fence.ts +4 -0
- package/src/detectors/registry/unpaired-parallel.ts +4 -0
- package/src/detectors/registry/unrendered-emphasis.ts +4 -0
- package/src/detectors/relative-pronoun-mix.ts +79 -0
- package/src/detectors/request-owner.ts +141 -0
- package/src/detectors/share-over-hundred.ts +75 -0
- package/src/detectors/step-reference.ts +83 -0
- package/src/detectors/technical-docs.ts +230 -0
- package/src/detectors/toc-heading.ts +125 -0
- package/src/extension/pack-read.ts +128 -0
- package/src/extension/plugin-load.ts +49 -9
- package/src/extension/plugin-parse.ts +10 -3
- package/src/facts/address-values.ts +74 -0
- package/src/facts/cross-facts.ts +54 -0
- package/src/fix-plan/chosen-depth.ts +28 -0
- package/src/fix-plan/mode.ts +57 -11
- package/src/fix-plan/plan.ts +37 -5
- package/src/fix-plan/render.ts +24 -0
- package/src/fix-plan/text.ts +47 -10
- package/src/genre-load.ts +7 -4
- package/src/genre-parse.ts +19 -0
- package/src/init.ts +10 -10
- package/src/known-genres.ts +19 -0
- package/src/link-shape.ts +62 -0
- package/src/list-marks.ts +106 -0
- package/src/reasons.ts +16 -4
- package/src/render/explain.ts +14 -2
- package/src/render/friendly.ts +1 -1
- package/src/render/rules-json.ts +14 -3
- package/src/render/rules-table.ts +6 -6
- package/src/render/semantic.ts +2 -2
- package/src/render/suppressions.ts +2 -2
- package/src/rewrite-depth.ts +60 -0
- package/src/rule-fields.ts +123 -0
- package/src/rule-guide.ts +9 -0
- package/src/rule-load.ts +10 -4
- package/src/rule-offs.ts +50 -0
- package/src/structure/build.ts +21 -1
- package/src/structure/cross-definitions.ts +60 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
// A work email or letter's own parts: a greeting and a closing, a subject line, and an attachment the text mentions.
|
|
2
|
+
// Pure. The words (お世話になっております, Dear, Best regards, 件名, attached) come from the language's email-greeting,
|
|
3
|
+
// email-closing, email-subject-field, attachment-mention, attachment-not-mention and attachment-line lexicons. The
|
|
4
|
+
// header and the signature are masked in doc.prose; a quoted reply is someone else's words and is left out.
|
|
5
|
+
import { escapeRegExp } from "../orthography.js";
|
|
6
|
+
import { quoteAt } from "./structure-tree.js";
|
|
7
|
+
/** A greeting comes before the body: past the subject, the addressee (株式会社… / 総務部 山田様) and the writer's name. */
|
|
8
|
+
const GREETING_LINES = 5;
|
|
9
|
+
/** A closing comes at the end, before the writer's name, title, company, address and contact lines, or an acceptance block. */
|
|
10
|
+
const CLOSING_LINES = 10;
|
|
11
|
+
const patternsOf = (doc, id) => (doc.lexicons[id] ?? []).map((entry) => entry.pattern);
|
|
12
|
+
const LATIN_START = /^[A-Za-z]/u;
|
|
13
|
+
const LETTER = /\p{L}/u;
|
|
14
|
+
/**
|
|
15
|
+
* Whether a line holds one of the words. A Latin word opens the line (Dear, Best regards) and is followed by no letter,
|
|
16
|
+
* so "Hi" does not match "History"; a Japanese word may stand anywhere in it (いつもお世話になっております).
|
|
17
|
+
*/
|
|
18
|
+
export const lineHas = (line, words) => {
|
|
19
|
+
const trimmed = line.trim();
|
|
20
|
+
const folded = trimmed.toLowerCase();
|
|
21
|
+
return words.some((word) => {
|
|
22
|
+
if (!LATIN_START.test(word))
|
|
23
|
+
return trimmed.includes(word);
|
|
24
|
+
return folded.startsWith(word.toLowerCase()) && !LETTER.test(trimmed.charAt(word.length));
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Whether each offset, asked in rising order, is inside one of the spans (sorted by start). One pass over the spans for
|
|
29
|
+
* the whole document: an archive with a quoted reply in every message stays linear.
|
|
30
|
+
*/
|
|
31
|
+
const insideCursor = (spans) => {
|
|
32
|
+
const sorted = spans.toSorted((left, right) => left.start - right.start);
|
|
33
|
+
const cursor = { next: 0, farthestEnd: -1 };
|
|
34
|
+
return (offset) => {
|
|
35
|
+
while (cursor.next < sorted.length && (sorted[cursor.next]?.start ?? Infinity) <= offset) {
|
|
36
|
+
cursor.farthestEnd = Math.max(cursor.farthestEnd, sorted[cursor.next]?.end ?? 0);
|
|
37
|
+
cursor.next += 1;
|
|
38
|
+
}
|
|
39
|
+
return offset < cursor.farthestEnd;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* A line prose masks words at the head of: a header field whose value stays (Subject: …), not the writer's text. Emphasis
|
|
44
|
+
* marks are masked too, but they hold no letter.
|
|
45
|
+
*/
|
|
46
|
+
const isFieldLine = (sourceLine, proseLine) => {
|
|
47
|
+
const sourceChars = [...sourceLine];
|
|
48
|
+
const kept = [...proseLine].findIndex((char, index) => char.trim() !== "" || sourceChars[index]?.trim() === "");
|
|
49
|
+
return LETTER.test(sourceChars.slice(0, kept === -1 ? sourceChars.length : kept).join(""));
|
|
50
|
+
};
|
|
51
|
+
const linesWithOffsets = (text) => {
|
|
52
|
+
const lines = [];
|
|
53
|
+
text.split("\n").forEach((line) => lines.push({ start: (lines.at(-1)?.start ?? 0) + (lines.at(-1)?.text.length ?? -1) + 1, text: line }));
|
|
54
|
+
return lines;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* The writer's own lines, in order: not blank once the header and signature are masked (prose), not a quoted reply, not a
|
|
58
|
+
* heading. A heading, or a line the source has and prose masks (a header, a signature), breaks the text into parts.
|
|
59
|
+
*/
|
|
60
|
+
export const bodyLines = (source, prose, replyQuotes) => {
|
|
61
|
+
const quoted = insideCursor(replyQuotes);
|
|
62
|
+
const lines = [];
|
|
63
|
+
const state = { broken: false };
|
|
64
|
+
linesWithOffsets(prose).forEach(({ start, text }) => {
|
|
65
|
+
const trimmed = text.trimStart();
|
|
66
|
+
const sourceLine = source.slice(start, start + text.length);
|
|
67
|
+
const masked = trimmed === "" ? sourceLine.trim() !== "" : isFieldLine(sourceLine, text);
|
|
68
|
+
const inQuote = quoted(start);
|
|
69
|
+
if (masked || trimmed.startsWith("#"))
|
|
70
|
+
state.broken = true;
|
|
71
|
+
else if (trimmed !== "" && !trimmed.startsWith(">") && !inQuote) {
|
|
72
|
+
lines.push({ start, text, breaks: state.broken });
|
|
73
|
+
state.broken = false;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return lines;
|
|
77
|
+
};
|
|
78
|
+
/** The lines split where a heading, a header or a signature breaks them: a letter and its appendix, or one message and the next. */
|
|
79
|
+
const partsOf = (lines) => {
|
|
80
|
+
const parts = [];
|
|
81
|
+
lines.forEach((line) => {
|
|
82
|
+
const current = parts.at(-1);
|
|
83
|
+
if (line.breaks || current === undefined)
|
|
84
|
+
parts.push([line]);
|
|
85
|
+
else
|
|
86
|
+
current.push(line);
|
|
87
|
+
});
|
|
88
|
+
return parts;
|
|
89
|
+
};
|
|
90
|
+
/** A missing greeting (none in the first lines) and a missing closing (none in the last lines of any part). */
|
|
91
|
+
export const frameSlips = (lines, greetings, closings) => {
|
|
92
|
+
const first = lines[0];
|
|
93
|
+
const last = lines.at(-1);
|
|
94
|
+
if (first === undefined || last === undefined)
|
|
95
|
+
return [];
|
|
96
|
+
const greeted = lines.slice(0, GREETING_LINES).some((line) => lineHas(line.text, greetings));
|
|
97
|
+
const closed = partsOf(lines).some((part) => part.slice(-CLOSING_LINES).some((line) => lineHas(line.text, closings)));
|
|
98
|
+
return [
|
|
99
|
+
...(greeted ? [] : [{ variant: "greeting", offset: first.start }]),
|
|
100
|
+
...(closed ? [] : [{ variant: "closing", offset: last.start }]),
|
|
101
|
+
];
|
|
102
|
+
};
|
|
103
|
+
export const emailFrame = (doc) => frameSlips(bodyLines(doc.source, doc.prose ?? doc.source, doc.replyQuotes ?? []), patternsOf(doc, "email-greeting"), patternsOf(doc, "email-closing")).map((slip) => ({
|
|
104
|
+
rule: "email-greeting-closing",
|
|
105
|
+
severity: "info",
|
|
106
|
+
line: 0,
|
|
107
|
+
column: 0,
|
|
108
|
+
quote: quoteAt(doc.source, slip.offset),
|
|
109
|
+
values: { offset: slip.offset },
|
|
110
|
+
variant: slip.variant,
|
|
111
|
+
}));
|
|
112
|
+
/** A field's name is one word of at most this many characters. */
|
|
113
|
+
const MAX_FIELD_NAME = 20;
|
|
114
|
+
const BLANK = /\s/u;
|
|
115
|
+
/** "Subject: Lunch" as its name and value; undefined for a line that is no field. */
|
|
116
|
+
export const fieldOf = (line) => {
|
|
117
|
+
const colon = [...line].findIndex((char) => char === ":" || char === ":");
|
|
118
|
+
if (colon <= 0)
|
|
119
|
+
return undefined;
|
|
120
|
+
const chars = [...line];
|
|
121
|
+
const name = chars.slice(0, colon).join("").trimEnd();
|
|
122
|
+
return name.length > MAX_FIELD_NAME || BLANK.test(name)
|
|
123
|
+
? undefined
|
|
124
|
+
: {
|
|
125
|
+
name,
|
|
126
|
+
value: chars
|
|
127
|
+
.slice(colon + 1)
|
|
128
|
+
.join("")
|
|
129
|
+
.trim(),
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
/** The subject lines (Subject: …, 件名:…), outside a quoted reply, with reply and forward marks (Re:, Fwd:) taken off the value. */
|
|
133
|
+
export const subjectLines = (source, fields, replyMarks, replyQuotes) => {
|
|
134
|
+
const names = new Set(fields.map((field) => field.toLowerCase()));
|
|
135
|
+
const quoted = insideCursor(replyQuotes);
|
|
136
|
+
return linesWithOffsets(source).flatMap(({ start, text }) => {
|
|
137
|
+
const field = fieldOf(text);
|
|
138
|
+
const inQuote = quoted(start);
|
|
139
|
+
return field === undefined || inQuote || !names.has(field.name.toLowerCase()) ? [] : [{ start, subject: withoutReplyMarks(field.value, replyMarks) }];
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
/** "Re: Fwd: Lunch" is "Lunch": the marks a mail program adds are not what the writer wrote. Read piece by piece between colons. */
|
|
143
|
+
export const withoutReplyMarks = (subject, marks) => {
|
|
144
|
+
const folded = new Set(marks.map((mark) => mark.toLowerCase()));
|
|
145
|
+
const pieces = subject.split(/[::]/u);
|
|
146
|
+
const kept = pieces.findIndex((piece, index) => index === pieces.length - 1 || !folded.has(piece.trim().toLowerCase()));
|
|
147
|
+
const dropped = pieces.slice(0, kept).reduce((length, piece) => length + piece.length + 1, 0);
|
|
148
|
+
return subject.slice(dropped).trim();
|
|
149
|
+
};
|
|
150
|
+
export const emailSubject = (doc, options) => subjectLines(doc.source, patternsOf(doc, "email-subject-field"), patternsOf(doc, "email-reply-mark"), doc.replyQuotes ?? []).flatMap((line) => {
|
|
151
|
+
const length = [...line.subject].length;
|
|
152
|
+
if (length > 0 && length <= options.limit)
|
|
153
|
+
return [];
|
|
154
|
+
return [
|
|
155
|
+
{
|
|
156
|
+
rule: "email-subject-length",
|
|
157
|
+
severity: "warning",
|
|
158
|
+
line: 0,
|
|
159
|
+
column: 0,
|
|
160
|
+
quote: quoteAt(doc.source, line.start),
|
|
161
|
+
values: { count: length, limit: options.limit, offset: line.start },
|
|
162
|
+
...(length === 0 ? { variant: "empty" } : {}),
|
|
163
|
+
},
|
|
164
|
+
];
|
|
165
|
+
});
|
|
166
|
+
/** Where the text first mentions an attachment (添付します, attached), outside the phrases that only look like one (attached to). */
|
|
167
|
+
export const firstMention = (lines, mentions, notMentions) => {
|
|
168
|
+
const folded = (text) => text.toLowerCase();
|
|
169
|
+
const isMention = (text) => {
|
|
170
|
+
const cleared = notMentions.reduce((rest, phrase) => rest.split(folded(phrase)).join(" "), folded(text));
|
|
171
|
+
return mentions.some((word) => cleared.includes(folded(word)));
|
|
172
|
+
};
|
|
173
|
+
const line = lines.find((candidate) => isMention(candidate.text));
|
|
174
|
+
return line === undefined ? undefined : line.start + line.text.length - line.text.trimStart().length;
|
|
175
|
+
};
|
|
176
|
+
/** The marks around a label line: a heading's #, emphasis, 【】. */
|
|
177
|
+
const LINE_MARKS = new Set("#*_【】 \t\u3000");
|
|
178
|
+
const withoutMarks = (line) => {
|
|
179
|
+
const chars = [...line];
|
|
180
|
+
const first = chars.findIndex((char) => !LINE_MARKS.has(char));
|
|
181
|
+
return first === -1 ? "" : chars.slice(first, chars.findLastIndex((char) => !LINE_MARKS.has(char)) + 1).join("");
|
|
182
|
+
};
|
|
183
|
+
/** A line that labels what is attached: the label and a colon (Attachment: quote.pdf), or the label alone (### Enclosures, 【添付資料】). */
|
|
184
|
+
const labelsAttachment = (line, labels) => {
|
|
185
|
+
const bare = withoutMarks(line).toLowerCase();
|
|
186
|
+
return labels.some((label) => {
|
|
187
|
+
const folded = label.toLowerCase();
|
|
188
|
+
return bare === folded || (bare.startsWith(folded) && /^\s*[::]/u.test(bare.slice(folded.length)));
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
/** An attachment shown: a line that labels it, a file name with a listed extension, or the archive's note. text is the writer's own (no quoted reply). */
|
|
192
|
+
export const showsAttachment = (text, labels, extensions, notes) => {
|
|
193
|
+
const labelled = text.split("\n").some((line) => labelsAttachment(line, labels));
|
|
194
|
+
const fileName = new RegExp(`[\\w\\-ぁ-んァ-ヶ一-龠]\\.(?:${extensions.map(escapeRegExp).join("|")})\\b`, "iu");
|
|
195
|
+
return labelled || (extensions.length > 0 && fileName.test(text)) || notes.some((note) => text.includes(note));
|
|
196
|
+
};
|
|
197
|
+
/** The source without someone else's words: a quoted reply's spans blanked and its "> " lines dropped. An old message's attachment is not this one's. */
|
|
198
|
+
export const ownText = (source, replyQuotes) => {
|
|
199
|
+
const pieces = [];
|
|
200
|
+
const cursor = { at: 0 };
|
|
201
|
+
replyQuotes
|
|
202
|
+
.toSorted((left, right) => left.start - right.start)
|
|
203
|
+
.forEach((span) => {
|
|
204
|
+
const from = Math.max(span.start, cursor.at);
|
|
205
|
+
pieces.push(source.slice(cursor.at, from), " ".repeat(Math.max(0, span.end - from)));
|
|
206
|
+
cursor.at = Math.max(cursor.at, span.end);
|
|
207
|
+
});
|
|
208
|
+
pieces.push(source.slice(cursor.at));
|
|
209
|
+
return pieces
|
|
210
|
+
.join("")
|
|
211
|
+
.split("\n")
|
|
212
|
+
.filter((line) => !line.trimStart().startsWith(">"))
|
|
213
|
+
.join("\n");
|
|
214
|
+
};
|
|
215
|
+
export const attachmentMissing = (doc) => {
|
|
216
|
+
const lines = bodyLines(doc.source, doc.prose ?? doc.source, doc.replyQuotes ?? []);
|
|
217
|
+
const mention = firstMention(lines, patternsOf(doc, "attachment-mention"), patternsOf(doc, "attachment-not-mention"));
|
|
218
|
+
if (mention === undefined)
|
|
219
|
+
return [];
|
|
220
|
+
const extensions = patternsOf(doc, "attachment-file-extension").map((extension) => extension.replace(/^\./u, ""));
|
|
221
|
+
if (showsAttachment(ownText(doc.source, doc.replyQuotes ?? []), patternsOf(doc, "attachment-line"), extensions, patternsOf(doc, "email-attachment-note")))
|
|
222
|
+
return [];
|
|
223
|
+
return [
|
|
224
|
+
{
|
|
225
|
+
rule: "attachment-not-attached",
|
|
226
|
+
severity: "warning",
|
|
227
|
+
line: 0,
|
|
228
|
+
column: 0,
|
|
229
|
+
quote: quoteAt(doc.source, mention),
|
|
230
|
+
values: { offset: mention },
|
|
231
|
+
},
|
|
232
|
+
];
|
|
233
|
+
};
|
|
234
|
+
//# sourceMappingURL=email-letter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-letter.js","sourceRoot":"","sources":["../../src/detectors/email-letter.ts"],"names":[],"mappings":"AAAA,qHAAqH;AACrH,2GAA2G;AAC3G,mHAAmH;AACnH,4GAA4G;AAC5G,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,iHAAiH;AACjH,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,+HAA+H;AAC/H,MAAM,aAAa,GAAG,EAAE,CAAC;AAKzB,MAAM,UAAU,GAAG,CAAC,GAAkB,EAAE,EAAU,EAAY,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAExH,MAAM,WAAW,GAAG,YAAY,CAAC;AACjC,MAAM,MAAM,GAAG,QAAQ,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,KAAwB,EAAW,EAAE;IACzE,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IACrC,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EA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CAAC;IACZ,OAAO;QACL;YACE,IAAI,EAAE,yBAAyB;YAC/B,QAAQ,EAAE,SAAS;YACnB,IAAI,EAAE,CAAC;YACP,MAAM,EAAE,CAAC;YACT,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;YACnC,MAAM,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;SAC5B;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Detector } from "../plugin.ts";
|
|
2
|
+
/** 合わない注 1 つ。missing は印に注が無い、unused は注に印が無い。label は書いたままの印([^1]、※1)。 */
|
|
3
|
+
export type NoteSlip = {
|
|
4
|
+
readonly offset: number;
|
|
5
|
+
readonly label: string;
|
|
6
|
+
readonly reason: "missing" | "unused";
|
|
7
|
+
};
|
|
8
|
+
/** 文字列の中の、注の無い印と印の無い注。 */
|
|
9
|
+
export declare const noteSlips: (text: string, words: readonly string[]) => NoteSlip[];
|
|
10
|
+
export declare const footnoteMismatch: Detector;
|
|
11
|
+
//# sourceMappingURL=footnote-mismatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"footnote-mismatch.d.ts","sourceRoot":"","sources":["../../src/detectors/footnote-mismatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAW,MAAM,cAAc,CAAC;AAMtD,wEAAwE;AACxE,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAA;CAAE,CAAC;AA8ClH,0BAA0B;AAC1B,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,EAAE,OAAO,SAAS,MAAM,EAAE,KAAG,QAAQ,EAG1E,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,QAY9B,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { escapeRegExp } from "../orthography.js";
|
|
2
|
+
import { quoteAround } from "./quote-around.js";
|
|
3
|
+
const MARKDOWN = "markdown";
|
|
4
|
+
const FULLWIDTH_OFFSET = 0xfee0;
|
|
5
|
+
/** 行の頭から印までに来てよいもの(字下げ、箇条書きの印、開き括弧)。 */
|
|
6
|
+
const NOTE_LINE_HEAD = /^[ \t]*(?:[-*+][ \t]+)?[((]?$/u;
|
|
7
|
+
const halfWidth = (text) => text.replace(/[0-9]/gu, (char) => String.fromCharCode(char.charCodeAt(0) - FULLWIDTH_OFFSET));
|
|
8
|
+
const lineHeadOf = (text, offset) => text.slice(text.lastIndexOf("\n", offset - 1) + 1, offset);
|
|
9
|
+
/** Markdown の脚注。名前は大文字と小文字を区別しない(CommonMark の参照と同じ)。 */
|
|
10
|
+
const markdownMarks = (text) => [...text.matchAll(/\[\^(?<key>[^\]\s]+)\](?<colon>:)?/gu)].map((match) => {
|
|
11
|
+
const note = match.groups?.["colon"] !== undefined && /^[ \t]{0,3}$/u.test(lineHeadOf(text, match.index));
|
|
12
|
+
return { offset: match.index, label: `[^${match.groups?.["key"] ?? ""}]`, kind: MARKDOWN, key: (match.groups?.["key"] ?? "").toLowerCase(), note };
|
|
13
|
+
});
|
|
14
|
+
/** 印と一桁か二桁の番号。後ろに数字や小数が続けば年や数(※2018年度、※1.2倍)で、注の番号ではない。 */
|
|
15
|
+
const wordMarks = (text, mark) => [...text.matchAll(new RegExp(`${escapeRegExp(mark)}(?<key>[0-90-9]{1,2})(?![0-90-9]|[..,,][0-90-9])`, "gu"))].map((match) => ({
|
|
16
|
+
offset: match.index,
|
|
17
|
+
label: match[0],
|
|
18
|
+
kind: mark,
|
|
19
|
+
key: halfWidth(match.groups?.["key"] ?? ""),
|
|
20
|
+
note: NOTE_LINE_HEAD.test(lineHeadOf(text, match.index)),
|
|
21
|
+
}));
|
|
22
|
+
/** 一つの種類の印のうち、合わないもの。印の語(※)は、その種類の注が一つも無ければ注を別に置いた文書と読んで言わない。 */
|
|
23
|
+
const slipsOfKind = (marks, kind) => {
|
|
24
|
+
const ofKind = marks.filter((mark) => mark.kind === kind);
|
|
25
|
+
const notes = new Set(ofKind.filter((mark) => mark.note).map((mark) => mark.key));
|
|
26
|
+
const referenced = new Set(ofKind.filter((mark) => !mark.note).map((mark) => mark.key));
|
|
27
|
+
if (notes.size === 0 && kind !== MARKDOWN)
|
|
28
|
+
return [];
|
|
29
|
+
const missing = ofKind
|
|
30
|
+
.filter((mark) => !mark.note && !notes.has(mark.key))
|
|
31
|
+
.map((mark) => ({ offset: mark.offset, label: mark.label, reason: "missing" }));
|
|
32
|
+
const unused = ofKind
|
|
33
|
+
.filter((mark) => mark.note && !referenced.has(mark.key))
|
|
34
|
+
.map((mark) => ({ offset: mark.offset, label: mark.label, reason: "unused" }));
|
|
35
|
+
return [...missing, ...unused];
|
|
36
|
+
};
|
|
37
|
+
/** 文字列の中の、注の無い印と印の無い注。 */
|
|
38
|
+
export const noteSlips = (text, words) => {
|
|
39
|
+
const marks = [...markdownMarks(text), ...words.flatMap((word) => wordMarks(text, word))];
|
|
40
|
+
return [...new Set(marks.map((mark) => mark.kind))].flatMap((kind) => slipsOfKind(marks, kind)).toSorted((left, right) => left.offset - right.offset);
|
|
41
|
+
};
|
|
42
|
+
export const footnoteMismatch = (doc) => {
|
|
43
|
+
const text = doc.prose ?? doc.source;
|
|
44
|
+
const words = (doc.lexicons["note-mark"] ?? []).map((entry) => entry.pattern);
|
|
45
|
+
return noteSlips(text, words).map((slip) => ({
|
|
46
|
+
rule: "",
|
|
47
|
+
severity: "warning",
|
|
48
|
+
line: 0,
|
|
49
|
+
column: 0,
|
|
50
|
+
quote: quoteAround(text, slip.offset, slip.offset + slip.label.length),
|
|
51
|
+
values: { label: slip.label, offset: slip.offset },
|
|
52
|
+
variant: slip.reason,
|
|
53
|
+
}));
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=footnote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方のものと、いちばん多い書き方の例。 */
|
|
2
|
+
export type FormMinority<T> = {
|
|
3
|
+
readonly odd: readonly T[];
|
|
4
|
+
readonly usual: T;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* いちばん多い書き方と違うもの。少ないほうが limit パーセントを超えれば使い分けている文書と読んで言わない。
|
|
8
|
+
* いちばん多い書き方が同じ数で並べば、どちらにも立たない。
|
|
9
|
+
*/
|
|
10
|
+
export declare const formMinority: <T extends {
|
|
11
|
+
readonly form: string;
|
|
12
|
+
}>(items: readonly T[], limit: number) => FormMinority<T> | undefined;
|
|
13
|
+
//# sourceMappingURL=form-minority.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-minority.d.ts","sourceRoot":"","sources":["../../src/detectors/form-minority.ts"],"names":[],"mappings":"AAEA,iCAAiC;AACjC,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,EAAE,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC;AAIhF;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,OAAO,SAAS,CAAC,EAAE,EAAE,OAAO,MAAM,KAAG,YAAY,CAAC,CAAC,CAAC,GAAG,SASxH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// 一つの文書の中で、同じものを何通りかに書いたときの少ないほう。どの書き方が正しいかは決めない。
|
|
2
|
+
const PERCENT = 100;
|
|
3
|
+
/**
|
|
4
|
+
* いちばん多い書き方と違うもの。少ないほうが limit パーセントを超えれば使い分けている文書と読んで言わない。
|
|
5
|
+
* いちばん多い書き方が同じ数で並べば、どちらにも立たない。
|
|
6
|
+
*/
|
|
7
|
+
export const formMinority = (items, limit) => {
|
|
8
|
+
const counts = new Map();
|
|
9
|
+
items.forEach((item) => counts.set(item.form, (counts.get(item.form) ?? 0) + 1));
|
|
10
|
+
const [top, second] = [...counts].toSorted((left, right) => right[1] - left[1]);
|
|
11
|
+
if (top === undefined || second === undefined || top[1] === second[1])
|
|
12
|
+
return undefined;
|
|
13
|
+
const odd = items.filter((item) => item.form !== top[0]);
|
|
14
|
+
const usual = items.find((item) => item.form === top[0]);
|
|
15
|
+
if (usual === undefined || odd.length * PERCENT > items.length * limit)
|
|
16
|
+
return undefined;
|
|
17
|
+
return { odd, usual };
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=form-minority.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-minority.js","sourceRoot":"","sources":["../../src/detectors/form-minority.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAKlD,MAAM,OAAO,GAAG,GAAG,CAAC;AAEpB;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAsC,KAAmB,EAAE,KAAa,EAA+B,EAAE;IACnI,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACjF,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAChF,IAAI,GAAG,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IACxF,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,IAAI,KAAK,KAAK,SAAS,IAAI,GAAG,CAAC,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC,MAAM,GAAG,KAAK;QAAE,OAAO,SAAS,CAAC;IACzF,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;AACxB,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Detector } from "../plugin.ts";
|
|
2
|
+
/** The mark a heading ends with, "" for none, or undefined when its last full stop belongs to its words. */
|
|
3
|
+
export declare const endMarkOf: (heading: string, words?: readonly string[]) => string | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Headings that end with a colon or a full stop where most headings of the same depth do not, or the other way round. Headings
|
|
6
|
+
* of one depth are one kind of heading; a depth of labels ("Optional:") is its own way. The page title (one top-level heading
|
|
7
|
+
* that opens the document) is a name and is not compared.
|
|
8
|
+
*/
|
|
9
|
+
export declare const headingEndMark: Detector;
|
|
10
|
+
//# sourceMappingURL=heading-end-mark.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heading-end-mark.d.ts","sourceRoot":"","sources":["../../src/detectors/heading-end-mark.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAyC,MAAM,cAAc,CAAC;AAgCpF,4GAA4G;AAC5G,eAAO,MAAM,SAAS,GAAI,SAAS,MAAM,EAAE,QAAO,SAAS,MAAM,EAAO,KAAG,MAAM,GAAG,SAInF,CAAC;AAoBF;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,QAmB5B,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { findingAt, writtenHeadings } from "./markup-finding.js";
|
|
2
|
+
import { pageTitleOf } from "./heading-case.js";
|
|
3
|
+
import { minorityWithin } from "../orthography.js";
|
|
4
|
+
/** A mark a heading may end with or go without: a colon or a full stop, in either width. A question mark belongs to the words. */
|
|
5
|
+
const END_MARK = /[::.。]$/u;
|
|
6
|
+
/** An ellipsis: the full stops are the words trailing off. */
|
|
7
|
+
const ELLIPSIS = /(?:\.\.\.|…)$/u;
|
|
8
|
+
/** Emphasis closed at the very end (`## **Note:**`): the mark the reader sees is the one before it. */
|
|
9
|
+
const EMPHASIS_MARKS = new Set(["*", "_"]);
|
|
10
|
+
const withoutClosingEmphasis = (text) => {
|
|
11
|
+
const kept = [...text];
|
|
12
|
+
while (EMPHASIS_MARKS.has(kept.at(-1) ?? ""))
|
|
13
|
+
kept.pop();
|
|
14
|
+
return kept.join("");
|
|
15
|
+
};
|
|
16
|
+
const LETTER = /\p{L}/u;
|
|
17
|
+
/** Past this share, both ways are in use on purpose, and neither is the odd one. */
|
|
18
|
+
const MINORITY_PERCENT = 25;
|
|
19
|
+
/** Fewer section headings than this, and the majority is not yet a habit. */
|
|
20
|
+
const MIN_HEADINGS = 4;
|
|
21
|
+
/** Whether the heading's last word is one that ends in a full stop of its own (etc., Inc., from the lexicon). */
|
|
22
|
+
const endsWithWord = (shown, words) => words.some((word) => shown.endsWith(word) && !LETTER.test(shown.charAt(shown.length - word.length - 1)));
|
|
23
|
+
/** The mark a heading ends with, "" for none, or undefined when its last full stop belongs to its words. */
|
|
24
|
+
export const endMarkOf = (heading, words = []) => {
|
|
25
|
+
const shown = withoutClosingEmphasis(heading.trim()).trimEnd();
|
|
26
|
+
if (ELLIPSIS.test(shown) || endsWithWord(shown, words))
|
|
27
|
+
return undefined;
|
|
28
|
+
return END_MARK.exec(shown)?.[0] ?? "";
|
|
29
|
+
};
|
|
30
|
+
/** The odd ones among headings of one depth, each with the usual side's first heading and count. */
|
|
31
|
+
const oddAtDepth = (doc, judged) => {
|
|
32
|
+
if (judged.length < MIN_HEADINGS)
|
|
33
|
+
return [];
|
|
34
|
+
const odd = minorityWithin(judged, (entry) => entry.mark !== "", MINORITY_PERCENT);
|
|
35
|
+
const usual = judged.filter((entry) => !odd.includes(entry));
|
|
36
|
+
const example = usual[0]?.heading.text.trim() ?? "";
|
|
37
|
+
return odd.map((entry) => findingAt(doc, entry.heading, { heading: entry.heading.text.trim(), mark: entry.mark, example, count: usual.length }, entry.mark === "" ? "bare" : "marked"));
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Headings that end with a colon or a full stop where most headings of the same depth do not, or the other way round. Headings
|
|
41
|
+
* of one depth are one kind of heading; a depth of labels ("Optional:") is its own way. The page title (one top-level heading
|
|
42
|
+
* that opens the document) is a name and is not compared.
|
|
43
|
+
*/
|
|
44
|
+
export const headingEndMark = (doc, options) => {
|
|
45
|
+
const words = (options.lexicon ?? []).map((entry) => entry.pattern);
|
|
46
|
+
const headings = writtenHeadings(doc);
|
|
47
|
+
const title = pageTitleOf(headings);
|
|
48
|
+
const judged = headings
|
|
49
|
+
.filter((heading) => heading !== title)
|
|
50
|
+
.flatMap((heading) => {
|
|
51
|
+
const mark = endMarkOf(heading.text, words);
|
|
52
|
+
return mark === undefined ? [] : [{ heading, mark }];
|
|
53
|
+
});
|
|
54
|
+
const depths = [...new Set(judged.map((entry) => entry.heading.depth))];
|
|
55
|
+
return depths
|
|
56
|
+
.flatMap((depth) => oddAtDepth(doc, judged.filter((entry) => entry.heading.depth === depth)))
|
|
57
|
+
.toSorted((left, right) => Number(left.values["offset"]) - Number(right.values["offset"]));
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=heading-end-mark.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heading-end-mark.js","sourceRoot":"","sources":["../../src/detectors/heading-end-mark.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,E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,CAAC;AAC/F,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Detector, ProseDocument } from "../plugin.ts";
|
|
2
|
+
/** 日付を読むのに要る語。months は一月から順の月の名前と略した名前、units は年・月・日の単位、eras は元号。 */
|
|
3
|
+
export type CalendarWords = {
|
|
4
|
+
readonly months: readonly string[];
|
|
5
|
+
readonly units: readonly string[];
|
|
6
|
+
readonly eras: readonly string[];
|
|
7
|
+
};
|
|
8
|
+
/** 暦に無い日付 1 つ。reason は、月が無い(month)、その月にその日が無い(day)、うるう年でない年の 2 月 29 日(leap)。 */
|
|
9
|
+
export type ImpossibleDate = {
|
|
10
|
+
readonly offset: number;
|
|
11
|
+
readonly written: string;
|
|
12
|
+
readonly reason: "month" | "day" | "leap";
|
|
13
|
+
readonly month: number;
|
|
14
|
+
readonly days: number;
|
|
15
|
+
};
|
|
16
|
+
/** 文字列の中の、暦に無い日付。同じ所に二つの形が当たれば、先に見つけたほうだけ。 */
|
|
17
|
+
export declare const impossibleDates: (text: string, words: CalendarWords) => ImpossibleDate[];
|
|
18
|
+
export declare const calendarWordsOf: (doc: ProseDocument) => CalendarWords;
|
|
19
|
+
export declare const impossibleDate: Detector;
|
|
20
|
+
//# sourceMappingURL=impossible-date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"impossible-date.d.ts","sourceRoot":"","sources":["../../src/detectors/impossible-date.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAW,aAAa,EAAE,MAAM,cAAc,CAAC;AAOrE,oEAAoE;AACpE,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAExI,gFAAgF;AAChF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;IAC1C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AA6FF,8CAA8C;AAC9C,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,EAAE,OAAO,aAAa,KAAG,cAAc,EAQlF,CAAC;AAIF,eAAO,MAAM,eAAe,GAAI,KAAK,aAAa,KAAG,aAInD,CAAC;AAEH,eAAO,MAAM,cAAc,EAAE,QAW5B,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { escapeRegExp } from "../orthography.js";
|
|
2
|
+
import { quoteAround } from "./quote-around.js";
|
|
3
|
+
const DIGIT = "[0-90-9]";
|
|
4
|
+
const NOT_AFTER_NUMBER = "(?<![\\w/.\\-0-9])";
|
|
5
|
+
/** 日付の後ろに来ない字。ただし日時(2023-02-29T10:00)の T は日付の終わり。 */
|
|
6
|
+
const NOT_BEFORE_NUMBER = "(?:(?=T\\d)|(?![\\w//\\-0-9]|\\.\\w))";
|
|
7
|
+
const MONTHS_IN_YEAR = 12;
|
|
8
|
+
const LONGEST_MONTH = 31;
|
|
9
|
+
const FEBRUARY = 2;
|
|
10
|
+
const LEAP_DAY = 29;
|
|
11
|
+
const FIRST_CALENDAR_YEAR = 1000;
|
|
12
|
+
const DAYS_IN_MONTH = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
13
|
+
const FULLWIDTH_OFFSET = 0xfee0;
|
|
14
|
+
const halfWidth = (text) => text.replace(/[0-9]/gu, (char) => String.fromCharCode(char.charCodeAt(0) - FULLWIDTH_OFFSET));
|
|
15
|
+
const isLeapYear = (year) => (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
|
|
16
|
+
/** 年の数。元号の年や 4 桁でない年は、うるう年を決められないので undefined。 */
|
|
17
|
+
const yearOf = (groups) => {
|
|
18
|
+
const written = groups["y"];
|
|
19
|
+
if (written === undefined || groups["era"] !== undefined)
|
|
20
|
+
return undefined;
|
|
21
|
+
const year = Number(halfWidth(written));
|
|
22
|
+
return year >= FIRST_CALENDAR_YEAR ? year : undefined;
|
|
23
|
+
};
|
|
24
|
+
/** 一月から順の月の名前(初めの十二)で、略した名前(Sept、Feb.)が何月か。 */
|
|
25
|
+
const monthNamed = (months, written) => {
|
|
26
|
+
const name = written.replace(/\.$/u, "");
|
|
27
|
+
return months.slice(0, MONTHS_IN_YEAR).findIndex((full) => full.startsWith(name)) + 1;
|
|
28
|
+
};
|
|
29
|
+
const monthOf = (groups, months) => groups["name"] === undefined ? Number(halfWidth(groups["m"] ?? "")) : monthNamed(months, groups["name"]);
|
|
30
|
+
/** その月の日数。2 月は、年が分かってうるう年でなければ 28 日、分からなければ 29 日。 */
|
|
31
|
+
const daysIn = (month, year) => month === FEBRUARY && year !== undefined && !isLeapYear(year) ? LEAP_DAY - 1 : (DAYS_IN_MONTH[month - 1] ?? LONGEST_MONTH);
|
|
32
|
+
const problemOf = (month, day, year, strict) => {
|
|
33
|
+
if (month < 1 || month > MONTHS_IN_YEAR)
|
|
34
|
+
return strict ? "month" : undefined;
|
|
35
|
+
if (day < 1 || day > LONGEST_MONTH)
|
|
36
|
+
return strict ? "day" : undefined;
|
|
37
|
+
if (day <= daysIn(month, year))
|
|
38
|
+
return undefined;
|
|
39
|
+
return month === FEBRUARY && day === LEAP_DAY ? "leap" : "day";
|
|
40
|
+
};
|
|
41
|
+
const shapesOf = (words) => {
|
|
42
|
+
const [yearUnit, monthUnit, dayUnit] = words.units.map(escapeRegExp);
|
|
43
|
+
const names = words.months.map(escapeRegExp).join("|");
|
|
44
|
+
const eras = words.eras.map(escapeRegExp).join("|");
|
|
45
|
+
const era = eras === "" ? "" : `(?:(?<era>${eras})\\s?)?`;
|
|
46
|
+
const unitShape = yearUnit === undefined || monthUnit === undefined || dayUnit === undefined
|
|
47
|
+
? []
|
|
48
|
+
: [
|
|
49
|
+
{
|
|
50
|
+
pattern: new RegExp(`(?<!${DIGIT})${era}(?:(?<y>${DIGIT}{1,4}|元)${yearUnit}\\s?)?(?<m>${DIGIT}{1,2})${monthUnit}\\s?(?<d>${DIGIT}{1,2})${dayUnit}`, "gu"),
|
|
51
|
+
strict: true,
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
const nameShapes = names === ""
|
|
55
|
+
? []
|
|
56
|
+
: [
|
|
57
|
+
{ pattern: new RegExp(`\\b(?<name>${names})\\.?\\s(?<d>\\d{1,2})(?:st|nd|rd|th)?(?![\\d:])(?:,?\\s(?<y>\\d{4})\\b)?`, "gu"), strict: false },
|
|
58
|
+
{ pattern: new RegExp(`(?<![\\d.,])\\b(?<d>\\d{1,2})(?:st|nd|rd|th)?\\s(?<name>${names})\\b\\.?(?:,?\\s(?<y>\\d{4})\\b)?`, "gu"), strict: false },
|
|
59
|
+
];
|
|
60
|
+
return [
|
|
61
|
+
{ pattern: new RegExp(`${NOT_AFTER_NUMBER}(?<y>\\d{4})-(?<m>\\d{1,2})-(?<d>\\d{1,2})${NOT_BEFORE_NUMBER}`, "gu"), strict: false },
|
|
62
|
+
{ pattern: new RegExp(`${NOT_AFTER_NUMBER}(?<y>\\d{4})[//](?<m>\\d{1,2})[//](?<d>\\d{1,2})${NOT_BEFORE_NUMBER}`, "gu"), strict: false },
|
|
63
|
+
...unitShape,
|
|
64
|
+
...nameShapes,
|
|
65
|
+
];
|
|
66
|
+
};
|
|
67
|
+
const impossibleIn = (text, shape, months) => [...text.matchAll(shape.pattern)].flatMap((match) => {
|
|
68
|
+
const groups = match.groups ?? {};
|
|
69
|
+
const month = monthOf(groups, months);
|
|
70
|
+
const year = yearOf(groups);
|
|
71
|
+
const reason = problemOf(month, Number(halfWidth(groups["d"] ?? "")), year, shape.strict);
|
|
72
|
+
if (reason === undefined)
|
|
73
|
+
return [];
|
|
74
|
+
return [{ offset: match.index, written: match[0].trim(), reason, month, days: daysIn(month, year) }];
|
|
75
|
+
});
|
|
76
|
+
/** 文字列の中の、暦に無い日付。同じ所に二つの形が当たれば、先に見つけたほうだけ。 */
|
|
77
|
+
export const impossibleDates = (text, words) => {
|
|
78
|
+
const byOffset = new Map();
|
|
79
|
+
shapesOf(words)
|
|
80
|
+
.flatMap((shape) => impossibleIn(text, shape, words.months))
|
|
81
|
+
.forEach((found) => {
|
|
82
|
+
if (!byOffset.has(found.offset))
|
|
83
|
+
byOffset.set(found.offset, found);
|
|
84
|
+
});
|
|
85
|
+
return [...byOffset.values()].toSorted((left, right) => left.offset - right.offset);
|
|
86
|
+
};
|
|
87
|
+
const patternsOf = (doc, id) => (doc.lexicons[id] ?? []).map((entry) => entry.pattern);
|
|
88
|
+
export const calendarWordsOf = (doc) => ({
|
|
89
|
+
months: patternsOf(doc, "month-name"),
|
|
90
|
+
units: patternsOf(doc, "date-time-unit").slice(0, 3),
|
|
91
|
+
eras: patternsOf(doc, "calendar-era"),
|
|
92
|
+
});
|
|
93
|
+
export const impossibleDate = (doc) => {
|
|
94
|
+
const text = doc.prose ?? doc.source;
|
|
95
|
+
return impossibleDates(text, calendarWordsOf(doc)).map((found) => ({
|
|
96
|
+
rule: "",
|
|
97
|
+
severity: "warning",
|
|
98
|
+
line: 0,
|
|
99
|
+
column: 0,
|
|
100
|
+
quote: quoteAround(text, found.offset, found.offset + found.written.length),
|
|
101
|
+
values: { written: found.written, month: found.month, days: found.days, offset: found.offset },
|
|
102
|
+
variant: found.reason,
|
|
103
|
+
}));
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=impossible-date.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"impossible-date.js","sourceRoot":"","sources":["../../src/detectors/impossible-date.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,C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