chaffjs 0.28.0 → 0.30.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/dist/ai-score/of-document.d.ts.map +1 -1
- package/dist/ai-score/of-document.js +23 -14
- package/dist/ai-score/of-document.js.map +1 -1
- package/dist/ai-score/render.d.ts.map +1 -1
- package/dist/ai-score/render.js +13 -4
- package/dist/ai-score/render.js.map +1 -1
- package/dist/ai-score/score.d.ts +16 -1
- package/dist/ai-score/score.d.ts.map +1 -1
- package/dist/ai-score/score.js +15 -3
- package/dist/ai-score/score.js.map +1 -1
- package/dist/ai-score/signals.d.ts +2 -4
- package/dist/ai-score/signals.d.ts.map +1 -1
- package/dist/ai-score/signals.js +11 -2
- package/dist/ai-score/signals.js.map +1 -1
- package/dist/ai-score/text.d.ts +2 -0
- package/dist/ai-score/text.d.ts.map +1 -1
- package/dist/ai-score/text.js +4 -2
- package/dist/ai-score/text.js.map +1 -1
- package/dist/announced-count.d.ts +2 -0
- package/dist/announced-count.d.ts.map +1 -1
- package/dist/announced-count.js +14 -7
- package/dist/announced-count.js.map +1 -1
- package/dist/check-source.d.ts +3 -1
- package/dist/check-source.d.ts.map +1 -1
- package/dist/check-source.js +3 -1
- package/dist/check-source.js.map +1 -1
- package/dist/cli-text.d.ts.map +1 -1
- package/dist/cli-text.js +38 -16
- package/dist/cli-text.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/cite-claims.d.ts +36 -0
- package/dist/commands/cite-claims.d.ts.map +1 -0
- package/dist/commands/cite-claims.js +81 -0
- package/dist/commands/cite-claims.js.map +1 -0
- package/dist/commands/cite-page.d.ts +14 -0
- package/dist/commands/cite-page.d.ts.map +1 -0
- package/dist/commands/cite-page.js +47 -0
- package/dist/commands/cite-page.js.map +1 -0
- package/dist/commands/cite-scaffold.d.ts +16 -0
- package/dist/commands/cite-scaffold.d.ts.map +1 -0
- package/dist/commands/cite-scaffold.js +21 -0
- package/dist/commands/cite-scaffold.js.map +1 -0
- package/dist/commands/cite.d.ts +3 -12
- package/dist/commands/cite.d.ts.map +1 -1
- package/dist/commands/cite.js +110 -51
- package/dist/commands/cite.js.map +1 -1
- package/dist/company-names.d.ts +34 -0
- package/dist/company-names.d.ts.map +1 -0
- package/dist/company-names.js +158 -0
- package/dist/company-names.js.map +1 -0
- package/dist/default-values.d.ts +17 -0
- package/dist/default-values.d.ts.map +1 -0
- package/dist/default-values.js +134 -0
- package/dist/default-values.js.map +1 -0
- package/dist/deprecated-use.d.ts +17 -0
- package/dist/deprecated-use.d.ts.map +1 -0
- package/dist/deprecated-use.js +95 -0
- package/dist/deprecated-use.js.map +1 -0
- package/dist/derived/session-hours.d.ts +26 -0
- package/dist/derived/session-hours.d.ts.map +1 -0
- package/dist/derived/session-hours.js +29 -0
- package/dist/derived/session-hours.js.map +1 -0
- package/dist/derived/stays.d.ts +43 -0
- package/dist/derived/stays.d.ts.map +1 -0
- package/dist/derived/stays.js +105 -0
- package/dist/derived/stays.js.map +1 -0
- package/dist/derived/time-lengths.d.ts +37 -0
- package/dist/derived/time-lengths.d.ts.map +1 -0
- package/dist/derived/time-lengths.js +168 -0
- package/dist/derived/time-lengths.js.map +1 -0
- package/dist/derived/unit-counts.d.ts +7 -0
- package/dist/derived/unit-counts.d.ts.map +1 -0
- package/dist/derived/unit-counts.js +13 -0
- package/dist/derived/unit-counts.js.map +1 -0
- package/dist/derived/working-hours.d.ts +36 -0
- package/dist/derived/working-hours.d.ts.map +1 -0
- package/dist/derived/working-hours.js +55 -0
- package/dist/derived/working-hours.js.map +1 -0
- package/dist/detectors/acronym-context.d.ts +2 -2
- package/dist/detectors/acronym-context.d.ts.map +1 -1
- package/dist/detectors/acronym-context.js +6 -0
- package/dist/detectors/acronym-context.js.map +1 -1
- package/dist/detectors/acronym-expansion.d.ts +1 -1
- package/dist/detectors/acronym-expansion.d.ts.map +1 -1
- package/dist/detectors/acronym-expansion.js +46 -2
- package/dist/detectors/acronym-expansion.js.map +1 -1
- package/dist/detectors/address-word.d.ts +3 -0
- package/dist/detectors/address-word.d.ts.map +1 -0
- package/dist/detectors/address-word.js +7 -0
- package/dist/detectors/address-word.js.map +1 -0
- package/dist/detectors/agreement-slip.d.ts.map +1 -1
- package/dist/detectors/agreement-slip.js +4 -1
- package/dist/detectors/agreement-slip.js.map +1 -1
- package/dist/detectors/ai-phrasing.d.ts +0 -4
- package/dist/detectors/ai-phrasing.d.ts.map +1 -1
- package/dist/detectors/ai-phrasing.js +5 -1
- package/dist/detectors/ai-phrasing.js.map +1 -1
- package/dist/detectors/amount-range.d.ts +3 -0
- package/dist/detectors/amount-range.d.ts.map +1 -0
- package/dist/detectors/amount-range.js +38 -0
- package/dist/detectors/amount-range.js.map +1 -0
- package/dist/detectors/amount-scale.d.ts +6 -1
- package/dist/detectors/amount-scale.d.ts.map +1 -1
- package/dist/detectors/amount-scale.js +33 -9
- package/dist/detectors/amount-scale.js.map +1 -1
- package/dist/detectors/announced-count.d.ts +1 -1
- package/dist/detectors/announced-count.d.ts.map +1 -1
- package/dist/detectors/announced-count.js +18 -3
- package/dist/detectors/announced-count.js.map +1 -1
- package/dist/detectors/bare-comparative.d.ts.map +1 -1
- package/dist/detectors/bare-comparative.js +4 -1
- package/dist/detectors/bare-comparative.js.map +1 -1
- package/dist/detectors/block-quotation.d.ts +13 -0
- package/dist/detectors/block-quotation.d.ts.map +1 -0
- package/dist/detectors/block-quotation.js +86 -0
- package/dist/detectors/block-quotation.js.map +1 -0
- package/dist/detectors/bracket-label.d.ts +10 -0
- package/dist/detectors/bracket-label.d.ts.map +1 -0
- package/dist/detectors/bracket-label.js +51 -0
- package/dist/detectors/bracket-label.js.map +1 -0
- package/dist/detectors/capitalised-term.d.ts +44 -0
- package/dist/detectors/capitalised-term.d.ts.map +1 -0
- package/dist/detectors/capitalised-term.js +101 -0
- package/dist/detectors/capitalised-term.js.map +1 -0
- package/dist/detectors/citation-entry.d.ts +5 -0
- package/dist/detectors/citation-entry.d.ts.map +1 -1
- package/dist/detectors/citation-entry.js +19 -5
- package/dist/detectors/citation-entry.js.map +1 -1
- package/dist/detectors/code-before.d.ts +6 -0
- package/dist/detectors/code-before.d.ts.map +1 -0
- package/dist/detectors/code-before.js +15 -0
- package/dist/detectors/code-before.js.map +1 -0
- package/dist/detectors/connective-hierarchy.d.ts +11 -1
- package/dist/detectors/connective-hierarchy.d.ts.map +1 -1
- package/dist/detectors/connective-hierarchy.js +26 -6
- package/dist/detectors/connective-hierarchy.js.map +1 -1
- package/dist/detectors/currency-notation.d.ts.map +1 -1
- package/dist/detectors/currency-notation.js +2 -1
- package/dist/detectors/currency-notation.js.map +1 -1
- package/dist/detectors/date-outside-period.d.ts +4 -0
- package/dist/detectors/date-outside-period.d.ts.map +1 -0
- package/dist/detectors/date-outside-period.js +37 -0
- package/dist/detectors/date-outside-period.js.map +1 -0
- package/dist/detectors/default-values.d.ts +3 -0
- package/dist/detectors/default-values.d.ts.map +1 -0
- package/dist/detectors/default-values.js +14 -0
- package/dist/detectors/default-values.js.map +1 -0
- package/dist/detectors/defined-term-form.d.ts +6 -2
- package/dist/detectors/defined-term-form.d.ts.map +1 -1
- package/dist/detectors/defined-term-form.js +72 -12
- 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 +8 -1
- package/dist/detectors/definition-use.js.map +1 -1
- package/dist/detectors/deprecated-use.d.ts +3 -0
- package/dist/detectors/deprecated-use.d.ts.map +1 -0
- package/dist/detectors/deprecated-use.js +14 -0
- package/dist/detectors/deprecated-use.js.map +1 -0
- package/dist/detectors/derived-numbers.d.ts +3 -1
- package/dist/detectors/derived-numbers.d.ts.map +1 -1
- package/dist/detectors/derived-numbers.js +119 -10
- package/dist/detectors/derived-numbers.js.map +1 -1
- package/dist/detectors/document-shape.d.ts +1 -0
- 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/due-date.d.ts +3 -0
- package/dist/detectors/due-date.d.ts.map +1 -0
- package/dist/detectors/due-date.js +38 -0
- package/dist/detectors/due-date.js.map +1 -0
- package/dist/detectors/en-shape.d.ts.map +1 -1
- package/dist/detectors/en-shape.js +17 -9
- package/dist/detectors/en-shape.js.map +1 -1
- package/dist/detectors/fact-consistency.d.ts.map +1 -1
- package/dist/detectors/fact-consistency.js +76 -2
- package/dist/detectors/fact-consistency.js.map +1 -1
- package/dist/detectors/heading-echo.d.ts.map +1 -1
- package/dist/detectors/heading-echo.js +10 -1
- package/dist/detectors/heading-echo.js.map +1 -1
- package/dist/detectors/kana-function-word.d.ts +12 -0
- package/dist/detectors/kana-function-word.d.ts.map +1 -0
- package/dist/detectors/kana-function-word.js +59 -0
- package/dist/detectors/kana-function-word.js.map +1 -0
- package/dist/detectors/line-amount.d.ts +3 -0
- package/dist/detectors/line-amount.d.ts.map +1 -0
- package/dist/detectors/line-amount.js +22 -0
- package/dist/detectors/line-amount.js.map +1 -0
- package/dist/detectors/location-pointer.d.ts +6 -0
- package/dist/detectors/location-pointer.d.ts.map +1 -0
- package/dist/detectors/location-pointer.js +22 -0
- package/dist/detectors/location-pointer.js.map +1 -0
- package/dist/detectors/mark-shape.d.ts.map +1 -1
- package/dist/detectors/mark-shape.js +13 -1
- package/dist/detectors/mark-shape.js.map +1 -1
- package/dist/detectors/nado-closed-list.d.ts +3 -0
- package/dist/detectors/nado-closed-list.d.ts.map +1 -0
- package/dist/detectors/nado-closed-list.js +21 -0
- package/dist/detectors/nado-closed-list.js.map +1 -0
- package/dist/detectors/name-variant.d.ts.map +1 -1
- package/dist/detectors/name-variant.js +129 -8
- package/dist/detectors/name-variant.js.map +1 -1
- package/dist/detectors/next-word.d.ts.map +1 -1
- package/dist/detectors/next-word.js +41 -8
- package/dist/detectors/next-word.js.map +1 -1
- package/dist/detectors/number-word-figure.d.ts +5 -0
- package/dist/detectors/number-word-figure.d.ts.map +1 -0
- package/dist/detectors/number-word-figure.js +32 -0
- package/dist/detectors/number-word-figure.js.map +1 -0
- package/dist/detectors/obligation-without-deadline.d.ts +39 -0
- package/dist/detectors/obligation-without-deadline.d.ts.map +1 -0
- package/dist/detectors/obligation-without-deadline.js +148 -0
- package/dist/detectors/obligation-without-deadline.js.map +1 -0
- package/dist/detectors/open-end-names.d.ts +23 -0
- package/dist/detectors/open-end-names.d.ts.map +1 -0
- package/dist/detectors/open-end-names.js +95 -0
- package/dist/detectors/open-end-names.js.map +1 -0
- package/dist/detectors/ordinal-run-gaps.d.ts +8 -0
- package/dist/detectors/ordinal-run-gaps.d.ts.map +1 -0
- package/dist/detectors/ordinal-run-gaps.js +80 -0
- package/dist/detectors/ordinal-run-gaps.js.map +1 -0
- package/dist/detectors/orthographic-variant.d.ts.map +1 -1
- package/dist/detectors/orthographic-variant.js +26 -9
- package/dist/detectors/orthographic-variant.js.map +1 -1
- package/dist/detectors/orthography.d.ts.map +1 -1
- package/dist/detectors/orthography.js +5 -0
- package/dist/detectors/orthography.js.map +1 -1
- package/dist/detectors/parameter-table.d.ts +3 -0
- package/dist/detectors/parameter-table.d.ts.map +1 -0
- package/dist/detectors/parameter-table.js +16 -0
- package/dist/detectors/parameter-table.js.map +1 -0
- package/dist/detectors/party-order.d.ts +3 -0
- package/dist/detectors/party-order.d.ts.map +1 -0
- package/dist/detectors/party-order.js +46 -0
- package/dist/detectors/party-order.js.map +1 -0
- package/dist/detectors/phone-number-variant.d.ts +3 -0
- package/dist/detectors/phone-number-variant.d.ts.map +1 -0
- package/dist/detectors/phone-number-variant.js +18 -0
- package/dist/detectors/phone-number-variant.js.map +1 -0
- package/dist/detectors/prerequisite-order.d.ts +3 -0
- package/dist/detectors/prerequisite-order.d.ts.map +1 -0
- package/dist/detectors/prerequisite-order.js +30 -0
- package/dist/detectors/prerequisite-order.js.map +1 -0
- package/dist/detectors/quote-unnamed-speaker.d.ts +3 -0
- package/dist/detectors/quote-unnamed-speaker.d.ts.map +1 -0
- package/dist/detectors/quote-unnamed-speaker.js +18 -0
- package/dist/detectors/quote-unnamed-speaker.js.map +1 -0
- package/dist/detectors/quote-without-source.d.ts +12 -2
- package/dist/detectors/quote-without-source.d.ts.map +1 -1
- package/dist/detectors/quote-without-source.js +45 -11
- package/dist/detectors/quote-without-source.js.map +1 -1
- package/dist/detectors/registry/amount-range.d.ts +3 -0
- package/dist/detectors/registry/amount-range.d.ts.map +1 -0
- package/dist/detectors/registry/amount-range.js +3 -0
- package/dist/detectors/registry/amount-range.js.map +1 -0
- package/dist/detectors/registry/arrival-before-departure.d.ts +3 -0
- package/dist/detectors/registry/arrival-before-departure.d.ts.map +1 -0
- package/dist/detectors/registry/arrival-before-departure.js +3 -0
- package/dist/detectors/registry/arrival-before-departure.js.map +1 -0
- package/dist/detectors/registry/connection-time-short.d.ts +3 -0
- package/dist/detectors/registry/connection-time-short.d.ts.map +1 -0
- package/dist/detectors/registry/connection-time-short.js +3 -0
- package/dist/detectors/registry/connection-time-short.js.map +1 -0
- package/dist/detectors/registry/date-outside-period.d.ts +3 -0
- package/dist/detectors/registry/date-outside-period.d.ts.map +1 -0
- package/dist/detectors/registry/date-outside-period.js +3 -0
- package/dist/detectors/registry/date-outside-period.js.map +1 -0
- package/dist/detectors/registry/default-values.d.ts +3 -0
- package/dist/detectors/registry/default-values.d.ts.map +1 -0
- package/dist/detectors/registry/default-values.js +3 -0
- package/dist/detectors/registry/default-values.js.map +1 -0
- package/dist/detectors/registry/deprecated-use.d.ts +3 -0
- package/dist/detectors/registry/deprecated-use.d.ts.map +1 -0
- package/dist/detectors/registry/deprecated-use.js +3 -0
- package/dist/detectors/registry/deprecated-use.js.map +1 -0
- package/dist/detectors/registry/due-date.d.ts +3 -0
- package/dist/detectors/registry/due-date.d.ts.map +1 -0
- package/dist/detectors/registry/due-date.js +3 -0
- package/dist/detectors/registry/due-date.js.map +1 -0
- package/dist/detectors/registry/duration-product-mismatch.d.ts +3 -0
- package/dist/detectors/registry/duration-product-mismatch.d.ts.map +1 -0
- package/dist/detectors/registry/duration-product-mismatch.js +3 -0
- package/dist/detectors/registry/duration-product-mismatch.js.map +1 -0
- package/dist/detectors/registry/kana-function-word.d.ts +3 -0
- package/dist/detectors/registry/kana-function-word.d.ts.map +1 -0
- package/dist/detectors/registry/kana-function-word.js +3 -0
- package/dist/detectors/registry/kana-function-word.js.map +1 -0
- package/dist/detectors/registry/line-amount.d.ts +3 -0
- package/dist/detectors/registry/line-amount.d.ts.map +1 -0
- package/dist/detectors/registry/line-amount.js +3 -0
- package/dist/detectors/registry/line-amount.js.map +1 -0
- package/dist/detectors/registry/nado-closed-list.d.ts +3 -0
- package/dist/detectors/registry/nado-closed-list.d.ts.map +1 -0
- package/dist/detectors/registry/nado-closed-list.js +3 -0
- package/dist/detectors/registry/nado-closed-list.js.map +1 -0
- package/dist/detectors/registry/number-word-figure.d.ts +3 -0
- package/dist/detectors/registry/number-word-figure.d.ts.map +1 -0
- package/dist/detectors/registry/number-word-figure.js +3 -0
- package/dist/detectors/registry/number-word-figure.js.map +1 -0
- package/dist/detectors/registry/obligation-without-deadline.d.ts +3 -0
- package/dist/detectors/registry/obligation-without-deadline.d.ts.map +1 -0
- package/dist/detectors/registry/obligation-without-deadline.js +3 -0
- package/dist/detectors/registry/obligation-without-deadline.js.map +1 -0
- package/dist/detectors/registry/parameter-table.d.ts +3 -0
- package/dist/detectors/registry/parameter-table.d.ts.map +1 -0
- package/dist/detectors/registry/parameter-table.js +3 -0
- package/dist/detectors/registry/parameter-table.js.map +1 -0
- package/dist/detectors/registry/party-order.d.ts +3 -0
- package/dist/detectors/registry/party-order.d.ts.map +1 -0
- package/dist/detectors/registry/party-order.js +3 -0
- package/dist/detectors/registry/party-order.js.map +1 -0
- package/dist/detectors/registry/phone-number-variant.d.ts +3 -0
- package/dist/detectors/registry/phone-number-variant.d.ts.map +1 -0
- package/dist/detectors/registry/phone-number-variant.js +3 -0
- package/dist/detectors/registry/phone-number-variant.js.map +1 -0
- package/dist/detectors/registry/prerequisite-order.d.ts +3 -0
- package/dist/detectors/registry/prerequisite-order.d.ts.map +1 -0
- package/dist/detectors/registry/prerequisite-order.js +3 -0
- package/dist/detectors/registry/prerequisite-order.js.map +1 -0
- package/dist/detectors/registry/quote-unnamed-speaker.d.ts +3 -0
- package/dist/detectors/registry/quote-unnamed-speaker.d.ts.map +1 -0
- package/dist/detectors/registry/quote-unnamed-speaker.js +3 -0
- package/dist/detectors/registry/quote-unnamed-speaker.js.map +1 -0
- package/dist/detectors/registry/requirement-lists.d.ts +3 -0
- package/dist/detectors/registry/requirement-lists.d.ts.map +1 -0
- package/dist/detectors/registry/requirement-lists.js +3 -0
- package/dist/detectors/registry/requirement-lists.js.map +1 -0
- package/dist/detectors/registry/return-type.d.ts +3 -0
- package/dist/detectors/registry/return-type.d.ts.map +1 -0
- package/dist/detectors/registry/return-type.js +3 -0
- package/dist/detectors/registry/return-type.js.map +1 -0
- package/dist/detectors/registry/tax-amount.d.ts +3 -0
- package/dist/detectors/registry/tax-amount.d.ts.map +1 -0
- package/dist/detectors/registry/tax-amount.js +3 -0
- package/dist/detectors/registry/tax-amount.js.map +1 -0
- package/dist/detectors/registry/time-order.d.ts +3 -0
- package/dist/detectors/registry/time-order.d.ts.map +1 -0
- package/dist/detectors/registry/time-order.js +3 -0
- package/dist/detectors/registry/time-order.js.map +1 -0
- package/dist/detectors/registry/ui-label.d.ts +3 -0
- package/dist/detectors/registry/ui-label.d.ts.map +1 -0
- package/dist/detectors/registry/ui-label.js +3 -0
- package/dist/detectors/registry/ui-label.js.map +1 -0
- package/dist/detectors/registry/undefined-call.d.ts +3 -0
- package/dist/detectors/registry/undefined-call.d.ts.map +1 -0
- package/dist/detectors/registry/undefined-call.js +3 -0
- package/dist/detectors/registry/undefined-call.js.map +1 -0
- package/dist/detectors/registry/undefined-term.d.ts +3 -0
- package/dist/detectors/registry/undefined-term.d.ts.map +1 -0
- package/dist/detectors/registry/undefined-term.js +3 -0
- package/dist/detectors/registry/undefined-term.js.map +1 -0
- package/dist/detectors/registry/version-order.d.ts +3 -0
- package/dist/detectors/registry/version-order.d.ts.map +1 -0
- package/dist/detectors/registry/version-order.js +3 -0
- package/dist/detectors/registry/version-order.js.map +1 -0
- package/dist/detectors/registry/warning-action.d.ts +3 -0
- package/dist/detectors/registry/warning-action.d.ts.map +1 -0
- package/dist/detectors/registry/warning-action.js +3 -0
- package/dist/detectors/registry/warning-action.js.map +1 -0
- package/dist/detectors/requirement-lists.d.ts +3 -0
- package/dist/detectors/requirement-lists.d.ts.map +1 -0
- package/dist/detectors/requirement-lists.js +46 -0
- package/dist/detectors/requirement-lists.js.map +1 -0
- package/dist/detectors/requirement-smell.d.ts.map +1 -1
- package/dist/detectors/requirement-smell.js +25 -8
- package/dist/detectors/requirement-smell.js.map +1 -1
- package/dist/detectors/return-type.d.ts +3 -0
- package/dist/detectors/return-type.d.ts.map +1 -0
- package/dist/detectors/return-type.js +24 -0
- package/dist/detectors/return-type.js.map +1 -0
- package/dist/detectors/structure-tree.d.ts +12 -4
- package/dist/detectors/structure-tree.d.ts.map +1 -1
- package/dist/detectors/structure-tree.js +40 -15
- package/dist/detectors/structure-tree.js.map +1 -1
- package/dist/detectors/superlative-scope.d.ts.map +1 -1
- package/dist/detectors/superlative-scope.js +11 -1
- package/dist/detectors/superlative-scope.js.map +1 -1
- package/dist/detectors/tax-amount.d.ts +3 -0
- package/dist/detectors/tax-amount.d.ts.map +1 -0
- package/dist/detectors/tax-amount.js +19 -0
- package/dist/detectors/tax-amount.js.map +1 -0
- package/dist/detectors/technical-docs.d.ts.map +1 -1
- package/dist/detectors/technical-docs.js +5 -1
- package/dist/detectors/technical-docs.js.map +1 -1
- package/dist/detectors/term-extension.d.ts +14 -0
- package/dist/detectors/term-extension.d.ts.map +1 -0
- package/dist/detectors/term-extension.js +67 -0
- package/dist/detectors/term-extension.js.map +1 -0
- package/dist/detectors/time-order.d.ts +5 -0
- package/dist/detectors/time-order.d.ts.map +1 -0
- package/dist/detectors/time-order.js +58 -0
- package/dist/detectors/time-order.js.map +1 -0
- package/dist/detectors/ui-label.d.ts +3 -0
- package/dist/detectors/ui-label.d.ts.map +1 -0
- package/dist/detectors/ui-label.js +16 -0
- package/dist/detectors/ui-label.js.map +1 -0
- package/dist/detectors/unbalanced-bracket.d.ts.map +1 -1
- package/dist/detectors/unbalanced-bracket.js +8 -13
- package/dist/detectors/unbalanced-bracket.js.map +1 -1
- package/dist/detectors/undefined-call.d.ts +3 -0
- package/dist/detectors/undefined-call.d.ts.map +1 -0
- package/dist/detectors/undefined-call.js +18 -0
- package/dist/detectors/undefined-call.js.map +1 -0
- package/dist/detectors/undefined-term.d.ts +22 -0
- package/dist/detectors/undefined-term.d.ts.map +1 -0
- package/dist/detectors/undefined-term.js +101 -0
- package/dist/detectors/undefined-term.js.map +1 -0
- package/dist/detectors/unknown-word.d.ts +1 -1
- package/dist/detectors/unknown-word.js +3 -3
- package/dist/detectors/unknown-word.js.map +1 -1
- package/dist/detectors/vague-deadline.d.ts +4 -0
- package/dist/detectors/vague-deadline.d.ts.map +1 -1
- package/dist/detectors/vague-deadline.js +3 -3
- package/dist/detectors/vague-deadline.js.map +1 -1
- package/dist/detectors/version-mismatch.d.ts.map +1 -1
- package/dist/detectors/version-mismatch.js +18 -1
- package/dist/detectors/version-mismatch.js.map +1 -1
- package/dist/detectors/version-order.d.ts +3 -0
- package/dist/detectors/version-order.d.ts.map +1 -0
- package/dist/detectors/version-order.js +43 -0
- package/dist/detectors/version-order.js.map +1 -0
- package/dist/detectors/warning-action.d.ts +3 -0
- package/dist/detectors/warning-action.d.ts.map +1 -0
- package/dist/detectors/warning-action.js +48 -0
- package/dist/detectors/warning-action.js.map +1 -0
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +4 -1
- package/dist/document.js.map +1 -1
- package/dist/facts/condition-pairs.d.ts +51 -0
- package/dist/facts/condition-pairs.d.ts.map +1 -0
- package/dist/facts/condition-pairs.js +203 -0
- package/dist/facts/condition-pairs.js.map +1 -0
- package/dist/facts/event-dates.d.ts +26 -0
- package/dist/facts/event-dates.d.ts.map +1 -0
- package/dist/facts/event-dates.js +38 -0
- package/dist/facts/event-dates.js.map +1 -0
- package/dist/facts/fact-scope.d.ts +2 -0
- package/dist/facts/fact-scope.d.ts.map +1 -1
- package/dist/facts/fact-scope.js +5 -0
- package/dist/facts/fact-scope.js.map +1 -1
- package/dist/facts/labelled-facts.d.ts +2 -0
- package/dist/facts/labelled-facts.d.ts.map +1 -1
- package/dist/facts/labelled-facts.js +9 -1
- package/dist/facts/labelled-facts.js.map +1 -1
- package/dist/facts/table-facts.d.ts +18 -0
- package/dist/facts/table-facts.d.ts.map +1 -1
- package/dist/facts/table-facts.js +4 -2
- package/dist/facts/table-facts.js.map +1 -1
- package/dist/grade/ai-score.d.ts +1 -1
- package/dist/grade/ai-score.d.ts.map +1 -1
- package/dist/grade/text.js +2 -2
- package/dist/grade/text.js.map +1 -1
- package/dist/heading-numbering.js +2 -2
- package/dist/heading-numbering.js.map +1 -1
- package/dist/html/fetch-page.d.ts +20 -0
- package/dist/html/fetch-page.d.ts.map +1 -0
- package/dist/html/fetch-page.js +51 -0
- package/dist/html/fetch-page.js.map +1 -0
- package/dist/html/fetched-text.d.ts +5 -0
- package/dist/html/fetched-text.d.ts.map +1 -0
- package/dist/html/fetched-text.js +25 -0
- package/dist/html/fetched-text.js.map +1 -0
- package/dist/html/html-content-block.d.ts +6 -0
- package/dist/html/html-content-block.d.ts.map +1 -0
- package/dist/html/html-content-block.js +86 -0
- package/dist/html/html-content-block.js.map +1 -0
- package/dist/html/html-elements.d.ts +41 -0
- package/dist/html/html-elements.d.ts.map +1 -0
- package/dist/html/html-elements.js +91 -0
- package/dist/html/html-elements.js.map +1 -0
- package/dist/html/html-footnote-marks.d.ts +2 -0
- package/dist/html/html-footnote-marks.d.ts.map +1 -0
- package/dist/html/html-footnote-marks.js +15 -0
- package/dist/html/html-footnote-marks.js.map +1 -0
- package/dist/html/html-heading-links.d.ts +6 -0
- package/dist/html/html-heading-links.d.ts.map +1 -0
- package/dist/html/html-heading-links.js +71 -0
- package/dist/html/html-heading-links.js.map +1 -0
- package/dist/html/html-lost-tags.d.ts +3 -0
- package/dist/html/html-lost-tags.d.ts.map +1 -0
- package/dist/html/html-lost-tags.js +11 -0
- package/dist/html/html-lost-tags.js.map +1 -0
- package/dist/html/html-markdown.d.ts +2 -0
- package/dist/html/html-markdown.d.ts.map +1 -0
- package/dist/html/html-markdown.js +347 -0
- package/dist/html/html-markdown.js.map +1 -0
- package/dist/html/html-preformatted.d.ts +17 -0
- package/dist/html/html-preformatted.d.ts.map +1 -0
- package/dist/html/html-preformatted.js +82 -0
- package/dist/html/html-preformatted.js.map +1 -0
- package/dist/html/html-reader-only.d.ts +6 -0
- package/dist/html/html-reader-only.d.ts.map +1 -0
- package/dist/html/html-reader-only.js +63 -0
- package/dist/html/html-reader-only.js.map +1 -0
- package/dist/html/html-run-in-headings.d.ts +2 -0
- package/dist/html/html-run-in-headings.d.ts.map +1 -0
- package/dist/html/html-run-in-headings.js +36 -0
- package/dist/html/html-run-in-headings.js.map +1 -0
- package/dist/html/html-tables.d.ts +3 -0
- package/dist/html/html-tables.d.ts.map +1 -0
- package/dist/html/html-tables.js +58 -0
- package/dist/html/html-tables.js.map +1 -0
- package/dist/html/html-widgets.d.ts +3 -0
- package/dist/html/html-widgets.d.ts.map +1 -0
- package/dist/html/html-widgets.js +71 -0
- package/dist/html/html-widgets.js.map +1 -0
- package/dist/html/markup-text.d.ts +5 -0
- package/dist/html/markup-text.d.ts.map +1 -0
- package/dist/html/markup-text.js +32 -0
- package/dist/html/markup-text.js.map +1 -0
- package/dist/html/page-document.d.ts +9 -0
- package/dist/html/page-document.d.ts.map +1 -0
- package/dist/html/page-document.js +19 -0
- package/dist/html/page-document.js.map +1 -0
- package/dist/inline-count.d.ts +19 -0
- package/dist/inline-count.d.ts.map +1 -0
- package/dist/inline-count.js +109 -0
- package/dist/inline-count.js.map +1 -0
- package/dist/kana-spelling.d.ts +5 -0
- package/dist/kana-spelling.d.ts.map +1 -1
- package/dist/kana-spelling.js +5 -0
- package/dist/kana-spelling.js.map +1 -1
- package/dist/location-part.d.ts +13 -0
- package/dist/location-part.d.ts.map +1 -0
- package/dist/location-part.js +24 -0
- package/dist/location-part.js.map +1 -0
- package/dist/nado-closed-list.d.ts +20 -0
- package/dist/nado-closed-list.d.ts.map +1 -0
- package/dist/nado-closed-list.js +72 -0
- package/dist/nado-closed-list.js.map +1 -0
- package/dist/name-cue.d.ts +17 -0
- package/dist/name-cue.d.ts.map +1 -0
- package/dist/name-cue.js +29 -0
- package/dist/name-cue.js.map +1 -0
- package/dist/name-variants.d.ts +29 -2
- package/dist/name-variants.d.ts.map +1 -1
- package/dist/name-variants.js +107 -8
- package/dist/name-variants.js.map +1 -1
- package/dist/name-word-order.d.ts +49 -0
- package/dist/name-word-order.d.ts.map +1 -0
- package/dist/name-word-order.js +114 -0
- package/dist/name-word-order.js.map +1 -0
- package/dist/paragraph-runs.d.ts +6 -1
- package/dist/paragraph-runs.d.ts.map +1 -1
- package/dist/paragraph-runs.js +9 -2
- package/dist/paragraph-runs.js.map +1 -1
- package/dist/parameter-table.d.ts +19 -0
- package/dist/parameter-table.d.ts.map +1 -0
- package/dist/parameter-table.js +191 -0
- package/dist/parameter-table.js.map +1 -0
- package/dist/phone-numbers.d.ts +23 -0
- package/dist/phone-numbers.d.ts.map +1 -0
- package/dist/phone-numbers.js +83 -0
- package/dist/phone-numbers.js.map +1 -0
- package/dist/place-names.d.ts +55 -0
- package/dist/place-names.d.ts.map +1 -0
- package/dist/place-names.js +196 -0
- package/dist/place-names.js.map +1 -0
- package/dist/plugin.d.ts +11 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/prerequisite-order.d.ts +16 -0
- package/dist/prerequisite-order.d.ts.map +1 -0
- package/dist/prerequisite-order.js +29 -0
- package/dist/prerequisite-order.js.map +1 -0
- package/dist/profile/parse.d.ts.map +1 -1
- package/dist/profile/parse.js +10 -1
- package/dist/profile/parse.js.map +1 -1
- package/dist/reasons.d.ts +2 -0
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +2 -0
- package/dist/reasons.js.map +1 -1
- package/dist/render/rules-json.d.ts.map +1 -1
- package/dist/render/rules-json.js +4 -0
- package/dist/render/rules-json.js.map +1 -1
- package/dist/render/rules-table.d.ts.map +1 -1
- package/dist/render/rules-table.js +6 -2
- package/dist/render/rules-table.js.map +1 -1
- package/dist/return-type.d.ts +33 -0
- package/dist/return-type.d.ts.map +1 -0
- package/dist/return-type.js +302 -0
- package/dist/return-type.js.map +1 -0
- package/dist/rule-genres.d.ts +5 -2
- package/dist/rule-genres.d.ts.map +1 -1
- package/dist/rule-genres.js +2 -0
- package/dist/rule-genres.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.d.ts.map +1 -1
- package/dist/run.js +5 -1
- package/dist/run.js.map +1 -1
- package/dist/spelling.d.ts +2 -0
- package/dist/spelling.d.ts.map +1 -1
- package/dist/spelling.js +6 -0
- package/dist/spelling.js.map +1 -1
- package/dist/structure/action-due.d.ts +21 -0
- package/dist/structure/action-due.d.ts.map +1 -0
- package/dist/structure/action-due.js +126 -0
- package/dist/structure/action-due.js.map +1 -0
- package/dist/structure/amount-range.d.ts +30 -0
- package/dist/structure/amount-range.d.ts.map +1 -0
- package/dist/structure/amount-range.js +153 -0
- package/dist/structure/amount-range.js.map +1 -0
- package/dist/structure/amount-scale.d.ts +6 -0
- package/dist/structure/amount-scale.d.ts.map +1 -1
- package/dist/structure/amount-scale.js +13 -0
- package/dist/structure/amount-scale.js.map +1 -1
- package/dist/structure/cite.d.ts +5 -2
- package/dist/structure/cite.d.ts.map +1 -1
- package/dist/structure/cite.js +20 -1
- package/dist/structure/cite.js.map +1 -1
- package/dist/structure/connection-times.d.ts +56 -0
- package/dist/structure/connection-times.d.ts.map +1 -0
- package/dist/structure/connection-times.js +165 -0
- package/dist/structure/connection-times.js.map +1 -0
- package/dist/structure/counted-amounts.d.ts +12 -0
- package/dist/structure/counted-amounts.d.ts.map +1 -0
- package/dist/structure/counted-amounts.js +30 -0
- package/dist/structure/counted-amounts.js.map +1 -0
- package/dist/structure/date-order-tie.d.ts +13 -0
- package/dist/structure/date-order-tie.d.ts.map +1 -0
- package/dist/structure/date-order-tie.js +61 -0
- package/dist/structure/date-order-tie.js.map +1 -0
- package/dist/structure/date-order.d.ts +24 -3
- package/dist/structure/date-order.d.ts.map +1 -1
- package/dist/structure/date-order.js +66 -17
- package/dist/structure/date-order.js.map +1 -1
- package/dist/structure/date-outside-period.d.ts +33 -0
- package/dist/structure/date-outside-period.d.ts.map +1 -0
- package/dist/structure/date-outside-period.js +132 -0
- package/dist/structure/date-outside-period.js.map +1 -0
- package/dist/structure/date-range.d.ts +5 -2
- package/dist/structure/date-range.d.ts.map +1 -1
- package/dist/structure/date-range.js +37 -9
- package/dist/structure/date-range.js.map +1 -1
- package/dist/structure/definition-use.d.ts +5 -2
- package/dist/structure/definition-use.d.ts.map +1 -1
- package/dist/structure/definition-use.js +11 -3
- package/dist/structure/definition-use.js.map +1 -1
- package/dist/structure/due-date.d.ts +19 -0
- package/dist/structure/due-date.d.ts.map +1 -0
- package/dist/structure/due-date.js +30 -0
- package/dist/structure/due-date.js.map +1 -0
- package/dist/structure/heading-runs.d.ts +9 -0
- package/dist/structure/heading-runs.d.ts.map +1 -0
- package/dist/structure/heading-runs.js +23 -0
- package/dist/structure/heading-runs.js.map +1 -0
- package/dist/structure/install-pin.d.ts +46 -0
- package/dist/structure/install-pin.d.ts.map +1 -0
- package/dist/structure/install-pin.js +85 -0
- package/dist/structure/install-pin.js.map +1 -0
- package/dist/structure/leg-times.d.ts +36 -0
- package/dist/structure/leg-times.d.ts.map +1 -0
- package/dist/structure/leg-times.js +148 -0
- package/dist/structure/leg-times.js.map +1 -0
- package/dist/structure/line-amount-unit.d.ts +24 -0
- package/dist/structure/line-amount-unit.d.ts.map +1 -0
- package/dist/structure/line-amount-unit.js +24 -0
- package/dist/structure/line-amount-unit.js.map +1 -0
- package/dist/structure/line-amount.d.ts +40 -0
- package/dist/structure/line-amount.d.ts.map +1 -0
- package/dist/structure/line-amount.js +118 -0
- package/dist/structure/line-amount.js.map +1 -0
- package/dist/structure/number-word-figure.d.ts +37 -0
- package/dist/structure/number-word-figure.d.ts.map +1 -0
- package/dist/structure/number-word-figure.js +151 -0
- package/dist/structure/number-word-figure.js.map +1 -0
- package/dist/structure/numbering.d.ts +1 -0
- package/dist/structure/numbering.d.ts.map +1 -1
- package/dist/structure/numbering.js +3 -0
- package/dist/structure/numbering.js.map +1 -1
- package/dist/structure/ordinal-runs.d.ts +45 -0
- package/dist/structure/ordinal-runs.d.ts.map +1 -0
- package/dist/structure/ordinal-runs.js +78 -0
- package/dist/structure/ordinal-runs.js.map +1 -0
- package/dist/structure/party-order.d.ts +33 -0
- package/dist/structure/party-order.d.ts.map +1 -0
- package/dist/structure/party-order.js +79 -0
- package/dist/structure/party-order.js.map +1 -0
- package/dist/structure/percent-sum-prose.d.ts +1 -1
- package/dist/structure/percent-sum-prose.d.ts.map +1 -1
- package/dist/structure/percent-sum-prose.js +45 -3
- package/dist/structure/percent-sum-prose.js.map +1 -1
- package/dist/structure/percent-sum.d.ts +8 -0
- package/dist/structure/percent-sum.d.ts.map +1 -1
- package/dist/structure/percent-sum.js +8 -1
- package/dist/structure/percent-sum.js.map +1 -1
- package/dist/structure/release-list.d.ts +9 -0
- package/dist/structure/release-list.d.ts.map +1 -0
- package/dist/structure/release-list.js +46 -0
- package/dist/structure/release-list.js.map +1 -0
- package/dist/structure/requirement-lists.d.ts +37 -0
- package/dist/structure/requirement-lists.d.ts.map +1 -0
- package/dist/structure/requirement-lists.js +89 -0
- package/dist/structure/requirement-lists.js.map +1 -0
- package/dist/structure/share-column.d.ts +7 -0
- package/dist/structure/share-column.d.ts.map +1 -0
- package/dist/structure/share-column.js +22 -0
- package/dist/structure/share-column.js.map +1 -0
- package/dist/structure/stated-period.d.ts +31 -0
- package/dist/structure/stated-period.d.ts.map +1 -0
- package/dist/structure/stated-period.js +127 -0
- package/dist/structure/stated-period.js.map +1 -0
- package/dist/structure/tax.d.ts +25 -0
- package/dist/structure/tax.d.ts.map +1 -0
- package/dist/structure/tax.js +86 -0
- package/dist/structure/tax.js.map +1 -0
- package/dist/structure/time-marks.d.ts +58 -0
- package/dist/structure/time-marks.d.ts.map +1 -0
- package/dist/structure/time-marks.js +74 -0
- package/dist/structure/time-marks.js.map +1 -0
- package/dist/structure/time-order.d.ts +42 -0
- package/dist/structure/time-order.d.ts.map +1 -0
- package/dist/structure/time-order.js +107 -0
- package/dist/structure/time-order.js.map +1 -0
- package/dist/structure/title-lines.d.ts +8 -0
- package/dist/structure/title-lines.d.ts.map +1 -0
- package/dist/structure/title-lines.js +27 -0
- package/dist/structure/title-lines.js.map +1 -0
- package/dist/structure/total.d.ts.map +1 -1
- package/dist/structure/total.js +3 -1
- package/dist/structure/total.js.map +1 -1
- package/dist/structure/version-mismatch.d.ts +1 -5
- package/dist/structure/version-mismatch.d.ts.map +1 -1
- package/dist/structure/version-mismatch.js +65 -12
- package/dist/structure/version-mismatch.js.map +1 -1
- package/dist/structure/version-order.d.ts +25 -0
- package/dist/structure/version-order.d.ts.map +1 -0
- package/dist/structure/version-order.js +77 -0
- package/dist/structure/version-order.js.map +1 -0
- package/dist/surname-near.d.ts +6 -0
- package/dist/surname-near.d.ts.map +1 -0
- package/dist/surname-near.js +31 -0
- package/dist/surname-near.js.map +1 -0
- package/dist/table-cells.d.ts +13 -0
- package/dist/table-cells.d.ts.map +1 -0
- package/dist/table-cells.js +36 -0
- package/dist/table-cells.js.map +1 -0
- package/dist/table-names.d.ts +42 -0
- package/dist/table-names.d.ts.map +1 -0
- package/dist/table-names.js +94 -0
- package/dist/table-names.js.map +1 -0
- package/dist/table-text.d.ts +9 -0
- package/dist/table-text.d.ts.map +1 -0
- package/dist/table-text.js +36 -0
- package/dist/table-text.js.map +1 -0
- package/dist/ui-labels.d.ts +16 -0
- package/dist/ui-labels.d.ts.map +1 -0
- package/dist/ui-labels.js +42 -0
- package/dist/ui-labels.js.map +1 -0
- package/dist/undefined-call.d.ts +13 -0
- package/dist/undefined-call.d.ts.map +1 -0
- package/dist/undefined-call.js +55 -0
- package/dist/undefined-call.js.map +1 -0
- package/dist/unnamed-speaker.d.ts +23 -0
- package/dist/unnamed-speaker.d.ts.map +1 -0
- package/dist/unnamed-speaker.js +176 -0
- package/dist/unnamed-speaker.js.map +1 -0
- package/dist/warning-action.d.ts +22 -0
- package/dist/warning-action.d.ts.map +1 -0
- package/dist/warning-action.js +58 -0
- package/dist/warning-action.js.map +1 -0
- package/genres.yaml +2 -0
- package/package.json +4 -3
- package/profiles/statute.yaml +8 -0
- package/rules/agreement-slip.yaml +2 -2
- package/rules/amount-range-reversed.yaml +52 -0
- package/rules/amount-scale-consistency.yaml +4 -4
- package/rules/announced-count-mismatch.yaml +9 -4
- package/rules/arrival-before-departure.yaml +48 -0
- package/rules/connection-time-short.yaml +52 -0
- package/rules/connective-hierarchy.yaml +3 -3
- package/rules/currency-notation-consistency.yaml +2 -2
- package/rules/date-order.yaml +9 -4
- package/rules/date-outside-period.yaml +64 -0
- package/rules/default-value-mismatch.yaml +79 -0
- package/rules/defined-term-form.yaml +9 -7
- package/rules/deprecated-option-used.yaml +78 -0
- package/rules/doubled-nado.yaml +28 -12
- package/rules/due-before-issue.yaml +68 -0
- package/rules/duplicate-definition.yaml +2 -2
- package/rules/duration-mismatch.yaml +15 -4
- package/rules/duration-product-mismatch.yaml +73 -0
- package/rules/heading-echo.yaml +2 -2
- package/rules/hyphen-as-dash.yaml +2 -2
- package/rules/kana-function-word.yaml +58 -0
- package/rules/latin-spacing.yaml +6 -5
- package/rules/line-amount-mismatch.yaml +58 -0
- package/rules/nado-closed-list.yaml +77 -0
- package/rules/name-variant.yaml +20 -2
- package/rules/number-word-figure-mismatch.yaml +76 -0
- package/rules/numbering-gap.yaml +2 -2
- package/rules/obligation-without-deadline.yaml +95 -0
- package/rules/one-sentence-paragraph-run.yaml +2 -3
- package/rules/parameter-table-mismatch.yaml +90 -0
- package/rules/party-order.yaml +84 -0
- package/rules/percent-sum-mismatch.yaml +2 -2
- package/rules/phone-number-variant.yaml +68 -0
- package/rules/prerequisite-after-step.yaml +78 -0
- package/rules/quote-unnamed-speaker.yaml +67 -0
- package/rules/quote-without-source.yaml +6 -6
- package/rules/required-listed-as-preferred.yaml +102 -0
- package/rules/requirement-smell.yaml +3 -3
- package/rules/return-type-mismatch.yaml +79 -0
- package/rules/sentence-initial-conjunction-run.yaml +13 -7
- package/rules/summary-fact-mismatch.yaml +4 -4
- package/rules/tax-mismatch.yaml +71 -0
- package/rules/time-order.yaml +65 -0
- package/rules/title-length.yaml +2 -2
- package/rules/ui-label-variant.yaml +70 -0
- package/rules/unbalanced-bracket.yaml +4 -4
- package/rules/uncomparable-graded.yaml +29 -10
- package/rules/undefined-function-call.yaml +77 -0
- package/rules/undefined-term.yaml +86 -0
- package/rules/unknown-word.yaml +2 -2
- package/rules/unqualified-superlative.yaml +2 -2
- package/rules/use-before-definition.yaml +2 -2
- package/rules/version-mismatch.yaml +12 -4
- package/rules/version-order.yaml +85 -0
- package/rules/very-adjective.yaml +31 -13
- package/rules/warning-without-action.yaml +64 -0
- package/rules/wordy-phrase.yaml +27 -9
- package/src/ai-score/of-document.ts +19 -9
- package/src/ai-score/render.ts +24 -4
- package/src/ai-score/score.ts +24 -3
- package/src/ai-score/signals.ts +12 -2
- package/src/ai-score/text.ts +7 -2
- package/src/announced-count.ts +19 -12
- package/src/check-source.ts +11 -2
- package/src/cli-text.ts +38 -16
- package/src/cli.ts +2 -1
- package/src/commands/cite-claims.ts +103 -0
- package/src/commands/cite-page.ts +61 -0
- package/src/commands/cite-scaffold.ts +27 -0
- package/src/commands/cite.ts +127 -58
- package/src/company-names.ts +202 -0
- package/src/default-values.ts +158 -0
- package/src/deprecated-use.ts +122 -0
- package/src/derived/session-hours.ts +62 -0
- package/src/derived/stays.ts +145 -0
- package/src/derived/time-lengths.ts +226 -0
- package/src/derived/unit-counts.ts +18 -0
- package/src/derived/working-hours.ts +97 -0
- package/src/detectors/acronym-context.ts +10 -2
- package/src/detectors/acronym-expansion.ts +57 -2
- package/src/detectors/address-word.ts +9 -0
- package/src/detectors/agreement-slip.ts +7 -1
- package/src/detectors/ai-phrasing.ts +6 -1
- package/src/detectors/amount-range.ts +54 -0
- package/src/detectors/amount-scale.ts +50 -17
- package/src/detectors/announced-count.ts +29 -11
- package/src/detectors/bare-comparative.ts +7 -2
- package/src/detectors/block-quotation.ts +95 -0
- package/src/detectors/bracket-label.ts +58 -0
- package/src/detectors/capitalised-term.ts +147 -0
- package/src/detectors/citation-entry.ts +20 -5
- package/src/detectors/code-before.ts +14 -0
- package/src/detectors/connective-hierarchy.ts +39 -11
- package/src/detectors/currency-notation.ts +2 -1
- package/src/detectors/date-outside-period.ts +41 -0
- package/src/detectors/default-values.ts +17 -0
- package/src/detectors/defined-term-form.ts +84 -15
- package/src/detectors/definition-use.ts +10 -2
- package/src/detectors/deprecated-use.ts +17 -0
- package/src/detectors/derived-numbers.ts +174 -10
- package/src/detectors/document-shape.ts +6 -1
- package/src/detectors/due-date.ts +47 -0
- package/src/detectors/en-shape.ts +27 -11
- package/src/detectors/fact-consistency.ts +95 -3
- package/src/detectors/heading-echo.ts +11 -1
- package/src/detectors/kana-function-word.ts +71 -0
- package/src/detectors/line-amount.ts +33 -0
- package/src/detectors/location-pointer.ts +30 -0
- package/src/detectors/mark-shape.ts +18 -1
- package/src/detectors/nado-closed-list.ts +25 -0
- package/src/detectors/name-variant.ts +164 -13
- package/src/detectors/next-word.ts +56 -9
- package/src/detectors/number-word-figure.ts +43 -0
- package/src/detectors/obligation-without-deadline.ts +192 -0
- package/src/detectors/open-end-names.ts +140 -0
- package/src/detectors/ordinal-run-gaps.ts +101 -0
- package/src/detectors/orthographic-variant.ts +39 -14
- package/src/detectors/orthography.ts +6 -1
- package/src/detectors/parameter-table.ts +17 -0
- package/src/detectors/party-order.ts +50 -0
- package/src/detectors/phone-number-variant.ts +18 -0
- package/src/detectors/prerequisite-order.ts +35 -0
- package/src/detectors/quote-unnamed-speaker.ts +19 -0
- package/src/detectors/quote-without-source.ts +57 -10
- package/src/detectors/registry/amount-range.ts +4 -0
- package/src/detectors/registry/arrival-before-departure.ts +4 -0
- package/src/detectors/registry/connection-time-short.ts +4 -0
- package/src/detectors/registry/date-outside-period.ts +4 -0
- package/src/detectors/registry/default-values.ts +4 -0
- package/src/detectors/registry/deprecated-use.ts +4 -0
- package/src/detectors/registry/due-date.ts +4 -0
- package/src/detectors/registry/duration-product-mismatch.ts +4 -0
- package/src/detectors/registry/kana-function-word.ts +4 -0
- package/src/detectors/registry/line-amount.ts +4 -0
- package/src/detectors/registry/nado-closed-list.ts +4 -0
- package/src/detectors/registry/number-word-figure.ts +4 -0
- package/src/detectors/registry/obligation-without-deadline.ts +4 -0
- package/src/detectors/registry/parameter-table.ts +4 -0
- package/src/detectors/registry/party-order.ts +4 -0
- package/src/detectors/registry/phone-number-variant.ts +4 -0
- package/src/detectors/registry/prerequisite-order.ts +4 -0
- package/src/detectors/registry/quote-unnamed-speaker.ts +4 -0
- package/src/detectors/registry/requirement-lists.ts +4 -0
- package/src/detectors/registry/return-type.ts +4 -0
- package/src/detectors/registry/tax-amount.ts +4 -0
- package/src/detectors/registry/time-order.ts +4 -0
- package/src/detectors/registry/ui-label.ts +4 -0
- package/src/detectors/registry/undefined-call.ts +4 -0
- package/src/detectors/registry/undefined-term.ts +4 -0
- package/src/detectors/registry/version-order.ts +4 -0
- package/src/detectors/registry/warning-action.ts +4 -0
- package/src/detectors/requirement-lists.ts +65 -0
- package/src/detectors/requirement-smell.ts +29 -9
- package/src/detectors/return-type.ts +30 -0
- package/src/detectors/structure-tree.ts +55 -22
- package/src/detectors/superlative-scope.ts +13 -1
- package/src/detectors/tax-amount.ts +25 -0
- package/src/detectors/technical-docs.ts +7 -1
- package/src/detectors/term-extension.ts +67 -0
- package/src/detectors/time-order.ts +84 -0
- package/src/detectors/ui-label.ts +17 -0
- package/src/detectors/unbalanced-bracket.ts +7 -14
- package/src/detectors/undefined-call.ts +19 -0
- package/src/detectors/undefined-term.ts +120 -0
- package/src/detectors/unknown-word.ts +3 -3
- package/src/detectors/vague-deadline.ts +3 -3
- package/src/detectors/version-mismatch.ts +26 -5
- package/src/detectors/version-order.ts +50 -0
- package/src/detectors/warning-action.ts +49 -0
- package/src/document.ts +4 -1
- package/src/facts/condition-pairs.ts +289 -0
- package/src/facts/event-dates.ts +63 -0
- package/src/facts/fact-scope.ts +6 -0
- package/src/facts/labelled-facts.ts +13 -1
- package/src/facts/table-facts.ts +6 -3
- package/src/grade/ai-score.ts +1 -1
- package/src/grade/text.ts +2 -2
- package/src/heading-numbering.ts +2 -2
- package/src/html/fetch-page.ts +64 -0
- package/src/html/fetched-text.ts +32 -0
- package/src/html/html-content-block.ts +107 -0
- package/src/html/html-elements.ts +127 -0
- package/src/html/html-footnote-marks.ts +20 -0
- package/src/html/html-heading-links.ts +93 -0
- package/src/html/html-lost-tags.ts +14 -0
- package/src/html/html-markdown.ts +481 -0
- package/src/html/html-preformatted.ts +110 -0
- package/src/html/html-reader-only.ts +82 -0
- package/src/html/html-run-in-headings.ts +43 -0
- package/src/html/html-tables.ts +76 -0
- package/src/html/html-widgets.ts +114 -0
- package/src/html/markup-text.ts +35 -0
- package/src/html/page-document.ts +22 -0
- package/src/inline-count.ts +146 -0
- package/src/kana-spelling.ts +7 -0
- package/src/location-part.ts +30 -0
- package/src/nado-closed-list.ts +106 -0
- package/src/name-cue.ts +35 -0
- package/src/name-variants.ts +133 -12
- package/src/name-word-order.ts +149 -0
- package/src/paragraph-runs.ts +12 -2
- package/src/parameter-table.ts +208 -0
- package/src/phone-numbers.ts +98 -0
- package/src/place-names.ts +248 -0
- package/src/plugin.ts +9 -0
- package/src/prerequisite-order.ts +39 -0
- package/src/profile/parse.ts +10 -1
- package/src/reasons.ts +4 -0
- package/src/render/rules-json.ts +4 -0
- package/src/render/rules-table.ts +6 -3
- package/src/return-type.ts +361 -0
- package/src/rule-genres.ts +5 -2
- package/src/rule-load.ts +3 -2
- package/src/run.ts +3 -1
- package/src/spelling.ts +8 -0
- package/src/structure/action-due.ts +179 -0
- package/src/structure/amount-range.ts +219 -0
- package/src/structure/amount-scale.ts +18 -0
- package/src/structure/cite.ts +21 -2
- package/src/structure/connection-times.ts +226 -0
- package/src/structure/counted-amounts.ts +42 -0
- package/src/structure/date-order-tie.ts +86 -0
- package/src/structure/date-order.ts +100 -23
- package/src/structure/date-outside-period.ts +192 -0
- package/src/structure/date-range.ts +45 -9
- package/src/structure/definition-use.ts +24 -3
- package/src/structure/due-date.ts +46 -0
- package/src/structure/heading-runs.ts +24 -0
- package/src/structure/install-pin.ts +115 -0
- package/src/structure/leg-times.ts +213 -0
- package/src/structure/line-amount-unit.ts +35 -0
- package/src/structure/line-amount.ts +162 -0
- package/src/structure/number-word-figure.ts +199 -0
- package/src/structure/numbering.ts +3 -0
- package/src/structure/ordinal-runs.ts +107 -0
- package/src/structure/party-order.ts +115 -0
- package/src/structure/percent-sum-prose.ts +46 -3
- package/src/structure/percent-sum.ts +16 -2
- package/src/structure/release-list.ts +69 -0
- package/src/structure/requirement-lists.ts +145 -0
- package/src/structure/share-column.ts +25 -0
- package/src/structure/stated-period.ts +161 -0
- package/src/structure/tax.ts +114 -0
- package/src/structure/time-marks.ts +127 -0
- package/src/structure/time-order.ts +141 -0
- package/src/structure/title-lines.ts +33 -0
- package/src/structure/total.ts +5 -1
- package/src/structure/version-mismatch.ts +67 -13
- package/src/structure/version-order.ts +94 -0
- package/src/surname-near.ts +31 -0
- package/src/table-cells.ts +41 -0
- package/src/table-names.ts +113 -0
- package/src/table-text.ts +39 -0
- package/src/ui-labels.ts +55 -0
- package/src/undefined-call.ts +65 -0
- package/src/unnamed-speaker.ts +224 -0
- package/src/warning-action.ts +73 -0
- package/styles/koyobun.yaml +7 -4
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// A version written in the lead-in to a code block ("Install version 2.3.0 from npm:") that the block itself does not
|
|
2
2
|
// show (npm install tidyq@2.4.0). Pure: reads the source, the code blocks, and the prose with code covered.
|
|
3
|
+
import { escapeRegExp } from "../orthography.ts";
|
|
3
4
|
import type { Span } from "../plugin.ts";
|
|
4
5
|
import type { StructureIssue } from "./issues.ts";
|
|
5
6
|
|
|
@@ -85,19 +86,72 @@ const leadInOf = (source: string, blockStart: number): Span | undefined => {
|
|
|
85
86
|
return text === "" || NOT_PROSE.test(text) || !LETTER.test(words) ? undefined : { start, end: lines.length };
|
|
86
87
|
};
|
|
87
88
|
|
|
89
|
+
/** A pin with the version it pins, of any number of parts: redis 7.4 in redis:7.4-alpine and in library/redis:7.4. */
|
|
90
|
+
const PIN_VERSION = /^([\w.-]+)(?:@|==|=|:)[v^~]?(\d+(?:\.\d+)*)/u;
|
|
91
|
+
const HAS_LETTER = /[A-Za-z]/u;
|
|
92
|
+
|
|
93
|
+
/** Each name the block pins, with the one version it pins it to; a name pinned to two versions is left out. */
|
|
94
|
+
const pinnedVersions = (code: string): Map<string, string> => {
|
|
95
|
+
const byName = new Map<string, Set<string>>();
|
|
96
|
+
codeWords(code).forEach((word) => {
|
|
97
|
+
const match = PIN_VERSION.exec(word.slice(word.lastIndexOf("/") + 1));
|
|
98
|
+
if (match?.[1] === undefined || match[2] === undefined || !HAS_LETTER.test(match[1])) return;
|
|
99
|
+
const name = match[1].toLowerCase();
|
|
100
|
+
byName.set(name, new Set([...(byName.get(name) ?? []), match[2]]));
|
|
101
|
+
});
|
|
102
|
+
const single = new Map<string, string>();
|
|
103
|
+
byName.forEach((versions, name) => {
|
|
104
|
+
const [only] = versions;
|
|
105
|
+
if (versions.size === 1 && only !== undefined) single.set(name, only);
|
|
106
|
+
});
|
|
107
|
+
return single;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/** 7 and 7.4, or 7.4 and 7.4.1: one names the other's series, so they agree. */
|
|
111
|
+
const sameSeries = (written: string, pinned: string): boolean => {
|
|
112
|
+
const [shorter, longer] = [written.split("."), pinned.split(".")].toSorted((left, right) => left.length - right.length);
|
|
113
|
+
return (shorter ?? []).every((part, index) => part === longer?.[index]);
|
|
114
|
+
};
|
|
115
|
+
|
|
88
116
|
/**
|
|
89
|
-
* Each version
|
|
90
|
-
*
|
|
91
|
-
*
|
|
117
|
+
* Each version written right after the name of a program the block pins ("We run Redis 7.2" over redis:7.4) that is not of
|
|
118
|
+
* the pinned version's series. The name says whose version it is, so a version of two parts is read here, where a bare 7.2
|
|
119
|
+
* is too often a decimal; one part (port 6379, Node 20) is too often another number.
|
|
92
120
|
*/
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
.map((found) => ({ offset: found.start, values: { written: found.version, code } }));
|
|
121
|
+
const namedMismatches = (prose: string, leadIn: Span, code: string, ranges: readonly RangeWord[]): StructureIssue[] =>
|
|
122
|
+
[...pinnedVersions(code)].flatMap(([name, pinned]) => {
|
|
123
|
+
const pattern = new RegExp(`(?<![\\w.-])${escapeRegExp(name)}\\s+v?(\\d+(?:\\.\\d+){1,2})(?![\\w.]|\\.\\d)`, "giu");
|
|
124
|
+
return [...prose.slice(leadIn.start, leadIn.end).matchAll(pattern)].flatMap((match) => {
|
|
125
|
+
const written = match[1] ?? "";
|
|
126
|
+
const span = { start: leadIn.start + match.index, end: leadIn.start + match.index + match[0].length };
|
|
127
|
+
if (sameSeries(written, pinned) || isBound(prose, span, ranges)) return [];
|
|
128
|
+
return [{ offset: span.end - written.length, values: { written, code: pinned } }];
|
|
129
|
+
});
|
|
103
130
|
});
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Each version in the lead-in that differs from the one version the block shows. A block with no version, or with two (an
|
|
134
|
+
* upgrade from one to the other), says nothing to compare; a version marked as a bound, or named after another program, is
|
|
135
|
+
* not the one installed.
|
|
136
|
+
*/
|
|
137
|
+
const shownMismatches = (prose: string, leadIn: Span, code: string, words: VersionWords): StructureIssue[] => {
|
|
138
|
+
const shown = [...new Set(versionsIn(code).map((found) => found.version))];
|
|
139
|
+
const [only] = shown;
|
|
140
|
+
if (shown.length !== 1 || only === undefined) return [];
|
|
141
|
+
const names = pinnedNames(code);
|
|
142
|
+
return versionsIn(prose.slice(leadIn.start, leadIn.end), leadIn.start)
|
|
143
|
+
.filter((found) => found.version !== only && !isBound(prose, found, words.ranges) && isAboutBlock(prose, found, names, words.versionWords))
|
|
144
|
+
.map((found) => ({ offset: found.start, values: { written: found.version, code: only } }));
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/** Both readings of one block; a version both report is reported once, against the pin of the program it names. */
|
|
148
|
+
const blockMismatches = (source: string, prose: string, block: CodeBlock, words: VersionWords): StructureIssue[] => {
|
|
149
|
+
const leadIn = leadInOf(source, block.start);
|
|
150
|
+
if (leadIn === undefined) return [];
|
|
151
|
+
const issues = [...namedMismatches(prose, leadIn, block.code, words.ranges), ...shownMismatches(prose, leadIn, block.code, words)];
|
|
152
|
+
return issues.filter((issue, index) => issues.findIndex((other) => other.offset === issue.offset) === index);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/** Each version in a code block's lead-in that differs from the version the block installs. */
|
|
156
|
+
export const versionMismatches = (source: string, prose: string, blocks: readonly CodeBlock[], words: VersionWords): StructureIssue[] =>
|
|
157
|
+
blocks.flatMap((block) => blockMismatches(source, prose, block, words));
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { StructureIssue } from "./issues.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Versions listed in order, a changelog's headings or a list of releases, with one out of place. The direction (newest or
|
|
5
|
+
* oldest first) is taken from most of the steps, and a version that fits in no longest run along it is pointed out.
|
|
6
|
+
*/
|
|
7
|
+
export type VersionPoint = { readonly offset: number; readonly label: string };
|
|
8
|
+
|
|
9
|
+
type Version = { readonly parts: readonly number[]; readonly prerelease: string };
|
|
10
|
+
|
|
11
|
+
/** A version at the start of a heading or an item: 3.2.0, v3.2.0, [3.2.0], 3.2.0-beta.1. */
|
|
12
|
+
const VERSION_START = /^\[?v?(\d{1,4})\.(\d{1,4})\.(\d{1,4})(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?\]?(?![\w.])/u;
|
|
13
|
+
|
|
14
|
+
/** The version a heading or an item starts with, as written; undefined when it does not start with one. */
|
|
15
|
+
export const leadingVersion = (text: string): string | undefined => VERSION_START.exec(text.trim())?.[0];
|
|
16
|
+
|
|
17
|
+
const parse = (label: string): Version | undefined => {
|
|
18
|
+
const match = VERSION_START.exec(label);
|
|
19
|
+
if (match === null) return undefined;
|
|
20
|
+
return { parts: [match[1], match[2], match[3]].map(Number), prerelease: match[4] ?? "" };
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** A prerelease (3.0.0-beta.1) comes before its release (3.0.0). */
|
|
24
|
+
const comparePrerelease = (left: string, right: string): number => {
|
|
25
|
+
if (left === right) return 0;
|
|
26
|
+
if (left === "") return 1;
|
|
27
|
+
return right === "" ? -1 : Math.sign(left.localeCompare(right, "en", { numeric: true }));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const compareVersions = (left: Version, right: Version): number => {
|
|
31
|
+
const differing = left.parts.findIndex((part, index) => part !== right.parts[index]);
|
|
32
|
+
return differing === -1 ? comparePrerelease(left.prerelease, right.prerelease) : Math.sign((left.parts[differing] ?? 0) - (right.parts[differing] ?? 0));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** Whether every label is a version and no step goes against direction (equal versions do not break it). */
|
|
36
|
+
export const versionsAlong = (labels: readonly (string | undefined)[], direction: number): boolean => {
|
|
37
|
+
const versions = labels.flatMap((label) => {
|
|
38
|
+
const version = label === undefined ? undefined : parse(label);
|
|
39
|
+
return version === undefined ? [] : [version];
|
|
40
|
+
});
|
|
41
|
+
if (versions.length !== labels.length) return false;
|
|
42
|
+
return versions.slice(1).every((version, index) => compareVersions(version, versions[index] ?? version) !== -direction);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/** The longest run along direction ending at each version (equal versions do not break it). */
|
|
46
|
+
const longestEndingAt = (versions: readonly Version[], direction: number): number[] =>
|
|
47
|
+
versions.reduce<number[]>((lengths, version, index) => {
|
|
48
|
+
const along = versions.slice(0, index).map((earlier, at) => (compareVersions(version, earlier) === -direction ? 0 : (lengths[at] ?? 0)));
|
|
49
|
+
return [...lengths, 1 + Math.max(0, ...along)];
|
|
50
|
+
}, []);
|
|
51
|
+
|
|
52
|
+
const majorityOf = (versions: readonly Version[]): number =>
|
|
53
|
+
Math.sign(versions.slice(1).reduce((sum, version, index) => sum + compareVersions(version, versions[index] ?? version), 0));
|
|
54
|
+
|
|
55
|
+
/** The fewest versions an order is read from: with two, either one could be the one out of place. */
|
|
56
|
+
const MIN_VERSIONS = 3;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The versions that belong to no longest run along the majority direction. A run that holds no more than half of them is
|
|
60
|
+
* taken as sorted by something else, and nothing is said.
|
|
61
|
+
*/
|
|
62
|
+
export const versionOrderBreaks = (points: readonly VersionPoint[]): StructureIssue[] => {
|
|
63
|
+
const parsed = points.flatMap((point) => {
|
|
64
|
+
const version = parse(point.label);
|
|
65
|
+
return version === undefined ? [] : [{ point, version }];
|
|
66
|
+
});
|
|
67
|
+
const versions = parsed.map((entry) => entry.version);
|
|
68
|
+
const direction = majorityOf(versions);
|
|
69
|
+
if (versions.length < MIN_VERSIONS || direction === 0) return [];
|
|
70
|
+
const forward = longestEndingAt(versions, direction);
|
|
71
|
+
const backward = longestEndingAt(versions.toReversed(), -direction).toReversed();
|
|
72
|
+
const longest = Math.max(...forward);
|
|
73
|
+
if (longest * 2 <= versions.length) return [];
|
|
74
|
+
return parsed.flatMap((entry, index) =>
|
|
75
|
+
(forward[index] ?? 0) + (backward[index] ?? 0) - 1 === longest
|
|
76
|
+
? []
|
|
77
|
+
: [{ offset: entry.point.offset, values: { version: entry.point.label, previous: parsed[index - 1]?.point.label ?? "" } }],
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/** A version whose last part is zero (3.1.0) is no section number: the sections under 3.1 count from 3.1.1. */
|
|
82
|
+
const endsInZero = (version: Version): boolean => version.parts.at(-1) === 0;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Whether dotted labels (1.2.1, 1.2.2) are a version history rather than section numbers: all of them versions, and
|
|
86
|
+
* either one ends in zero or most steps go down (newest first). Section numbers only go up. version-order checks the
|
|
87
|
+
* histories and numbering-gap the rest, so a sequence is never reported by both.
|
|
88
|
+
*/
|
|
89
|
+
export const isVersionHistory = (labels: readonly string[]): boolean => {
|
|
90
|
+
const versions = labels.map(parse);
|
|
91
|
+
const parsed = versions.filter((version) => version !== undefined);
|
|
92
|
+
if (labels.length < 2 || parsed.length !== labels.length) return false;
|
|
93
|
+
return parsed.some(endsInZero) || majorityOf(parsed) < 0;
|
|
94
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// 名が同じ人の名前の、姓だけの書き損じ(Whitford と Whitfield)。一字違い(isNearWord)より遠い違いを、英字の長い姓に限って見る。
|
|
2
|
+
|
|
3
|
+
const LATIN_WORD = /^[a-z]+$/u;
|
|
4
|
+
|
|
5
|
+
/** 二字違いまで見る姓の長さ。短い姓(Martin と Marten、Hansen と Hanson)は別の姓のことが多い。 */
|
|
6
|
+
const MIN_SURNAME_LENGTH = 7;
|
|
7
|
+
/** 頭からそろう字の数。頭が違えば別の姓(Robertson と Robinson)。 */
|
|
8
|
+
const MIN_SURNAME_PREFIX = 4;
|
|
9
|
+
/** 頭と終わりのそろった字のあいだに残る字の数。短いほうで二字まで、長いほうで三字まで(Whitford の or と Whitfield の iel)。 */
|
|
10
|
+
const MAX_SURNAME_GAP = 2;
|
|
11
|
+
|
|
12
|
+
const sharedPrefix = (left: string, right: string): number => {
|
|
13
|
+
const differ = [...left].findIndex((char, index) => char !== right.charAt(index));
|
|
14
|
+
return differ < 0 ? left.length : differ;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 二つの英字の姓が、頭が四字以上そろい、終わりの字もそろい、あいだの二字(長いほうは三字)までだけ違うか。どちらも七字以上で。
|
|
19
|
+
* 終わりだけの違い(Whitford と Whitfords)は語の形の違い。
|
|
20
|
+
*/
|
|
21
|
+
export const isNearSurname = (left: string, right: string): boolean => {
|
|
22
|
+
if (left === right || !LATIN_WORD.test(left) || !LATIN_WORD.test(right) || Math.min(left.length, right.length) < MIN_SURNAME_LENGTH) return false;
|
|
23
|
+
const prefix = sharedPrefix(left, right);
|
|
24
|
+
if (prefix < MIN_SURNAME_PREFIX) return false;
|
|
25
|
+
const [leftRest, rightRest] = [left.slice(prefix), right.slice(prefix)];
|
|
26
|
+
const suffix = sharedPrefix([...leftRest].toReversed().join(""), [...rightRest].toReversed().join(""));
|
|
27
|
+
if (suffix === 0) return false;
|
|
28
|
+
const gaps = [leftRest.length - suffix, rightRest.length - suffix].toSorted((first, second) => first - second);
|
|
29
|
+
const [shorter = 0, longer = 0] = gaps;
|
|
30
|
+
return shorter <= MAX_SURNAME_GAP && longer <= MAX_SURNAME_GAP + 1;
|
|
31
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ProseDocument, Segmentation, Span, TableCell, Token } from "./plugin.ts";
|
|
2
|
+
import { proseAndTablesOf } from "./table-text.ts";
|
|
3
|
+
import { tableBodyCells, type Cell } from "./facts/table-facts.ts";
|
|
4
|
+
|
|
5
|
+
// 表の升の語。本文は表を覆うので、升の字は文の分割も品詞解析も通らない。升ごとに adapter に渡し、語の位置を source の上に戻す。
|
|
6
|
+
|
|
7
|
+
const LETTER = /\p{L}/u;
|
|
8
|
+
|
|
9
|
+
const shiftToken = (token: Token, by: number): Token => ({ ...token, span: { start: token.span.start + by, end: token.span.end + by } });
|
|
10
|
+
|
|
11
|
+
/** 升一つの語。字の無い升(数だけ、空)は解析しない。adapter が語を返さなければ tokens は無い。 */
|
|
12
|
+
export const cellWithTokens = (cell: Cell, segment: (text: string) => Segmentation): TableCell => {
|
|
13
|
+
if (!LETTER.test(cell.text)) return cell;
|
|
14
|
+
const sentences = segment(cell.text).sentences;
|
|
15
|
+
if (!sentences.some((sentence) => sentence.tokens !== undefined)) return cell;
|
|
16
|
+
return { ...cell, tokens: sentences.flatMap((sentence) => (sentence.tokens ?? []).map((token) => shiftToken(token, cell.start))) };
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** 文書の表(引用とコードの外)の本体の升と、その語。 */
|
|
20
|
+
export const tableCellsOf = (doc: ProseDocument, segment: (text: string) => Segmentation): TableCell[] =>
|
|
21
|
+
tableBodyCells(proseAndTablesOf(doc)).map((cell) => cellWithTokens(cell, segment));
|
|
22
|
+
|
|
23
|
+
/** prose に、升の字だけを書き戻したもの(表の見出しの行と区切りの | は覆ったまま)。位置は変えない。 */
|
|
24
|
+
export const proseWithCells = (prose: string, cells: readonly (Span & { readonly text: string })[]): string => {
|
|
25
|
+
const pieces: string[] = [];
|
|
26
|
+
const end = cells
|
|
27
|
+
.toSorted((left, right) => left.start - right.start)
|
|
28
|
+
.reduce((from, cell) => {
|
|
29
|
+
if (cell.start < from || cell.end - cell.start !== cell.text.length) return from;
|
|
30
|
+
pieces.push(prose.slice(from, cell.start), cell.text);
|
|
31
|
+
return cell.end;
|
|
32
|
+
}, 0);
|
|
33
|
+
pieces.push(prose.slice(end));
|
|
34
|
+
return pieces.join("");
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** 表の升の語は、読む rule があるときに一度だけ作る。升ごとの解析を、表を読まない rule に払わせない。 */
|
|
38
|
+
export const lazyCells = (make: () => readonly TableCell[]): (() => readonly TableCell[]) => {
|
|
39
|
+
const cells: { value?: readonly TableCell[] } = {};
|
|
40
|
+
return () => (cells.value ??= make());
|
|
41
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { isNearWord, nameKey, type NameMention } from "./name-variants.ts";
|
|
2
|
+
import type { TableCell, Token } from "./plugin.ts";
|
|
3
|
+
import { withoutEdgeMarks } from "./facts/trim-marks.ts";
|
|
4
|
+
|
|
5
|
+
// 表の升に書いた名前と、本文の名前の書き分け(本文は Sofia Mendes、担当者の表は Sofia Mendez)。表の升は品詞解析を通らないので、
|
|
6
|
+
// 名前の形をした升だけを読み、本文で読めた名前と比べる。比べるのは姓と名のように二語以上の名前で、一語だけが違うときに限る。
|
|
7
|
+
// 同じ語がほかにあることが、同じ人を指す手がかりになる。漢字・かなの名前は、本文と同じく読みが同じときに限る(佐々木 美穂 と
|
|
8
|
+
// 佐々木 美保)。読みの違う一字違い(佐藤 太郎 と 佐藤 次郎)は別の人のことが多い。
|
|
9
|
+
|
|
10
|
+
/** 表の升の名前。words は空白で分けた語。reading は升の語の読み(読めなければ無い)。 */
|
|
11
|
+
export type CellName = { readonly surface: string; readonly offset: number; readonly words: readonly string[]; readonly reading?: string | undefined };
|
|
12
|
+
|
|
13
|
+
/** 本文の名前の書き方と、その数。reading は最初の現れの読み。 */
|
|
14
|
+
export type ProseName = { readonly surface: string; readonly words: readonly string[]; readonly count: number; readonly reading?: string | undefined };
|
|
15
|
+
|
|
16
|
+
export type CellNameVariant = { readonly name: CellName; readonly usual: string; readonly kind: "spelling" | "reading" | "near" };
|
|
17
|
+
|
|
18
|
+
/** 英字の名前の升: 大文字で始まる語が二つから四つ。小文字の語(Write the procedure)を含む升は名前でない。 */
|
|
19
|
+
const LATIN_NAME = /^\p{Lu}[\p{L}'’.-]*(?: \p{Lu}[\p{L}'’.-]*){1,3}$/u;
|
|
20
|
+
/** 漢字・カタカナの名前の升: 名前の字の語が、空白一つを挟んで二つか三つ(佐々木 美穂)。 */
|
|
21
|
+
const CJK_NAME = /^[\p{Script=Han}\p{Script=Katakana}ー々]+(?:[ \u3000][\p{Script=Han}\p{Script=Katakana}ー々]+){1,2}$/u;
|
|
22
|
+
const SPACE = /[ \u3000]/u;
|
|
23
|
+
const LOWER = /\p{Ll}/u;
|
|
24
|
+
|
|
25
|
+
/** 範囲の中の語の読みをつないだもの。記号と空白の語は読まない。読めない語があれば無い。 */
|
|
26
|
+
export const readingWithin = (tokens: readonly Token[], start: number, end: number): string | undefined => {
|
|
27
|
+
const words = tokens.filter((token) => token.span.start >= start && token.span.end <= end && token.pos !== "PUNCT" && token.surface.trim() !== "");
|
|
28
|
+
const readings = words.map((token) => token.reading);
|
|
29
|
+
return words.length > 0 && readings.every((reading) => reading !== undefined && reading !== "") ? readings.join("") : undefined;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** 名前の形をした升。升の字の前後の空白と強調の印は名前の外。 */
|
|
33
|
+
export const cellNamesIn = (cells: readonly TableCell[]): CellName[] =>
|
|
34
|
+
cells.flatMap((cell) => {
|
|
35
|
+
const surface = withoutEdgeMarks(cell.text.trim());
|
|
36
|
+
if (!(LATIN_NAME.test(surface) && LOWER.test(surface)) && !CJK_NAME.test(surface)) return [];
|
|
37
|
+
const offset = cell.start + cell.text.indexOf(surface);
|
|
38
|
+
return [{ surface, offset, words: surface.split(SPACE), reading: readingWithin(cell.tokens ?? [], offset, offset + surface.length) }];
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 本文の名前の書き方ごとの数。空白一つで並んだ名前の現れ(佐々木 と 美穂)は、一つの名前(佐々木 美穂)としても数える。
|
|
43
|
+
* 日本語の解析器は姓と名のあいだの空白で名前を切る。
|
|
44
|
+
*/
|
|
45
|
+
export const proseNamesOf = (mentions: readonly NameMention[], source: string): ProseName[] => {
|
|
46
|
+
const sorted = mentions.toSorted((left, right) => left.offset - right.offset);
|
|
47
|
+
const joined = sorted.flatMap((mention, index): Written[] => {
|
|
48
|
+
const next = sorted[index + 1];
|
|
49
|
+
const end = mention.offset + mention.surface.length;
|
|
50
|
+
if (next === undefined || next.offset !== end + 1 || !SPACE.test(source.charAt(end))) return [];
|
|
51
|
+
const reading = mention.reading === undefined || next.reading === undefined ? undefined : `${mention.reading}${next.reading}`;
|
|
52
|
+
return [{ surface: `${mention.surface}${source.charAt(end)}${next.surface}`, reading }];
|
|
53
|
+
});
|
|
54
|
+
const forms = new Map<string, ProseName>();
|
|
55
|
+
[...sorted, ...joined].forEach(({ surface, reading }) => {
|
|
56
|
+
const form = forms.get(surface);
|
|
57
|
+
forms.set(surface, form === undefined ? { surface, words: surface.split(SPACE), count: 1, reading } : { ...form, count: form.count + 1 });
|
|
58
|
+
});
|
|
59
|
+
return [...forms.values()];
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
type Written = { readonly surface: string; readonly reading: string | undefined };
|
|
63
|
+
|
|
64
|
+
const LATIN = /\p{Script=Latin}/u;
|
|
65
|
+
/** 英字の語の中の記号(O'Connor、Anne-Marie)。一字違いは字だけで見る。 */
|
|
66
|
+
const WORD_MARKS = /['’.-]/gu;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 二つの英字の語が一字違いか(名前の見方と同じ isNearWord)。漢字・かなの語は見ない。升は読みが分からず、一字違いの名前
|
|
70
|
+
* (佐藤 太郎 と 佐藤 次郎)は別の人のことが多い。
|
|
71
|
+
*/
|
|
72
|
+
const isNearNameWord = (left: string, right: string): boolean =>
|
|
73
|
+
LATIN.test(left) && LATIN.test(right) && isNearWord(left.toLowerCase().replaceAll(WORD_MARKS, ""), right.toLowerCase().replaceAll(WORD_MARKS, ""));
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 升の名前が、本文の名前の書き分けか。記号・幅・大小だけの違いか、語の数が同じで一語だけが違い、残りの語が同じとき。違う一語は、
|
|
77
|
+
* 英字なら一字違い、漢字・かなら名前全体の読みが同じ(本文の名前の見方と同じ)。この二つは、本文の形が二度以上、升の形が文書の
|
|
78
|
+
* 中で一度だけのとき(別の人のこともある)。
|
|
79
|
+
*/
|
|
80
|
+
export const cellNameRelation = (name: CellName, uses: number, prose: ProseName): CellNameVariant["kind"] | undefined => {
|
|
81
|
+
if (name.surface === prose.surface || name.words.length !== prose.words.length) return undefined;
|
|
82
|
+
if (nameKey(name.surface) === nameKey(prose.surface)) return "spelling";
|
|
83
|
+
const differ = name.words.flatMap((word, index) => (word === prose.words[index] ? [] : [index]));
|
|
84
|
+
const [at] = differ;
|
|
85
|
+
if (differ.length !== 1 || at === undefined || uses !== 1 || prose.count < 2) return undefined;
|
|
86
|
+
if (isNearNameWord(name.words[at] ?? "", prose.words[at] ?? "")) return "near";
|
|
87
|
+
return name.reading !== undefined && name.reading === prose.reading ? "reading" : undefined;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/** 記号・幅・大小だけの違いを、読みの同じものと一字違いより先に取る。 */
|
|
91
|
+
const KIND_ORDER: readonly CellNameVariant["kind"][] = ["spelling", "reading", "near"];
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 表の升の名前のうち、本文の名前の書き分けのもの。記号だけの違いを先に、その中で本文の形のうち一番多いものと比べる。
|
|
95
|
+
* 書き方ごとに最初の升を一つ。
|
|
96
|
+
*/
|
|
97
|
+
export const cellNameVariants = (names: readonly CellName[], prose: readonly ProseName[]): CellNameVariant[] => {
|
|
98
|
+
const uses = new Map(prose.map((form) => [form.surface, form.count]));
|
|
99
|
+
const firsts = new Map<string, CellName>();
|
|
100
|
+
names.forEach((name) => {
|
|
101
|
+
uses.set(name.surface, (uses.get(name.surface) ?? 0) + 1);
|
|
102
|
+
if (!firsts.has(name.surface)) firsts.set(name.surface, name);
|
|
103
|
+
});
|
|
104
|
+
return [...firsts.values()].flatMap((name) => {
|
|
105
|
+
const [usual] = prose
|
|
106
|
+
.flatMap((form) => {
|
|
107
|
+
const kind = cellNameRelation(name, uses.get(name.surface) ?? 0, form);
|
|
108
|
+
return kind === undefined ? [] : [{ form, kind }];
|
|
109
|
+
})
|
|
110
|
+
.toSorted((left, right) => KIND_ORDER.indexOf(left.kind) - KIND_ORDER.indexOf(right.kind) || right.form.count - left.form.count);
|
|
111
|
+
return usual === undefined ? [] : [{ name, usual: usual.form.surface, kind: usual.kind }];
|
|
112
|
+
});
|
|
113
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// The prose with its Markdown tables read back in. The prose masks tables, but a quote or an invoice keeps most of its
|
|
2
|
+
// amounts in one, and a rule comparing how amounts are written has to see them.
|
|
3
|
+
import type { ProseDocument, Span } from "./plugin.ts";
|
|
4
|
+
import { maskSpans } from "./mask.ts";
|
|
5
|
+
import { opaqueSpans, readMarkdown, spansOfType } from "./markdown-read.ts";
|
|
6
|
+
import { TABLE_RULE } from "./structure/runs.ts";
|
|
7
|
+
|
|
8
|
+
const within = (inner: Span, outer: Span): boolean => inner.start >= outer.start && inner.end <= outer.end;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The prose, with each table span as the source writes it, except what stays hidden inside it (code in a cell). Offsets
|
|
12
|
+
* are kept. Pure.
|
|
13
|
+
*/
|
|
14
|
+
export const proseWithTables = (prose: string, source: string, tables: readonly Span[], hidden: readonly Span[]): string => {
|
|
15
|
+
if (tables.length === 0) return prose;
|
|
16
|
+
const shown = maskSpans(source, hidden);
|
|
17
|
+
const pieces: string[] = [];
|
|
18
|
+
const end = tables
|
|
19
|
+
.toSorted((left, right) => left.start - right.start)
|
|
20
|
+
.reduce((from, table) => {
|
|
21
|
+
if (table.start < from) return from;
|
|
22
|
+
pieces.push(prose.slice(from, table.start), shown.slice(table.start, table.end));
|
|
23
|
+
return table.end;
|
|
24
|
+
}, 0);
|
|
25
|
+
pieces.push(prose.slice(end));
|
|
26
|
+
return pieces.join("");
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const hasTableRule = (source: string): boolean => source.split("\n").some((line) => TABLE_RULE.test(line) && line.includes("-"));
|
|
30
|
+
|
|
31
|
+
/** The document's prose with its tables, outside code and quoted replies. A document that is not Markdown keeps its prose. */
|
|
32
|
+
export const proseAndTablesOf = (doc: ProseDocument): string => {
|
|
33
|
+
const prose = doc.prose ?? doc.source;
|
|
34
|
+
if (doc.prose === undefined || doc.markup?.markdown !== true || !hasTableRule(doc.source)) return prose;
|
|
35
|
+
const { root } = readMarkdown(doc.source);
|
|
36
|
+
const quoted = [...spansOfType(root, "blockquote"), ...(doc.replyQuotes ?? [])];
|
|
37
|
+
const tables = spansOfType(root, "table").filter((table) => !quoted.some((quote) => within(table, quote)));
|
|
38
|
+
return proseWithTables(doc.prose, doc.source, tables, opaqueSpans(root));
|
|
39
|
+
};
|
package/src/ui-labels.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// The same label on the screen written two ways in one manual (**Start Restore** and **Start restore**, [復元を開始] and
|
|
2
|
+
// [復元開始]). Pure: reads the labels a manual marks as labels, bold or in [], and points at the form written less often.
|
|
3
|
+
|
|
4
|
+
import { escapeRegExp } from "./orthography.ts";
|
|
5
|
+
|
|
6
|
+
export type Label = { readonly surface: string; readonly offset: number };
|
|
7
|
+
export type LabelVariant = { readonly label: Label; readonly usual: string };
|
|
8
|
+
|
|
9
|
+
/** What a manual marks as a label on the screen: bold (** or __), or the full-width brackets Japanese manuals use. */
|
|
10
|
+
const MARKED = /\*\*([^*\n]{1,40})\*\*|__([^_\n]{1,40})__|[([^]\n]{1,40})]/gu;
|
|
11
|
+
const SPACES = /\s+/gu;
|
|
12
|
+
const LETTER = /\p{L}/u;
|
|
13
|
+
|
|
14
|
+
/** Each label marked in the source whose text is prose (not covered as code in prose) and holds a letter. */
|
|
15
|
+
export const labelsIn = (source: string, prose: string): Label[] =>
|
|
16
|
+
[...source.matchAll(MARKED)].flatMap((match) => {
|
|
17
|
+
const surface = (match[1] ?? match[2] ?? match[3] ?? "").trim();
|
|
18
|
+
const inner = match.index + match[0].indexOf(surface);
|
|
19
|
+
const covered = prose.slice(inner, inner + surface.length) !== surface;
|
|
20
|
+
return covered || !LETTER.test(surface) ? [] : [{ surface, offset: inner }];
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Two forms of one label differ only in case, spaces, or a word a label is written with or without (the label-particle
|
|
25
|
+
* lexicon: 復元を開始 and 復元開始).
|
|
26
|
+
*/
|
|
27
|
+
const keyOf = (surface: string, particles: readonly string[]): string =>
|
|
28
|
+
particles.reduce((text, particle) => text.replace(joining(particle), ""), surface.replace(SPACES, "")).toLowerCase();
|
|
29
|
+
|
|
30
|
+
/** A particle between two kanji or katakana (復元を開始), not one inside a word (その他). */
|
|
31
|
+
const joining = (particle: string): RegExp =>
|
|
32
|
+
new RegExp(`(?<=[\\p{Script=Han}\\p{Script=Katakana}ー])${escapeRegExp(particle)}(?=[\\p{Script=Han}\\p{Script=Katakana}])`, "gu");
|
|
33
|
+
|
|
34
|
+
/** Two forms that differ only in the case of their first letter (Note and note): emphasis at a sentence's start, not two labels. */
|
|
35
|
+
const onlyFirstLetterDiffers = (forms: readonly string[]): boolean =>
|
|
36
|
+
new Set(forms.map((form) => `${form.charAt(0).toLowerCase()}${form.slice(1)}`)).size === 1;
|
|
37
|
+
|
|
38
|
+
const groupBy = (labels: readonly Label[], keyFor: (label: Label) => string): Map<string, Label[]> =>
|
|
39
|
+
labels.reduce((groups, label) => groups.set(keyFor(label), [...(groups.get(keyFor(label)) ?? []), label]), new Map<string, Label[]>());
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Each label written in a form other than the one its key is written in most; on a tie, the later form. A label written
|
|
43
|
+
* one way only says nothing.
|
|
44
|
+
*/
|
|
45
|
+
export const labelVariants = (labels: readonly Label[], particles: readonly string[] = []): LabelVariant[] => {
|
|
46
|
+
const byKey = groupBy(labels, (label) => keyOf(label.surface, particles));
|
|
47
|
+
return [...byKey.values()].flatMap((group) => {
|
|
48
|
+
const counts = groupBy(group, (label) => label.surface);
|
|
49
|
+
if (counts.size < 2 || onlyFirstLetterDiffers([...counts.keys()])) return [];
|
|
50
|
+
const [first] = counts;
|
|
51
|
+
if (first === undefined) return [];
|
|
52
|
+
const usual = [...counts].reduce((best, entry) => (entry[1].length > best[1].length ? entry : best), first)[0];
|
|
53
|
+
return group.filter((label) => label.surface !== usual).map((label) => ({ label, usual }));
|
|
54
|
+
});
|
|
55
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// A function called in a code example that the page never defines, where the page documents one whose name it extends:
|
|
2
|
+
// wrapText( on a page about wrap, wrapLines( after import { wrap }. Pure; reads the Markdown source. The global functions
|
|
3
|
+
// of programming languages (parseInt, setTimeout) come from a lexicon, so a page about parse may call parseInt.
|
|
4
|
+
import { codeFences } from "./detectors/code-fences.ts";
|
|
5
|
+
|
|
6
|
+
/** A call to a name the page does not define, where it is written, and the documented name it is likely a slip of. */
|
|
7
|
+
export type UndefinedCall = { readonly name: string; readonly offset: number; readonly documented: string };
|
|
8
|
+
|
|
9
|
+
const CALL = /(?<![\w$.])([A-Za-z_$][\w$]*)[ \t]*\(/gu;
|
|
10
|
+
const WORD = /[A-Za-z_$][\w$]*/gu;
|
|
11
|
+
const LEADING_WORD = /^[A-Za-z_$][\w$]*/u;
|
|
12
|
+
/** import { wrap, type Options, measure as m } from "wrapkit" (JavaScript) and from wrapkit import wrap, measure (Python). */
|
|
13
|
+
const IMPORT_BRACES = /\bimport[ \t]*\{([^}]*)\}/gu;
|
|
14
|
+
const FROM_IMPORT = /\bfrom[ \t]+[\w.]+[ \t]+import[ \t]+([\w, \t]+)/gu;
|
|
15
|
+
const TYPE_MODIFIER = /^type[ \t]+/u;
|
|
16
|
+
/** A name right after one of these is being declared, not called: function wrapText(, def wrap_text(. */
|
|
17
|
+
const DECLARING = /\b(?:function\*?|def|fn|func|class|new)[ \t]+$/u;
|
|
18
|
+
/** Where a line comment starts: a call after it is commented out. */
|
|
19
|
+
const LINE_COMMENT = /\/\/|(?:^|[ \t])#/u;
|
|
20
|
+
/** The shortest documented name a call is compared with: shorter ones (id, get) are prefixes of too many names. */
|
|
21
|
+
const MIN_DOCUMENTED = 4;
|
|
22
|
+
|
|
23
|
+
/** Each specifier's own name: `type Options` is Options, `measure as m` is measure. */
|
|
24
|
+
const specifiers = (list: string): string[] =>
|
|
25
|
+
list.split(",").flatMap((specifier) => LEADING_WORD.exec(specifier.trim().replace(TYPE_MODIFIER, ""))?.[0] ?? []);
|
|
26
|
+
|
|
27
|
+
const importedNames = (source: string): string[] =>
|
|
28
|
+
[...source.matchAll(IMPORT_BRACES), ...source.matchAll(FROM_IMPORT)].flatMap((match) => specifiers(match[1] ?? ""));
|
|
29
|
+
|
|
30
|
+
/** Names the page documents: the first word of a heading (## wrap, ### `wrap()`) and the names it imports. */
|
|
31
|
+
const documentedNames = (source: string, headings: readonly string[]): Set<string> => {
|
|
32
|
+
const fromHeadings = headings.flatMap((heading) => LEADING_WORD.exec(heading.replace(/[`*]/gu, "").trim())?.[0] ?? []);
|
|
33
|
+
return new Set([...fromHeadings, ...importedNames(source)].filter((name) => name.length >= MIN_DOCUMENTED));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const countWords = (source: string): Map<string, number> =>
|
|
37
|
+
[...source.matchAll(WORD)].reduce((counts, match) => counts.set(match[0], (counts.get(match[0]) ?? 0) + 1), new Map<string, number>());
|
|
38
|
+
|
|
39
|
+
/** Whether the call at `at` in `code` is declared there or commented out. */
|
|
40
|
+
const isDeclaredOrCommented = (code: string, at: number): boolean => {
|
|
41
|
+
const lineStart = code.lastIndexOf("\n", at - 1) + 1;
|
|
42
|
+
const before = code.slice(lineStart, at);
|
|
43
|
+
return DECLARING.test(before) || LINE_COMMENT.test(before);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Every call in a code block to a name written nowhere else on the page, when a documented name is its stem
|
|
48
|
+
* (wrap → wrapText). A name used twice (defined and called, or called twice) is the example's own. headings are the page's
|
|
49
|
+
* Markdown headings; globals the language functions every page may call.
|
|
50
|
+
*/
|
|
51
|
+
export const undefinedCalls = (source: string, headings: readonly string[], globals: readonly string[] = []): UndefinedCall[] => {
|
|
52
|
+
const documented = documentedNames(source, headings);
|
|
53
|
+
if (documented.size === 0) return [];
|
|
54
|
+
const counts = countWords(source);
|
|
55
|
+
const known = new Set([...documented, ...globals]);
|
|
56
|
+
return codeFences(source).flatMap((fence) => {
|
|
57
|
+
const code = source.slice(fence.start, fence.end);
|
|
58
|
+
return [...code.matchAll(CALL)].flatMap((match) => {
|
|
59
|
+
const name = match[1] ?? "";
|
|
60
|
+
const stem = [...documented].find((candidate) => name !== candidate && name.startsWith(candidate));
|
|
61
|
+
if (stem === undefined || known.has(name) || (counts.get(name) ?? 0) > 1 || isDeclaredOrCommented(code, match.index)) return [];
|
|
62
|
+
return [{ name, offset: fence.start + match.index, documented: stem }];
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
};
|