chaffjs 0.37.0 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +2 -0
- package/README.md +2 -0
- package/dist/acronym-expansions.d.ts.map +1 -1
- package/dist/acronym-expansions.js +8 -1
- package/dist/acronym-expansions.js.map +1 -1
- package/dist/ai-score/human-shares.d.ts.map +1 -1
- package/dist/ai-score/human-shares.js +36 -8
- package/dist/ai-score/human-shares.js.map +1 -1
- package/dist/alternative-words.d.ts +8 -0
- package/dist/alternative-words.d.ts.map +1 -0
- package/dist/alternative-words.js +15 -0
- package/dist/alternative-words.js.map +1 -0
- package/dist/article-h-style.d.ts +7 -0
- package/dist/article-h-style.d.ts.map +1 -0
- package/dist/article-h-style.js +12 -0
- package/dist/article-h-style.js.map +1 -0
- package/dist/bracket-annotation.d.ts +6 -0
- package/dist/bracket-annotation.d.ts.map +1 -0
- package/dist/bracket-annotation.js +46 -0
- package/dist/bracket-annotation.js.map +1 -0
- package/dist/compare/misopened-quotes.d.ts +7 -0
- package/dist/compare/misopened-quotes.d.ts.map +1 -0
- package/dist/compare/misopened-quotes.js +22 -0
- package/dist/compare/misopened-quotes.js.map +1 -0
- package/dist/compare/outcome.d.ts +2 -0
- package/dist/compare/outcome.d.ts.map +1 -1
- package/dist/compare/outcome.js +5 -2
- package/dist/compare/outcome.js.map +1 -1
- package/dist/compare/render.d.ts +1 -1
- package/dist/compare/render.d.ts.map +1 -1
- package/dist/compare/render.js +14 -4
- package/dist/compare/render.js.map +1 -1
- package/dist/compare/respelled.d.ts +19 -0
- package/dist/compare/respelled.d.ts.map +1 -0
- package/dist/compare/respelled.js +52 -0
- package/dist/compare/respelled.js.map +1 -0
- package/dist/compare/text-atoms.d.ts +1 -1
- package/dist/compare/text-atoms.d.ts.map +1 -1
- package/dist/compare/text-atoms.js +8 -2
- package/dist/compare/text-atoms.js.map +1 -1
- package/dist/compare/text.d.ts +2 -1
- package/dist/compare/text.d.ts.map +1 -1
- package/dist/compare/text.js +7 -2
- package/dist/compare/text.js.map +1 -1
- package/dist/contact-entry.d.ts +8 -0
- package/dist/contact-entry.d.ts.map +1 -0
- package/dist/contact-entry.js +16 -0
- package/dist/contact-entry.js.map +1 -0
- package/dist/contraction-words.d.ts +2 -0
- package/dist/contraction-words.d.ts.map +1 -0
- package/dist/contraction-words.js +11 -0
- package/dist/contraction-words.js.map +1 -0
- package/dist/derived/relative-dates.d.ts +4 -0
- package/dist/derived/relative-dates.d.ts.map +1 -1
- package/dist/derived/relative-dates.js +28 -1
- package/dist/derived/relative-dates.js.map +1 -1
- package/dist/detectors/abnf-grammar.d.ts +10 -0
- package/dist/detectors/abnf-grammar.d.ts.map +1 -0
- package/dist/detectors/abnf-grammar.js +65 -0
- package/dist/detectors/abnf-grammar.js.map +1 -0
- package/dist/detectors/acronym-context.d.ts +9 -0
- package/dist/detectors/acronym-context.d.ts.map +1 -1
- package/dist/detectors/acronym-context.js +29 -0
- package/dist/detectors/acronym-context.js.map +1 -1
- package/dist/detectors/acronym-expansion.d.ts.map +1 -1
- package/dist/detectors/acronym-expansion.js +27 -3
- package/dist/detectors/acronym-expansion.js.map +1 -1
- package/dist/detectors/acronym-gloss.d.ts +4 -0
- package/dist/detectors/acronym-gloss.d.ts.map +1 -0
- package/dist/detectors/acronym-gloss.js +28 -0
- package/dist/detectors/acronym-gloss.js.map +1 -0
- package/dist/detectors/acronym-known.d.ts +1 -1
- package/dist/detectors/acronym-known.d.ts.map +1 -1
- package/dist/detectors/acronym-known.js +11 -3
- package/dist/detectors/acronym-known.js.map +1 -1
- package/dist/detectors/adversative-ga.d.ts +4 -0
- package/dist/detectors/adversative-ga.d.ts.map +1 -0
- package/dist/detectors/adversative-ga.js +19 -0
- package/dist/detectors/adversative-ga.js.map +1 -0
- package/dist/detectors/agreement-slip.d.ts +3 -1
- package/dist/detectors/agreement-slip.d.ts.map +1 -1
- package/dist/detectors/agreement-slip.js +31 -3
- package/dist/detectors/agreement-slip.js.map +1 -1
- package/dist/detectors/ai-phrasing.d.ts +2 -1
- package/dist/detectors/ai-phrasing.d.ts.map +1 -1
- package/dist/detectors/ai-phrasing.js +5 -2
- package/dist/detectors/ai-phrasing.js.map +1 -1
- package/dist/detectors/alnum-number.d.ts +4 -0
- package/dist/detectors/alnum-number.d.ts.map +1 -0
- package/dist/detectors/alnum-number.js +11 -0
- package/dist/detectors/alnum-number.js.map +1 -0
- package/dist/detectors/asker-voice.d.ts +6 -0
- package/dist/detectors/asker-voice.d.ts.map +1 -0
- package/dist/detectors/asker-voice.js +18 -0
- package/dist/detectors/asker-voice.js.map +1 -0
- package/dist/detectors/bare-comparative.d.ts +6 -0
- package/dist/detectors/bare-comparative.d.ts.map +1 -1
- package/dist/detectors/bare-comparative.js +48 -2
- package/dist/detectors/bare-comparative.js.map +1 -1
- package/dist/detectors/blank-structure.d.ts.map +1 -1
- package/dist/detectors/blank-structure.js +4 -0
- package/dist/detectors/blank-structure.js.map +1 -1
- package/dist/detectors/bold-emphasis.d.ts +6 -0
- package/dist/detectors/bold-emphasis.d.ts.map +1 -0
- package/dist/detectors/bold-emphasis.js +38 -0
- package/dist/detectors/bold-emphasis.js.map +1 -0
- package/dist/detectors/bold-label.d.ts +2 -0
- package/dist/detectors/bold-label.d.ts.map +1 -1
- package/dist/detectors/bold-label.js +2 -0
- package/dist/detectors/bold-label.js.map +1 -1
- package/dist/detectors/broken-link.d.ts.map +1 -1
- package/dist/detectors/broken-link.js +13 -4
- package/dist/detectors/broken-link.js.map +1 -1
- package/dist/detectors/case-citation.d.ts +15 -0
- package/dist/detectors/case-citation.d.ts.map +1 -0
- package/dist/detectors/case-citation.js +50 -0
- package/dist/detectors/case-citation.js.map +1 -0
- package/dist/detectors/char-shape.d.ts.map +1 -1
- package/dist/detectors/char-shape.js +112 -20
- package/dist/detectors/char-shape.js.map +1 -1
- package/dist/detectors/citation-entry.d.ts +4 -0
- package/dist/detectors/citation-entry.d.ts.map +1 -1
- package/dist/detectors/citation-entry.js +17 -5
- package/dist/detectors/citation-entry.js.map +1 -1
- package/dist/detectors/citation-marks.d.ts +8 -0
- package/dist/detectors/citation-marks.d.ts.map +1 -1
- package/dist/detectors/citation-marks.js +74 -13
- package/dist/detectors/citation-marks.js.map +1 -1
- package/dist/detectors/citation-note.d.ts +18 -0
- package/dist/detectors/citation-note.d.ts.map +1 -0
- package/dist/detectors/citation-note.js +60 -0
- package/dist/detectors/citation-note.js.map +1 -0
- package/dist/detectors/citation-style.d.ts.map +1 -1
- package/dist/detectors/citation-style.js +3 -1
- package/dist/detectors/citation-style.js.map +1 -1
- package/dist/detectors/clause-shape.d.ts.map +1 -1
- package/dist/detectors/clause-shape.js +24 -2
- package/dist/detectors/clause-shape.js.map +1 -1
- package/dist/detectors/coordinate-adjective.d.ts +15 -0
- package/dist/detectors/coordinate-adjective.d.ts.map +1 -0
- package/dist/detectors/coordinate-adjective.js +34 -0
- package/dist/detectors/coordinate-adjective.js.map +1 -0
- package/dist/detectors/date-run.d.ts +15 -0
- package/dist/detectors/date-run.d.ts.map +1 -0
- package/dist/detectors/date-run.js +35 -0
- package/dist/detectors/date-run.js.map +1 -0
- package/dist/detectors/date-year.d.ts +5 -2
- package/dist/detectors/date-year.d.ts.map +1 -1
- package/dist/detectors/date-year.js +27 -11
- package/dist/detectors/date-year.js.map +1 -1
- package/dist/detectors/dateline.d.ts +16 -0
- package/dist/detectors/dateline.d.ts.map +1 -0
- package/dist/detectors/dateline.js +34 -0
- package/dist/detectors/dateline.js.map +1 -0
- package/dist/detectors/defined-term-form.d.ts +5 -2
- package/dist/detectors/defined-term-form.d.ts.map +1 -1
- package/dist/detectors/defined-term-form.js +18 -7
- package/dist/detectors/defined-term-form.js.map +1 -1
- package/dist/detectors/definition-scope-unit.d.ts +9 -0
- package/dist/detectors/definition-scope-unit.d.ts.map +1 -0
- package/dist/detectors/definition-scope-unit.js +67 -0
- package/dist/detectors/definition-scope-unit.js.map +1 -0
- package/dist/detectors/definition-use.d.ts.map +1 -1
- package/dist/detectors/definition-use.js +11 -3
- package/dist/detectors/definition-use.js.map +1 -1
- package/dist/detectors/division-label-separator.d.ts +8 -0
- package/dist/detectors/division-label-separator.d.ts.map +1 -0
- package/dist/detectors/division-label-separator.js +22 -0
- package/dist/detectors/division-label-separator.js.map +1 -0
- package/dist/detectors/document-shape.d.ts +6 -0
- package/dist/detectors/document-shape.d.ts.map +1 -1
- package/dist/detectors/document-shape.js +22 -1
- package/dist/detectors/document-shape.js.map +1 -1
- package/dist/detectors/doubled-punctuation.d.ts.map +1 -1
- package/dist/detectors/doubled-punctuation.js +16 -1
- package/dist/detectors/doubled-punctuation.js.map +1 -1
- package/dist/detectors/doubled-word.d.ts.map +1 -1
- package/dist/detectors/doubled-word.js +15 -2
- package/dist/detectors/doubled-word.js.map +1 -1
- package/dist/detectors/email-letter.d.ts +4 -1
- package/dist/detectors/email-letter.d.ts.map +1 -1
- package/dist/detectors/email-letter.js +14 -6
- package/dist/detectors/email-letter.js.map +1 -1
- package/dist/detectors/empty-intensifier.d.ts +11 -0
- package/dist/detectors/empty-intensifier.d.ts.map +1 -0
- package/dist/detectors/empty-intensifier.js +28 -0
- package/dist/detectors/empty-intensifier.js.map +1 -0
- package/dist/detectors/en-shape.d.ts.map +1 -1
- package/dist/detectors/en-shape.js +9 -5
- package/dist/detectors/en-shape.js.map +1 -1
- package/dist/detectors/example-baseline.d.ts +7 -0
- package/dist/detectors/example-baseline.d.ts.map +1 -0
- package/dist/detectors/example-baseline.js +21 -0
- package/dist/detectors/example-baseline.js.map +1 -0
- package/dist/detectors/figure-number-list.d.ts +24 -0
- package/dist/detectors/figure-number-list.d.ts.map +1 -0
- package/dist/detectors/figure-number-list.js +78 -0
- package/dist/detectors/figure-number-list.js.map +1 -0
- package/dist/detectors/figure-order.d.ts +10 -0
- package/dist/detectors/figure-order.d.ts.map +1 -1
- package/dist/detectors/figure-order.js +36 -2
- package/dist/detectors/figure-order.js.map +1 -1
- package/dist/detectors/fullwidth-alnum.d.ts.map +1 -1
- package/dist/detectors/fullwidth-alnum.js +26 -5
- package/dist/detectors/fullwidth-alnum.js.map +1 -1
- package/dist/detectors/grade-ladder.d.ts +3 -0
- package/dist/detectors/grade-ladder.d.ts.map +1 -0
- package/dist/detectors/grade-ladder.js +19 -0
- package/dist/detectors/grade-ladder.js.map +1 -0
- package/dist/detectors/gram-furniture.d.ts +5 -0
- package/dist/detectors/gram-furniture.d.ts.map +1 -1
- package/dist/detectors/gram-furniture.js +8 -0
- package/dist/detectors/gram-furniture.js.map +1 -1
- package/dist/detectors/heading-case.d.ts +7 -0
- package/dist/detectors/heading-case.d.ts.map +1 -1
- package/dist/detectors/heading-case.js +10 -2
- package/dist/detectors/heading-case.js.map +1 -1
- package/dist/detectors/heading-end-mark.d.ts.map +1 -1
- package/dist/detectors/heading-end-mark.js +9 -3
- package/dist/detectors/heading-end-mark.js.map +1 -1
- package/dist/detectors/heading-numbering.d.ts.map +1 -1
- package/dist/detectors/heading-numbering.js +2 -1
- package/dist/detectors/heading-numbering.js.map +1 -1
- package/dist/detectors/humble-for-others.d.ts +4 -0
- package/dist/detectors/humble-for-others.d.ts.map +1 -0
- package/dist/detectors/humble-for-others.js +53 -0
- package/dist/detectors/humble-for-others.js.map +1 -0
- package/dist/detectors/kanji-name-edge.d.ts +31 -0
- package/dist/detectors/kanji-name-edge.d.ts.map +1 -0
- package/dist/detectors/kanji-name-edge.js +64 -0
- package/dist/detectors/kanji-name-edge.js.map +1 -0
- package/dist/detectors/kanji-run-pieces.d.ts +23 -0
- package/dist/detectors/kanji-run-pieces.d.ts.map +1 -0
- package/dist/detectors/kanji-run-pieces.js +48 -0
- package/dist/detectors/kanji-run-pieces.js.map +1 -0
- package/dist/detectors/kutoten-consistency.d.ts.map +1 -1
- package/dist/detectors/kutoten-consistency.js +9 -2
- package/dist/detectors/kutoten-consistency.js.map +1 -1
- package/dist/detectors/lead-in-dash.d.ts +7 -0
- package/dist/detectors/lead-in-dash.d.ts.map +1 -0
- package/dist/detectors/lead-in-dash.js +41 -0
- package/dist/detectors/lead-in-dash.js.map +1 -0
- package/dist/detectors/lexicon.d.ts.map +1 -1
- package/dist/detectors/lexicon.js +9 -4
- package/dist/detectors/lexicon.js.map +1 -1
- package/dist/detectors/licence-notice.d.ts +9 -0
- package/dist/detectors/licence-notice.d.ts.map +1 -0
- package/dist/detectors/licence-notice.js +23 -0
- package/dist/detectors/licence-notice.js.map +1 -0
- package/dist/detectors/link-label.d.ts +3 -0
- package/dist/detectors/link-label.d.ts.map +1 -0
- package/dist/detectors/link-label.js +15 -0
- package/dist/detectors/link-label.js.map +1 -0
- package/dist/detectors/link-shape.d.ts +4 -1
- package/dist/detectors/link-shape.d.ts.map +1 -1
- package/dist/detectors/link-shape.js +7 -3
- package/dist/detectors/link-shape.js.map +1 -1
- package/dist/detectors/list-comma-aside.d.ts +14 -0
- package/dist/detectors/list-comma-aside.d.ts.map +1 -0
- package/dist/detectors/list-comma-aside.js +49 -0
- package/dist/detectors/list-comma-aside.js.map +1 -0
- package/dist/detectors/list-lead-in.d.ts.map +1 -1
- package/dist/detectors/list-lead-in.js +29 -4
- package/dist/detectors/list-lead-in.js.map +1 -1
- package/dist/detectors/list-parallel.d.ts.map +1 -1
- package/dist/detectors/list-parallel.js +51 -10
- package/dist/detectors/list-parallel.js.map +1 -1
- package/dist/detectors/list-sentence.d.ts +2 -0
- package/dist/detectors/list-sentence.d.ts.map +1 -1
- package/dist/detectors/list-sentence.js.map +1 -1
- package/dist/detectors/mark-shape.d.ts +2 -0
- package/dist/detectors/mark-shape.d.ts.map +1 -1
- package/dist/detectors/mark-shape.js +19 -2
- package/dist/detectors/mark-shape.js.map +1 -1
- package/dist/detectors/markdown-slip.d.ts.map +1 -1
- package/dist/detectors/markdown-slip.js +24 -10
- package/dist/detectors/markdown-slip.js.map +1 -1
- package/dist/detectors/missing-final-period.d.ts +2 -1
- package/dist/detectors/missing-final-period.d.ts.map +1 -1
- package/dist/detectors/missing-final-period.js +28 -3
- package/dist/detectors/missing-final-period.js.map +1 -1
- package/dist/detectors/name-list-sentence.d.ts +3 -0
- package/dist/detectors/name-list-sentence.d.ts.map +1 -0
- package/dist/detectors/name-list-sentence.js +26 -0
- package/dist/detectors/name-list-sentence.js.map +1 -0
- package/dist/detectors/name-variant-reference-list.d.ts +14 -0
- package/dist/detectors/name-variant-reference-list.d.ts.map +1 -0
- package/dist/detectors/name-variant-reference-list.js +21 -0
- package/dist/detectors/name-variant-reference-list.js.map +1 -0
- package/dist/detectors/name-variant.d.ts.map +1 -1
- package/dist/detectors/name-variant.js +4 -3
- package/dist/detectors/name-variant.js.map +1 -1
- package/dist/detectors/next-word.d.ts +4 -1
- package/dist/detectors/next-word.d.ts.map +1 -1
- package/dist/detectors/next-word.js +26 -9
- package/dist/detectors/next-word.js.map +1 -1
- package/dist/detectors/number-style.d.ts.map +1 -1
- package/dist/detectors/number-style.js +16 -1
- package/dist/detectors/number-style.js.map +1 -1
- package/dist/detectors/numbering-readings.d.ts +8 -0
- package/dist/detectors/numbering-readings.d.ts.map +1 -0
- package/dist/detectors/numbering-readings.js +17 -0
- package/dist/detectors/numbering-readings.js.map +1 -0
- package/dist/detectors/numeral-opener.d.ts +5 -2
- package/dist/detectors/numeral-opener.d.ts.map +1 -1
- package/dist/detectors/numeral-opener.js +30 -4
- package/dist/detectors/numeral-opener.js.map +1 -1
- package/dist/detectors/open-end-names.d.ts.map +1 -1
- package/dist/detectors/open-end-names.js +23 -2
- package/dist/detectors/open-end-names.js.map +1 -1
- package/dist/detectors/open-end-scope.d.ts +2 -0
- package/dist/detectors/open-end-scope.d.ts.map +1 -1
- package/dist/detectors/open-end-scope.js +22 -1
- package/dist/detectors/open-end-scope.js.map +1 -1
- package/dist/detectors/opener-phrase.d.ts +6 -0
- package/dist/detectors/opener-phrase.d.ts.map +1 -0
- package/dist/detectors/opener-phrase.js +15 -0
- package/dist/detectors/opener-phrase.js.map +1 -0
- package/dist/detectors/opener-tail.d.ts +7 -0
- package/dist/detectors/opener-tail.d.ts.map +1 -0
- package/dist/detectors/opener-tail.js +18 -0
- package/dist/detectors/opener-tail.js.map +1 -0
- package/dist/detectors/organisation-run.d.ts +2 -1
- package/dist/detectors/organisation-run.d.ts.map +1 -1
- package/dist/detectors/organisation-run.js +3 -2
- package/dist/detectors/organisation-run.js.map +1 -1
- package/dist/detectors/orthographic-variant.d.ts.map +1 -1
- package/dist/detectors/orthographic-variant.js +52 -81
- 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/over-general-claim.d.ts +11 -0
- package/dist/detectors/over-general-claim.d.ts.map +1 -0
- package/dist/detectors/over-general-claim.js +37 -0
- package/dist/detectors/over-general-claim.js.map +1 -0
- package/dist/detectors/oxford-comma.d.ts.map +1 -1
- package/dist/detectors/oxford-comma.js +20 -1
- package/dist/detectors/oxford-comma.js.map +1 -1
- package/dist/detectors/paragraph-run.d.ts +2 -1
- package/dist/detectors/paragraph-run.d.ts.map +1 -1
- package/dist/detectors/paragraph-run.js +4 -2
- package/dist/detectors/paragraph-run.js.map +1 -1
- package/dist/detectors/phrase-match.d.ts +6 -1
- package/dist/detectors/phrase-match.d.ts.map +1 -1
- package/dist/detectors/phrase-match.js +5 -0
- package/dist/detectors/phrase-match.js.map +1 -1
- package/dist/detectors/placeholder-text.d.ts +1 -1
- package/dist/detectors/placeholder-text.d.ts.map +1 -1
- package/dist/detectors/placeholder-text.js +57 -1
- package/dist/detectors/placeholder-text.js.map +1 -1
- package/dist/detectors/q-fragment-answer.d.ts +15 -0
- package/dist/detectors/q-fragment-answer.d.ts.map +1 -0
- package/dist/detectors/q-fragment-answer.js +51 -0
- package/dist/detectors/q-fragment-answer.js.map +1 -0
- package/dist/detectors/quotation-paragraph.d.ts +10 -0
- package/dist/detectors/quotation-paragraph.d.ts.map +1 -0
- package/dist/detectors/quotation-paragraph.js +22 -0
- package/dist/detectors/quotation-paragraph.js.map +1 -0
- package/dist/detectors/quoted-sentences.d.ts +6 -0
- package/dist/detectors/quoted-sentences.d.ts.map +1 -0
- package/dist/detectors/quoted-sentences.js +61 -0
- package/dist/detectors/quoted-sentences.js.map +1 -0
- package/dist/detectors/quoted-wording.d.ts +9 -0
- package/dist/detectors/quoted-wording.d.ts.map +1 -0
- package/dist/detectors/quoted-wording.js +18 -0
- package/dist/detectors/quoted-wording.js.map +1 -0
- package/dist/detectors/register-neutral-shape.d.ts +4 -0
- package/dist/detectors/register-neutral-shape.d.ts.map +1 -0
- package/dist/detectors/register-neutral-shape.js +37 -0
- package/dist/detectors/register-neutral-shape.js.map +1 -0
- package/dist/detectors/registry/bold-emphasis.d.ts +3 -0
- package/dist/detectors/registry/bold-emphasis.d.ts.map +1 -0
- package/dist/detectors/registry/bold-emphasis.js +3 -0
- package/dist/detectors/registry/bold-emphasis.js.map +1 -0
- package/dist/detectors/registry/empty-intensifier.d.ts +3 -0
- package/dist/detectors/registry/empty-intensifier.d.ts.map +1 -0
- package/dist/detectors/registry/empty-intensifier.js +3 -0
- package/dist/detectors/registry/empty-intensifier.js.map +1 -0
- package/dist/detectors/registry/humble-for-others.d.ts +3 -0
- package/dist/detectors/registry/humble-for-others.d.ts.map +1 -0
- package/dist/detectors/registry/humble-for-others.js +3 -0
- package/dist/detectors/registry/humble-for-others.js.map +1 -0
- package/dist/detectors/registry/over-general-claim.d.ts +3 -0
- package/dist/detectors/registry/over-general-claim.d.ts.map +1 -0
- package/dist/detectors/registry/over-general-claim.js +3 -0
- package/dist/detectors/registry/over-general-claim.js.map +1 -0
- package/dist/detectors/registry/q-fragment-answer.d.ts +3 -0
- package/dist/detectors/registry/q-fragment-answer.d.ts.map +1 -0
- package/dist/detectors/registry/q-fragment-answer.js +3 -0
- package/dist/detectors/registry/q-fragment-answer.js.map +1 -0
- package/dist/detectors/registry/unused-definition.d.ts.map +1 -1
- package/dist/detectors/registry/unused-definition.js +2 -2
- package/dist/detectors/registry/unused-definition.js.map +1 -1
- package/dist/detectors/registry/weasel-word.d.ts +3 -0
- package/dist/detectors/registry/weasel-word.d.ts.map +1 -0
- package/dist/detectors/registry/weasel-word.js +3 -0
- package/dist/detectors/registry/weasel-word.js.map +1 -0
- package/dist/detectors/relative-dates.d.ts.map +1 -1
- package/dist/detectors/relative-dates.js +1 -0
- package/dist/detectors/relative-dates.js.map +1 -1
- package/dist/detectors/relative-pronoun-mix.d.ts.map +1 -1
- package/dist/detectors/relative-pronoun-mix.js +9 -2
- package/dist/detectors/relative-pronoun-mix.js.map +1 -1
- package/dist/detectors/reported-speech.d.ts +14 -0
- package/dist/detectors/reported-speech.d.ts.map +1 -0
- package/dist/detectors/reported-speech.js +36 -0
- package/dist/detectors/reported-speech.js.map +1 -0
- package/dist/detectors/request-owner.d.ts +7 -1
- package/dist/detectors/request-owner.d.ts.map +1 -1
- package/dist/detectors/request-owner.js +45 -2
- package/dist/detectors/request-owner.js.map +1 -1
- package/dist/detectors/revision-date.d.ts +30 -0
- package/dist/detectors/revision-date.d.ts.map +1 -0
- package/dist/detectors/revision-date.js +55 -0
- package/dist/detectors/revision-date.js.map +1 -0
- package/dist/detectors/sentence-counts.d.ts +7 -2
- package/dist/detectors/sentence-counts.d.ts.map +1 -1
- package/dist/detectors/sentence-counts.js +31 -7
- package/dist/detectors/sentence-counts.js.map +1 -1
- package/dist/detectors/sentence-ending.d.ts +7 -0
- package/dist/detectors/sentence-ending.d.ts.map +1 -1
- package/dist/detectors/sentence-ending.js +19 -7
- package/dist/detectors/sentence-ending.js.map +1 -1
- package/dist/detectors/sentence-length.d.ts.map +1 -1
- package/dist/detectors/sentence-length.js +23 -2
- package/dist/detectors/sentence-length.js.map +1 -1
- package/dist/detectors/sentence-load.d.ts +3 -1
- package/dist/detectors/sentence-load.d.ts.map +1 -1
- package/dist/detectors/sentence-load.js +6 -2
- package/dist/detectors/sentence-load.js.map +1 -1
- package/dist/detectors/sentence-title.d.ts +16 -0
- package/dist/detectors/sentence-title.d.ts.map +1 -0
- package/dist/detectors/sentence-title.js +43 -0
- package/dist/detectors/sentence-title.js.map +1 -0
- package/dist/detectors/signals.d.ts +4 -0
- package/dist/detectors/signals.d.ts.map +1 -1
- package/dist/detectors/signals.js +30 -24
- package/dist/detectors/signals.js.map +1 -1
- package/dist/detectors/spreadsheet-grid.d.ts +3 -0
- package/dist/detectors/spreadsheet-grid.d.ts.map +1 -0
- package/dist/detectors/spreadsheet-grid.js +16 -0
- package/dist/detectors/spreadsheet-grid.js.map +1 -0
- package/dist/detectors/structure-tree.d.ts.map +1 -1
- package/dist/detectors/structure-tree.js +12 -17
- package/dist/detectors/structure-tree.js.map +1 -1
- package/dist/detectors/structure.d.ts.map +1 -1
- package/dist/detectors/structure.js +8 -2
- package/dist/detectors/structure.js.map +1 -1
- package/dist/detectors/superlative-phrase.d.ts +14 -0
- package/dist/detectors/superlative-phrase.d.ts.map +1 -0
- package/dist/detectors/superlative-phrase.js +52 -0
- package/dist/detectors/superlative-phrase.js.map +1 -0
- package/dist/detectors/superlative-scope.d.ts +1 -0
- package/dist/detectors/superlative-scope.d.ts.map +1 -1
- package/dist/detectors/superlative-scope.js +15 -1
- package/dist/detectors/superlative-scope.js.map +1 -1
- package/dist/detectors/titled-run.d.ts +2 -0
- package/dist/detectors/titled-run.d.ts.map +1 -1
- package/dist/detectors/titled-run.js +7 -0
- package/dist/detectors/titled-run.js.map +1 -1
- package/dist/detectors/token-shape.d.ts.map +1 -1
- package/dist/detectors/token-shape.js +15 -2
- package/dist/detectors/token-shape.js.map +1 -1
- package/dist/detectors/typewritten.d.ts +3 -0
- package/dist/detectors/typewritten.d.ts.map +1 -0
- package/dist/detectors/typewritten.js +6 -0
- package/dist/detectors/typewritten.js.map +1 -0
- package/dist/detectors/undefined-term.d.ts +7 -1
- package/dist/detectors/undefined-term.d.ts.map +1 -1
- package/dist/detectors/undefined-term.js +34 -11
- package/dist/detectors/undefined-term.js.map +1 -1
- package/dist/detectors/unfilled-placeholder.d.ts +4 -1
- package/dist/detectors/unfilled-placeholder.d.ts.map +1 -1
- package/dist/detectors/unfilled-placeholder.js +8 -3
- package/dist/detectors/unfilled-placeholder.js.map +1 -1
- package/dist/detectors/unknown-word.d.ts +5 -0
- package/dist/detectors/unknown-word.d.ts.map +1 -1
- package/dist/detectors/unknown-word.js +9 -1
- package/dist/detectors/unknown-word.js.map +1 -1
- package/dist/detectors/unused-definition-kept.d.ts +12 -0
- package/dist/detectors/unused-definition-kept.d.ts.map +1 -0
- package/dist/detectors/unused-definition-kept.js +61 -0
- package/dist/detectors/unused-definition-kept.js.map +1 -0
- package/dist/detectors/weasel-word.d.ts +3 -0
- package/dist/detectors/weasel-word.d.ts.map +1 -0
- package/dist/detectors/weasel-word.js +22 -0
- package/dist/detectors/weasel-word.js.map +1 -0
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +10 -5
- package/dist/document.js.map +1 -1
- package/dist/field-label-heading.d.ts +8 -0
- package/dist/field-label-heading.d.ts.map +1 -0
- package/dist/field-label-heading.js +32 -0
- package/dist/field-label-heading.js.map +1 -0
- package/dist/furigana.d.ts +2 -2
- package/dist/furigana.d.ts.map +1 -1
- package/dist/furigana.js +9 -5
- package/dist/furigana.js.map +1 -1
- package/dist/genre-load.d.ts.map +1 -1
- package/dist/genre-load.js +3 -2
- package/dist/genre-load.js.map +1 -1
- package/dist/heading-numbering.d.ts +7 -1
- package/dist/heading-numbering.d.ts.map +1 -1
- package/dist/heading-numbering.js +15 -1
- package/dist/heading-numbering.js.map +1 -1
- package/dist/honorific-group.d.ts +8 -0
- package/dist/honorific-group.d.ts.map +1 -0
- package/dist/honorific-group.js +15 -0
- package/dist/honorific-group.js.map +1 -0
- package/dist/html/html-elements.d.ts +1 -0
- package/dist/html/html-elements.d.ts.map +1 -1
- package/dist/html/html-elements.js +1 -1
- package/dist/html/html-elements.js.map +1 -1
- package/dist/html/html-footnote-marks.d.ts.map +1 -1
- package/dist/html/html-footnote-marks.js +10 -4
- package/dist/html/html-footnote-marks.js.map +1 -1
- package/dist/html/html-heading-links.d.ts +2 -5
- package/dist/html/html-heading-links.d.ts.map +1 -1
- package/dist/html/html-heading-links.js +19 -2
- package/dist/html/html-heading-links.js.map +1 -1
- package/dist/html/html-links.d.ts +5 -0
- package/dist/html/html-links.d.ts.map +1 -0
- package/dist/html/html-links.js +59 -0
- package/dist/html/html-links.js.map +1 -0
- package/dist/html/html-markdown.d.ts.map +1 -1
- package/dist/html/html-markdown.js +30 -35
- package/dist/html/html-markdown.js.map +1 -1
- package/dist/html/html-section-number.d.ts +5 -0
- package/dist/html/html-section-number.d.ts.map +1 -0
- package/dist/html/html-section-number.js +19 -0
- package/dist/html/html-section-number.js.map +1 -0
- package/dist/html/html-tables.d.ts +1 -1
- package/dist/html/html-tables.d.ts.map +1 -1
- package/dist/html/html-tables.js +24 -7
- package/dist/html/html-tables.js.map +1 -1
- package/dist/html/html-widgets.d.ts +7 -0
- package/dist/html/html-widgets.d.ts.map +1 -1
- package/dist/html/html-widgets.js +33 -2
- package/dist/html/html-widgets.js.map +1 -1
- package/dist/legal-address.d.ts +2 -0
- package/dist/legal-address.d.ts.map +1 -0
- package/dist/legal-address.js +16 -0
- package/dist/legal-address.js.map +1 -0
- package/dist/link-path.d.ts +10 -0
- package/dist/link-path.d.ts.map +1 -0
- package/dist/link-path.js +66 -0
- package/dist/link-path.js.map +1 -0
- package/dist/name-word-form.d.ts +14 -0
- package/dist/name-word-form.d.ts.map +1 -0
- package/dist/name-word-form.js +34 -0
- package/dist/name-word-form.js.map +1 -0
- package/dist/newsletter-issue.d.ts +12 -0
- package/dist/newsletter-issue.d.ts.map +1 -0
- package/dist/newsletter-issue.js +24 -0
- package/dist/newsletter-issue.js.map +1 -0
- package/dist/note-paragraphs.d.ts +8 -0
- package/dist/note-paragraphs.d.ts.map +1 -0
- package/dist/note-paragraphs.js +37 -0
- package/dist/note-paragraphs.js.map +1 -0
- package/dist/paragraph-runs.d.ts +8 -3
- package/dist/paragraph-runs.d.ts.map +1 -1
- package/dist/paragraph-runs.js +29 -3
- package/dist/paragraph-runs.js.map +1 -1
- package/dist/plugin.d.ts +7 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/profile/parse.d.ts.map +1 -1
- package/dist/profile/parse.js +9 -0
- package/dist/profile/parse.js.map +1 -1
- package/dist/return-type.d.ts +2 -0
- package/dist/return-type.d.ts.map +1 -1
- package/dist/return-type.js +34 -15
- package/dist/return-type.js.map +1 -1
- package/dist/rule-offs.d.ts +6 -0
- package/dist/rule-offs.d.ts.map +1 -1
- package/dist/rule-offs.js +6 -0
- package/dist/rule-offs.js.map +1 -1
- package/dist/sentence-load.d.ts.map +1 -1
- package/dist/sentence-load.js +27 -1
- package/dist/sentence-load.js.map +1 -1
- package/dist/single-quoted-span.d.ts +8 -0
- package/dist/single-quoted-span.d.ts.map +1 -0
- package/dist/single-quoted-span.js +30 -0
- package/dist/single-quoted-span.js.map +1 -0
- package/dist/spelling-mention.d.ts +7 -0
- package/dist/spelling-mention.d.ts.map +1 -0
- package/dist/spelling-mention.js +24 -0
- package/dist/spelling-mention.js.map +1 -0
- package/dist/stage-directions.d.ts +12 -0
- package/dist/stage-directions.d.ts.map +1 -0
- package/dist/stage-directions.js +29 -0
- package/dist/stage-directions.js.map +1 -0
- package/dist/stray-space.d.ts.map +1 -1
- package/dist/stray-space.js +19 -4
- package/dist/stray-space.js.map +1 -1
- package/dist/structure/alternative-clause.d.ts +9 -0
- package/dist/structure/alternative-clause.d.ts.map +1 -0
- package/dist/structure/alternative-clause.js +43 -0
- package/dist/structure/alternative-clause.js.map +1 -0
- package/dist/structure/build.d.ts.map +1 -1
- package/dist/structure/build.js +7 -2
- package/dist/structure/build.js.map +1 -1
- package/dist/structure/change-rate.d.ts.map +1 -1
- package/dist/structure/change-rate.js +20 -1
- package/dist/structure/change-rate.js.map +1 -1
- package/dist/structure/cited-elsewhere.d.ts +4 -0
- package/dist/structure/cited-elsewhere.d.ts.map +1 -0
- package/dist/structure/cited-elsewhere.js +15 -0
- package/dist/structure/cited-elsewhere.js.map +1 -0
- package/dist/structure/definition-use.d.ts +7 -4
- package/dist/structure/definition-use.d.ts.map +1 -1
- package/dist/structure/definition-use.js +32 -6
- package/dist/structure/definition-use.js.map +1 -1
- package/dist/structure/issues.d.ts +3 -1
- package/dist/structure/issues.d.ts.map +1 -1
- package/dist/structure/issues.js +31 -6
- package/dist/structure/issues.js.map +1 -1
- package/dist/structure/joined-labels.d.ts +8 -0
- package/dist/structure/joined-labels.d.ts.map +1 -0
- package/dist/structure/joined-labels.js +19 -0
- package/dist/structure/joined-labels.js.map +1 -0
- package/dist/structure/numbering.d.ts +10 -1
- package/dist/structure/numbering.d.ts.map +1 -1
- package/dist/structure/numbering.js +13 -5
- package/dist/structure/numbering.js.map +1 -1
- package/dist/structure/restated-name.d.ts +7 -0
- package/dist/structure/restated-name.d.ts.map +1 -0
- package/dist/structure/restated-name.js +25 -0
- package/dist/structure/restated-name.js.map +1 -0
- package/dist/structure/summary-lines.d.ts +15 -0
- package/dist/structure/summary-lines.d.ts.map +1 -0
- package/dist/structure/summary-lines.js +19 -0
- package/dist/structure/summary-lines.js.map +1 -0
- package/dist/structure/title-lines.d.ts.map +1 -1
- package/dist/structure/title-lines.js +41 -8
- package/dist/structure/title-lines.js.map +1 -1
- package/dist/structure/unit-word.d.ts +6 -0
- package/dist/structure/unit-word.d.ts.map +1 -1
- package/dist/structure/unit-word.js +10 -0
- package/dist/structure/unit-word.js.map +1 -1
- package/dist/structure/wrapped-reference.d.ts +10 -0
- package/dist/structure/wrapped-reference.d.ts.map +1 -0
- package/dist/structure/wrapped-reference.js +17 -0
- package/dist/structure/wrapped-reference.js.map +1 -0
- package/dist/subheading-line.d.ts +4 -1
- package/dist/subheading-line.d.ts.map +1 -1
- package/dist/subheading-line.js +14 -2
- package/dist/subheading-line.js.map +1 -1
- package/dist/topic-clause.d.ts.map +1 -1
- package/dist/topic-clause.js +15 -1
- package/dist/topic-clause.js.map +1 -1
- package/dist/voice-parts.d.ts +12 -0
- package/dist/voice-parts.d.ts.map +1 -0
- package/dist/voice-parts.js +8 -0
- package/dist/voice-parts.js.map +1 -0
- package/dist/word-use.d.ts +43 -0
- package/dist/word-use.d.ts.map +1 -0
- package/dist/word-use.js +109 -0
- package/dist/word-use.js.map +1 -0
- package/genres.yaml +4 -0
- package/package.json +3 -3
- package/profiles/play.yaml +14 -0
- package/profiles/verse.yaml +14 -0
- package/rules/acronym-expansion-conflict.yaml +2 -2
- package/rules/adversative-ga-repeat.yaml +3 -3
- package/rules/agreement-slip.yaml +20 -7
- package/rules/announced-count-mismatch.yaml +2 -2
- package/rules/article-sound.yaml +2 -2
- package/rules/bold-emphasis.yaml +113 -0
- package/rules/bold-label-list.yaml +38 -5
- package/rules/bracket-nesting.yaml +2 -2
- package/rules/bracket-width-consistency.yaml +11 -11
- package/rules/citation-reference-mismatch.yaml +2 -2
- package/rules/clause-chain.yaml +2 -0
- package/rules/colloquial-opener.yaml +2 -2
- package/rules/colon-lead-in.yaml +2 -2
- package/rules/comparative-without-baseline.yaml +2 -2
- package/rules/concrete-evidence-density.yaml +1 -0
- package/rules/dangling-reference.yaml +2 -2
- package/rules/date-weekday-mismatch.yaml +2 -2
- package/rules/date-without-year.yaml +5 -5
- package/rules/defined-name-repeated.yaml +2 -2
- package/rules/defined-term-form.yaml +2 -2
- package/rules/demonstrative-opener-run.yaml +4 -2
- package/rules/doubled-punctuation.yaml +2 -2
- package/rules/doubled-word.yaml +2 -2
- package/rules/duplicate-definition.yaml +2 -2
- package/rules/email-greeting-closing.yaml +2 -2
- package/rules/empty-intensifier.yaml +3 -3
- package/rules/figure-reference-order.yaml +2 -2
- package/rules/fullwidth-alnum-consistency.yaml +2 -2
- package/rules/heading-end-punctuation-mix.yaml +2 -2
- package/rules/heading-numbering-mix.yaml +2 -2
- package/rules/humble-for-others.yaml +4 -3
- package/rules/hyphen-as-dash.yaml +2 -2
- package/rules/kutoten-consistency.yaml +2 -2
- package/rules/latin-spacing.yaml +3 -2
- package/rules/link-text-url-mismatch.yaml +4 -4
- package/rules/list-item-form-mix.yaml +21 -6
- package/rules/max-kanji-continuous.yaml +31 -4
- package/rules/max-paragraph-length.yaml +2 -0
- package/rules/max-sentence-length.yaml +2 -2
- package/rules/max-ten.yaml +1 -0
- package/rules/missing-final-period.yaml +2 -2
- package/rules/name-variant.yaml +2 -2
- package/rules/ngram-repetition.yaml +2 -2
- package/rules/no-doubled-joshi.yaml +2 -2
- package/rules/no-em-dash.yaml +2 -2
- package/rules/no-mixed-desumasu.yaml +3 -3
- package/rules/nominalization.yaml +8 -2
- package/rules/number-style-consistency.yaml +2 -2
- package/rules/numbering-gap.yaml +2 -2
- package/rules/numeral-sentence-start.yaml +2 -2
- package/rules/one-sentence-paragraph-run.yaml +3 -2
- package/rules/orthographic-variant.yaml +2 -2
- package/rules/over-general-claim.yaml +73 -0
- package/rules/oxford-comma-consistency.yaml +3 -3
- package/rules/q-fragment-answer.yaml +69 -0
- package/rules/relative-date-mismatch.yaml +2 -2
- package/rules/repeated-sentence-ending.yaml +2 -0
- package/rules/request-without-deadline.yaml +2 -2
- package/rules/requirement-smell.yaml +2 -2
- package/rules/return-type-mismatch.yaml +2 -2
- package/rules/sentence-initial-conjunction-run.yaml +2 -2
- package/rules/sentence-rhythm.yaml +7 -4
- package/rules/stray-space.yaml +2 -2
- package/rules/taigen-dome-in-prose.yaml +2 -2
- package/rules/tari-unpaired.yaml +2 -2
- package/rules/teki-overuse.yaml +2 -2
- package/rules/title-case-consistency.yaml +4 -4
- package/rules/title-length.yaml +9 -2
- package/rules/topic-predicate-distance.yaml +4 -2
- package/rules/undefined-acronym.yaml +4 -2
- package/rules/undefined-term.yaml +2 -2
- package/rules/unfilled-placeholder.yaml +4 -4
- package/rules/unknown-word.yaml +2 -2
- package/rules/unqualified-superlative.yaml +2 -2
- package/rules/unused-definition.yaml +2 -2
- package/rules/use-before-definition.yaml +2 -2
- package/rules/weasel-word.yaml +4 -3
- package/rules/which-that-consistency.yaml +2 -2
- package/rules/wordy-phrase.yaml +2 -2
- package/skills/chaff/SKILL.md +11 -6
- package/src/acronym-expansions.ts +11 -1
- package/src/ai-score/human-shares.ts +36 -8
- package/src/alternative-words.ts +20 -0
- package/src/article-h-style.ts +16 -0
- package/src/bracket-annotation.ts +57 -0
- package/src/compare/misopened-quotes.ts +26 -0
- package/src/compare/outcome.ts +11 -2
- package/src/compare/render.ts +20 -7
- package/src/compare/respelled.ts +68 -0
- package/src/compare/text-atoms.ts +9 -2
- package/src/compare/text.ts +12 -3
- package/src/contact-entry.ts +19 -0
- package/src/contraction-words.ts +11 -0
- package/src/derived/relative-dates.ts +32 -1
- package/src/detectors/abnf-grammar.ts +79 -0
- package/src/detectors/acronym-context.ts +42 -0
- package/src/detectors/acronym-expansion.ts +31 -4
- package/src/detectors/acronym-gloss.ts +34 -0
- package/src/detectors/acronym-known.ts +11 -3
- package/src/detectors/adversative-ga.ts +26 -0
- package/src/detectors/agreement-slip.ts +33 -4
- package/src/detectors/ai-phrasing.ts +7 -3
- package/src/detectors/alnum-number.ts +11 -0
- package/src/detectors/asker-voice.ts +24 -0
- package/src/detectors/bare-comparative.ts +64 -2
- package/src/detectors/blank-structure.ts +9 -0
- package/src/detectors/bold-emphasis.ts +45 -0
- package/src/detectors/bold-label.ts +3 -0
- package/src/detectors/broken-link.ts +13 -4
- package/src/detectors/case-citation.ts +70 -0
- package/src/detectors/char-shape.ts +143 -25
- package/src/detectors/citation-entry.ts +22 -7
- package/src/detectors/citation-marks.ts +97 -15
- package/src/detectors/citation-note.ts +78 -0
- package/src/detectors/citation-style.ts +6 -1
- package/src/detectors/clause-shape.ts +27 -2
- package/src/detectors/coordinate-adjective.ts +41 -0
- package/src/detectors/date-run.ts +39 -0
- package/src/detectors/date-year.ts +44 -10
- package/src/detectors/dateline.ts +48 -0
- package/src/detectors/defined-term-form.ts +24 -7
- package/src/detectors/definition-scope-unit.ts +90 -0
- package/src/detectors/definition-use.ts +18 -5
- package/src/detectors/division-label-separator.ts +25 -0
- package/src/detectors/document-shape.ts +24 -1
- package/src/detectors/doubled-punctuation.ts +19 -1
- package/src/detectors/doubled-word.ts +21 -2
- package/src/detectors/email-letter.ts +14 -6
- package/src/detectors/empty-intensifier.ts +36 -0
- package/src/detectors/en-shape.ts +11 -5
- package/src/detectors/example-baseline.ts +31 -0
- package/src/detectors/figure-number-list.ts +101 -0
- package/src/detectors/figure-order.ts +43 -2
- package/src/detectors/fullwidth-alnum.ts +36 -6
- package/src/detectors/grade-ladder.ts +23 -0
- package/src/detectors/gram-furniture.ts +9 -0
- package/src/detectors/heading-case.ts +11 -2
- package/src/detectors/heading-end-mark.ts +12 -4
- package/src/detectors/heading-numbering.ts +10 -1
- package/src/detectors/humble-for-others.ts +63 -0
- package/src/detectors/kanji-name-edge.ts +79 -0
- package/src/detectors/kanji-run-pieces.ts +60 -0
- package/src/detectors/kutoten-consistency.ts +12 -2
- package/src/detectors/lead-in-dash.ts +43 -0
- package/src/detectors/lexicon.ts +13 -4
- package/src/detectors/licence-notice.ts +30 -0
- package/src/detectors/link-label.ts +17 -0
- package/src/detectors/link-shape.ts +7 -3
- package/src/detectors/list-comma-aside.ts +58 -0
- package/src/detectors/list-lead-in.ts +30 -2
- package/src/detectors/list-parallel.ts +58 -9
- package/src/detectors/list-sentence.ts +2 -0
- package/src/detectors/mark-shape.ts +24 -2
- package/src/detectors/markdown-slip.ts +20 -3
- package/src/detectors/missing-final-period.ts +42 -5
- package/src/detectors/name-list-sentence.ts +28 -0
- package/src/detectors/name-variant-reference-list.ts +34 -0
- package/src/detectors/name-variant.ts +4 -3
- package/src/detectors/next-word.ts +38 -9
- package/src/detectors/number-style.ts +17 -1
- package/src/detectors/numbering-readings.ts +22 -0
- package/src/detectors/numeral-opener.ts +37 -5
- package/src/detectors/open-end-names.ts +23 -2
- package/src/detectors/open-end-scope.ts +32 -2
- package/src/detectors/opener-phrase.ts +15 -0
- package/src/detectors/opener-tail.ts +19 -0
- package/src/detectors/organisation-run.ts +3 -2
- package/src/detectors/orthographic-variant.ts +68 -127
- package/src/detectors/orthography.ts +4 -0
- package/src/detectors/over-general-claim.ts +44 -0
- package/src/detectors/oxford-comma.ts +18 -1
- package/src/detectors/paragraph-run.ts +11 -2
- package/src/detectors/phrase-match.ts +6 -0
- package/src/detectors/placeholder-text.ts +62 -1
- package/src/detectors/q-fragment-answer.ts +64 -0
- package/src/detectors/quotation-paragraph.ts +28 -0
- package/src/detectors/quoted-sentences.ts +62 -0
- package/src/detectors/quoted-wording.ts +28 -0
- package/src/detectors/register-neutral-shape.ts +46 -0
- package/src/detectors/registry/bold-emphasis.ts +4 -0
- package/src/detectors/registry/empty-intensifier.ts +4 -0
- package/src/detectors/registry/humble-for-others.ts +4 -0
- package/src/detectors/registry/over-general-claim.ts +4 -0
- package/src/detectors/registry/q-fragment-answer.ts +4 -0
- package/src/detectors/registry/unused-definition.ts +2 -2
- package/src/detectors/registry/weasel-word.ts +4 -0
- package/src/detectors/relative-dates.ts +1 -0
- package/src/detectors/relative-pronoun-mix.ts +12 -2
- package/src/detectors/reported-speech.ts +37 -0
- package/src/detectors/request-owner.ts +62 -2
- package/src/detectors/revision-date.ts +80 -0
- package/src/detectors/sentence-counts.ts +35 -8
- package/src/detectors/sentence-ending.ts +35 -9
- package/src/detectors/sentence-length.ts +31 -4
- package/src/detectors/sentence-load.ts +6 -2
- package/src/detectors/sentence-title.ts +56 -0
- package/src/detectors/signals.ts +37 -25
- package/src/detectors/spreadsheet-grid.ts +20 -0
- package/src/detectors/structure-tree.ts +13 -17
- package/src/detectors/structure.ts +11 -3
- package/src/detectors/superlative-phrase.ts +57 -0
- package/src/detectors/superlative-scope.ts +16 -1
- package/src/detectors/titled-run.ts +9 -0
- package/src/detectors/token-shape.ts +18 -3
- package/src/detectors/typewritten.ts +7 -0
- package/src/detectors/undefined-term.ts +45 -9
- package/src/detectors/unfilled-placeholder.ts +8 -3
- package/src/detectors/unknown-word.ts +10 -1
- package/src/detectors/unused-definition-kept.ts +80 -0
- package/src/detectors/weasel-word.ts +24 -0
- package/src/document.ts +17 -6
- package/src/field-label-heading.ts +41 -0
- package/src/furigana.ts +9 -5
- package/src/genre-load.ts +3 -2
- package/src/heading-numbering.ts +23 -3
- package/src/honorific-group.ts +22 -0
- package/src/html/html-elements.ts +1 -1
- package/src/html/html-footnote-marks.ts +12 -4
- package/src/html/html-heading-links.ts +25 -2
- package/src/html/html-links.ts +70 -0
- package/src/html/html-markdown.ts +42 -36
- package/src/html/html-section-number.ts +20 -0
- package/src/html/html-tables.ts +29 -7
- package/src/html/html-widgets.ts +48 -1
- package/src/link-path.ts +70 -0
- package/src/name-word-form.ts +42 -0
- package/src/newsletter-issue.ts +38 -0
- package/src/note-paragraphs.ts +48 -0
- package/src/paragraph-runs.ts +38 -4
- package/src/plugin.ts +4 -0
- package/src/profile/parse.ts +11 -0
- package/src/return-type.ts +38 -16
- package/src/rule-offs.ts +10 -0
- package/src/sentence-load.ts +33 -1
- package/src/single-quoted-span.ts +40 -0
- package/src/spelling-mention.ts +30 -0
- package/src/stage-directions.ts +39 -0
- package/src/stray-space.ts +24 -5
- package/src/structure/alternative-clause.ts +46 -0
- package/src/structure/build.ts +13 -2
- package/src/structure/change-rate.ts +21 -1
- package/src/structure/cited-elsewhere.ts +23 -0
- package/src/structure/definition-use.ts +42 -7
- package/src/structure/issues.ts +32 -6
- package/src/structure/joined-labels.ts +24 -0
- package/src/structure/numbering.ts +23 -4
- package/src/structure/restated-name.ts +28 -0
- package/src/structure/summary-lines.ts +26 -0
- package/src/structure/title-lines.ts +40 -2
- package/src/structure/unit-word.ts +12 -0
- package/src/structure/wrapped-reference.ts +25 -0
- package/src/subheading-line.ts +17 -2
- package/src/topic-clause.ts +20 -1
- package/src/voice-parts.ts +11 -0
- package/src/word-use.ts +162 -0
|
@@ -45,8 +45,39 @@ export type TermWords = {
|
|
|
45
45
|
readonly selfNouns: readonly string[];
|
|
46
46
|
/** The term is set in quotes somewhere (「本情報」): defined in a form the structure did not read, or named on purpose. */
|
|
47
47
|
readonly isQuoted: (term: string) => boolean;
|
|
48
|
+
/** Terms the document names in a form the structure does not read as a definition: in quotes, or alone on a list item. */
|
|
49
|
+
readonly named: readonly string[];
|
|
50
|
+
/** What turns a term into another one (本報告書等 after 本報告書): a group the document has to define on its own. */
|
|
51
|
+
readonly groupSuffixes: readonly string[];
|
|
48
52
|
};
|
|
49
53
|
|
|
54
|
+
const QUOTED = /[「『“"](?<term>[^「」『』“”"\n]{1,40})[」』”"]/gu;
|
|
55
|
+
/** An item's number: 2. or 2 and a space, ②, (2). */
|
|
56
|
+
const ITEM_NUMBER = /^\s*(?:[0-90-9]{1,3}[..))]?\s|[①-⑳]|[((][0-90-9]{1,3}[))])/u;
|
|
57
|
+
const ONE_WORD = /^[^\s、。,.「」()()]+$/u;
|
|
58
|
+
|
|
59
|
+
/** A list item holding one word (② 本報告書, 2. 本発明): the label of a definition list, its meaning in the next paragraph. */
|
|
60
|
+
const listLabelOf = (line: string): string | undefined => {
|
|
61
|
+
const number = ITEM_NUMBER.exec(line);
|
|
62
|
+
const rest = number === null ? "" : line.slice(number[0].length).trim();
|
|
63
|
+
return ONE_WORD.test(rest) ? rest : undefined;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const hasPrefix = (term: string, prefixes: readonly string[]): boolean =>
|
|
67
|
+
prefixes.some((prefix) => term.startsWith(prefix) && Array.from(term.slice(prefix.length)).length >= MIN_REST);
|
|
68
|
+
|
|
69
|
+
/** The prefixed terms the source names in quotes or alone on a list item, which the structure does not read as definitions. */
|
|
70
|
+
export const namedTerms = (source: string, prefixes: readonly string[]): string[] => {
|
|
71
|
+
const given = prefixes.filter((prefix) => prefix !== "");
|
|
72
|
+
const quoted = [...source.matchAll(QUOTED)].map((match) => match.groups?.["term"] ?? "");
|
|
73
|
+
const labels = source.split("\n").flatMap((line) => listLabelOf(line) ?? []);
|
|
74
|
+
return [...new Set([...quoted, ...labels].filter((term) => hasPrefix(term, given)))];
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/** A use is a known form, or starts with one and goes on with more words (本報告書提出後), but not with a group's mark (本報告書等). */
|
|
78
|
+
const isKnownUse = (term: string, known: readonly string[], groupSuffixes: readonly string[]): boolean =>
|
|
79
|
+
known.some((form) => form.startsWith(term) || (term.startsWith(form) && !groupSuffixes.includes(term.slice(form.length))));
|
|
80
|
+
|
|
50
81
|
/** The defined terms and their other-prefix forms (本件業務 for 本業務), which defined-term-form reads. */
|
|
51
82
|
const knownForms = (defined: readonly string[], groups: TermWords["prefixGroups"]): string[] => [
|
|
52
83
|
...defined,
|
|
@@ -56,26 +87,28 @@ const knownForms = (defined: readonly string[], groups: TermWords["prefixGroups"
|
|
|
56
87
|
/**
|
|
57
88
|
* The first use of each term written with the document's prefix and defined nowhere, when the document defines at
|
|
58
89
|
* least one term with that prefix (else the prefix is not its way of naming terms). A use that starts with a known
|
|
59
|
-
* form (本サービス上 where 本サービス is defined) is that term.
|
|
90
|
+
* form (本サービス上 where 本サービス is defined) is that term, unless the rest is a group's mark (本サービス等).
|
|
60
91
|
*/
|
|
61
92
|
export const undefinedTerms = (source: string, sentences: readonly (readonly Token[])[], defined: readonly string[], words: TermWords): UndefinedTerm[] => {
|
|
62
93
|
const prefixes = words.prefixes.filter((prefix) => prefix !== "");
|
|
63
|
-
|
|
64
|
-
if (prefixed.length === 0) return [];
|
|
65
|
-
const known = knownForms(defined, words.prefixGroups);
|
|
94
|
+
if (!defined.some((term) => hasPrefix(term, prefixes))) return [];
|
|
66
95
|
const isSelf = (term: string, prefix: string): boolean => {
|
|
67
96
|
const rest = term.slice(prefix.length);
|
|
68
97
|
return words.selfNouns.some((noun) => noun !== "" && (rest.startsWith(noun) || rest.endsWith(noun)));
|
|
69
98
|
};
|
|
70
|
-
const
|
|
99
|
+
const runs = sentences.flatMap((tokens) =>
|
|
71
100
|
tokens.flatMap((token, index) => {
|
|
72
101
|
if (!prefixes.includes(token.surface) || !isNoun(tokens[index + 1]) || continuesWord(tokens[index - 1], token)) return [];
|
|
73
102
|
const use = termAt(source, tokens, index);
|
|
74
|
-
|
|
75
|
-
if (known.some((form) => use.term.startsWith(form) || form.startsWith(use.term))) return [];
|
|
76
|
-
return [use];
|
|
103
|
+
return use === undefined ? [] : [{ ...use, prefix: token.surface }];
|
|
77
104
|
}),
|
|
78
105
|
);
|
|
106
|
+
// A name that does not start a run of nouns (② 本研究の具体的な遂行方法) is an item of a list, not a term.
|
|
107
|
+
const named = words.named.filter((term) => runs.some((run) => run.term.startsWith(term)));
|
|
108
|
+
const known = knownForms([...defined, ...named], words.prefixGroups);
|
|
109
|
+
const uses = runs
|
|
110
|
+
.filter((run) => !isSelf(run.term, run.prefix) && !words.isQuoted(run.term) && !isKnownUse(run.term, known, words.groupSuffixes))
|
|
111
|
+
.map((run) => ({ offset: run.offset, term: run.term }));
|
|
79
112
|
return uses.filter((use, index) => uses.findIndex((other) => other.term === use.term) === index);
|
|
80
113
|
};
|
|
81
114
|
|
|
@@ -126,11 +159,14 @@ export const undefinedTerm: Detector = (doc): Finding[] => {
|
|
|
126
159
|
const sentences = doc.sentences.map((sentence) => sentence.tokens ?? []);
|
|
127
160
|
const definitions = definedTerms(doc.structure);
|
|
128
161
|
const defined = definitions.map((term) => term.term);
|
|
162
|
+
const prefixes = prefixEntries.map((entry) => entry.pattern);
|
|
129
163
|
const prefixed = undefinedTerms(doc.source, sentences, defined, {
|
|
130
|
-
prefixes
|
|
164
|
+
prefixes,
|
|
131
165
|
prefixGroups: prefixGroupsOf(prefixEntries),
|
|
132
166
|
selfNouns: [...patternsOf(doc, "self-reference-noun"), ...patternsOf(doc, "document-kind")],
|
|
133
167
|
isQuoted: (term) => QUOTE_PAIRS.some(([open, close]) => doc.source.includes(`${open}${term}${close}`)),
|
|
168
|
+
named: namedTerms(doc.source, prefixes),
|
|
169
|
+
groupSuffixes: patternsOf(doc, "defined-term-group-suffix"),
|
|
134
170
|
});
|
|
135
171
|
return [...prefixed, ...capitalisedUses(doc, sentences, definitions)].map((use) => findingOf(doc, use));
|
|
136
172
|
};
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import type { Detector } from "../plugin.ts";
|
|
2
|
+
import { entriesForGenre } from "../lexicon-genres.ts";
|
|
2
3
|
import { unfilledPlaceholder } from "./ai-phrasing.ts";
|
|
3
4
|
import { TEMPLATE, isInside, templateSections } from "./template-sections.ts";
|
|
4
5
|
|
|
5
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* A blank under a heading that names a template (Template, 雛形) is what the template is for, so it is not reported.
|
|
8
|
+
* Words that hold in some genres only (〇〇様 in a letter) count in those genres.
|
|
9
|
+
*/
|
|
6
10
|
export const unfilledPlaceholderOutsideTemplates: Detector = (doc, options) => {
|
|
7
|
-
const
|
|
11
|
+
const lexicon = entriesForGenre(options.lexicon ?? [], options.genre);
|
|
12
|
+
const words = lexicon.filter((word) => word.group === TEMPLATE);
|
|
8
13
|
const templates = templateSections(doc.markup?.headings ?? [], doc.source.length, words);
|
|
9
|
-
return unfilledPlaceholder(doc, options).filter((finding) => !isInside(templates, Number(finding.values["offset"])));
|
|
14
|
+
return unfilledPlaceholder(doc, { ...options, lexicon }).filter((finding) => !isInside(templates, Number(finding.values["offset"])));
|
|
10
15
|
};
|
|
@@ -41,6 +41,15 @@ export const codeWordsOf = (source: string): Set<string> => {
|
|
|
41
41
|
return words;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* A search stem with a wildcard in a list of terms (ukrain*, vaccin*): the word ends in a * that closes no emphasis
|
|
46
|
+
* (nothing opens one before the word), and a separator or the line's end follows it, not a word as after a footnote's *.
|
|
47
|
+
*/
|
|
48
|
+
export const isSearchStem = (source: string, offset: number, word: string): boolean => {
|
|
49
|
+
const end = offset + word.length;
|
|
50
|
+
return source[end] === "*" && source[offset - 1] !== "*" && /^[ \t]*(?:[,;|)\]]|\r?\n|$)/u.test(source.slice(end + 1));
|
|
51
|
+
};
|
|
52
|
+
|
|
44
53
|
/**
|
|
45
54
|
* 辞書に無い英語の語で、一字違いの辞書の語があるもの(recieve → receive)。辞書は adapter が持ち、無い言語では動かない。
|
|
46
55
|
* 大文字を含む語(固有名詞・略語)、コード・URL の中、頭の字を分けた語の残り、二度以上使う語、言い直しの無い語、
|
|
@@ -53,7 +62,7 @@ export const unknownWord: Detector = (doc): Finding[] => {
|
|
|
53
62
|
const words = wordsToCheck(doc.prose ?? doc.source, MIN_LENGTH, MAX_LENGTH).filter(({ offset }) => !isSplitWord(doc.source, offset));
|
|
54
63
|
const used = new Set(words.map(({ word }) => word).filter((word) => isKnownWord(word, speller)));
|
|
55
64
|
return usedOnce(words).flatMap(({ offset, word }) => {
|
|
56
|
-
if (known.has(word) || isKnownWord(word, speller)) return [];
|
|
65
|
+
if (known.has(word) || isKnownWord(word, speller) || isSearchStem(doc.source, offset, word)) return [];
|
|
57
66
|
const suggestion = suggestionFor(word, speller, used);
|
|
58
67
|
if (suggestion === undefined) return [];
|
|
59
68
|
return [{ rule: "", severity: "warning", line: 0, column: 0, quote: quoteAt(doc.source, offset), values: { word, suggestion, offset } }];
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// unused-definition, less the terms that are not unused definitions: a wording quoted as what not to write (「風雨が強い」と
|
|
2
|
+
// はせずに …), which the definition reader takes for 「X」とは, and a term a heading names under another capitalisation
|
|
3
|
+
// (### Audio Content, then “Audio content” refers to …). The words after the quote come from the language's word list
|
|
4
|
+
// (rejected-wording). Nor is a quoted word a sentence asks about ("what “done” means"). Nor is a term defined for a unit of a code that the document is only one section of ("For the purpose
|
|
5
|
+
// of this subchapter—" in 5 U.S.C. 551): the other sections of the unit use it. Pure.
|
|
6
|
+
import type { Detector, Finding, ProseDocument } from "../plugin.ts";
|
|
7
|
+
import { escapeRegExp } from "../orthography.ts";
|
|
8
|
+
import { unusedDefinition } from "./definition-use.ts";
|
|
9
|
+
import { scopedBeyondReader } from "./definition-scope-unit.ts";
|
|
10
|
+
|
|
11
|
+
/** How far after the definition's start the term itself is looked for. */
|
|
12
|
+
const TERM_REACH = 40;
|
|
13
|
+
/** Closing quotes and spaces between the term and the words after it. */
|
|
14
|
+
const CLOSING = /^[」』”"'’\s]*/u;
|
|
15
|
+
|
|
16
|
+
/** Whether the quoted term is followed by words that reject it (「X」とはせずに、"X" should not be used). */
|
|
17
|
+
export const isRejectedWording = (source: string, offset: number, term: string, markers: readonly string[]): boolean => {
|
|
18
|
+
const at = source.slice(offset, offset + TERM_REACH + term.length).indexOf(term);
|
|
19
|
+
if (at === -1 || markers.length === 0) return false;
|
|
20
|
+
const after = source.slice(offset + at + term.length).replace(CLOSING, "");
|
|
21
|
+
return markers.some((marker) => after.startsWith(marker));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/** Opening quotes and spaces between the words before the term and the term. */
|
|
25
|
+
const OPENING = new Set(["「", "『", "“", '"', "'", "‘"]);
|
|
26
|
+
|
|
27
|
+
const withoutOpening = (text: string): string => {
|
|
28
|
+
const chars = [...text];
|
|
29
|
+
return chars.slice(0, chars.findLastIndex((char) => !OPENING.has(char) && char.trim() !== "") + 1).join("");
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** The lead as a whole word at the end of the text before the term: "what", not "somewhat". */
|
|
33
|
+
const endsWithWord = (text: string, lead: string): boolean => text.endsWith(lead) && !/[\p{L}\p{N}]/u.test(text.at(-lead.length - 1) ?? "");
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Whether the quoted term follows a word that asks about it ("a definition of what “done” means"): the sentence asks
|
|
37
|
+
* what the term means, and defines nothing. The words come from the language's word list (question-wording-lead).
|
|
38
|
+
*/
|
|
39
|
+
export const isQuestionedWording = (source: string, offset: number, term: string, leads: readonly string[]): boolean => {
|
|
40
|
+
const at = source.slice(offset, offset + TERM_REACH + term.length).indexOf(term);
|
|
41
|
+
if (at === -1 || leads.length === 0) return false;
|
|
42
|
+
const before = withoutOpening(source.slice(Math.max(0, offset + at - TERM_REACH), offset + at)).toLowerCase();
|
|
43
|
+
return leads.some((lead) => endsWithWord(before, lead.toLowerCase()));
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** Whether a heading names the term, compared without case (### Audio Content and “Audio content”). */
|
|
47
|
+
export const isNamedByHeading = (term: string, headings: readonly string[]): boolean => {
|
|
48
|
+
const word = new RegExp(String.raw`(?<![\p{L}\p{N}])${escapeRegExp(term.toLocaleLowerCase())}(?![\p{L}\p{N}])`, "u");
|
|
49
|
+
return headings.some((heading) => word.test(heading.toLocaleLowerCase()));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const headingTexts = (doc: ProseDocument): string[] => (doc.markup?.headings ?? []).map((heading) => heading.text);
|
|
53
|
+
|
|
54
|
+
const patternsOf = (doc: ProseDocument, lexicon: string): string[] => (doc.lexicons[lexicon] ?? []).map((entry) => entry.pattern);
|
|
55
|
+
|
|
56
|
+
/** Whether the definition at `offset` is made for a unit of a code the document does not have. */
|
|
57
|
+
const scopedBeyond = (doc: ProseDocument): ((offset: number) => boolean) => {
|
|
58
|
+
const leads = patternsOf(doc, "definition-scope-lead");
|
|
59
|
+
const units = new Set(patternsOf(doc, "enclosing-unit").map((unit) => unit.toLowerCase()));
|
|
60
|
+
return doc.structure === undefined ? () => false : scopedBeyondReader(doc.structure, doc.source, leads, units);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const isKept =
|
|
64
|
+
(doc: ProseDocument, headings: readonly string[]) =>
|
|
65
|
+
(finding: Finding): boolean => {
|
|
66
|
+
const term = String(finding.values["term"] ?? "");
|
|
67
|
+
const offset = Number(finding.values["offset"] ?? 0);
|
|
68
|
+
return (
|
|
69
|
+
!isRejectedWording(doc.source, offset, term, patternsOf(doc, "rejected-wording")) &&
|
|
70
|
+
!isQuestionedWording(doc.source, offset, term, patternsOf(doc, "question-wording-lead")) &&
|
|
71
|
+
!isNamedByHeading(term, headings)
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const unusedDefinitionKept: Detector = (doc, options): Finding[] => {
|
|
76
|
+
const beyond = scopedBeyond(doc);
|
|
77
|
+
return unusedDefinition(doc, options)
|
|
78
|
+
.filter(isKept(doc, headingTexts(doc)))
|
|
79
|
+
.filter((finding) => !beyond(Number(finding.values["offset"] ?? 0)));
|
|
80
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Detector, LexiconEntry, ProseDocument, Sentence } from "../plugin.ts";
|
|
2
|
+
import { entryRanges } from "./lexicon-match.ts";
|
|
3
|
+
import { phraseMatchWhere } from "./phrase-match.ts";
|
|
4
|
+
import { followsToldQuote, type TellingCues } from "./reported-speech.ts";
|
|
5
|
+
|
|
6
|
+
const cuesOf = (doc: ProseDocument): TellingCues => {
|
|
7
|
+
const entries = doc.lexicons["telling-cue"] ?? [];
|
|
8
|
+
const inGroup = (group: string): string[] => entries.filter((entry) => entry.group === group).map((entry) => entry.pattern);
|
|
9
|
+
return { occasion: inGroup("occasion"), sayer: inGroup("sayer") };
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A weasel phrase counts unless every use of it in the sentence reports a quotation told on a named occasion or by a named
|
|
14
|
+
* sayer (申し込んだら、「…」と言われています). Without tokens the uses cannot be placed, so each one counts.
|
|
15
|
+
*/
|
|
16
|
+
const isWeaselUse = (doc: ProseDocument, sentence: Sentence, entry: LexiconEntry): boolean => {
|
|
17
|
+
const tokens = sentence.tokens ?? [];
|
|
18
|
+
const ranges = entryRanges(sentence, entry);
|
|
19
|
+
if (ranges.length === 0) return true;
|
|
20
|
+
const cues = cuesOf(doc);
|
|
21
|
+
return !ranges.every((range) => followsToldQuote(doc.source.slice(sentence.span.start, tokens[range.start]?.span.start ?? sentence.span.start), cues));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const weaselWord: Detector = (doc, options) => phraseMatchWhere(doc, options, (sentence, entry) => isWeaselUse(doc, sentence, entry));
|
package/src/document.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { spansWithin, unmaskedSoftBreaks } from "./soft-break.ts";
|
|
|
6
6
|
import { segmentJoined } from "./joined-view.ts";
|
|
7
7
|
import { paragraphsOf } from "./document-paragraphs.ts";
|
|
8
8
|
import { closingRun, standaloneLines, subheadingPieces, type StandsAlone } from "./subheading-line.ts";
|
|
9
|
+
import { stageDirectionPieces, type BracketPair } from "./stage-directions.ts";
|
|
9
10
|
import { isLinkLine } from "./link-line.ts";
|
|
10
11
|
import { speakerLabels } from "./speaker-labels.ts";
|
|
11
12
|
import type { Outline } from "./structure/build.ts";
|
|
@@ -181,13 +182,23 @@ const linkLineIn =
|
|
|
181
182
|
(start, end) =>
|
|
182
183
|
isLinkLine(source, shift({ start, end }, paragraph.start), links);
|
|
183
184
|
|
|
185
|
+
/** 片を、ト書きの括弧の中と外に分ける(戯曲)。括弧の組が無ければ片のまま。 */
|
|
186
|
+
const withoutStageDirections = (prose: string, piece: Span, pair: BracketPair | undefined): Span[] =>
|
|
187
|
+
pair === undefined ? [piece] : stageDirectionPieces(prose.slice(piece.start, piece.end), pair).map((span) => shift(span, piece.start));
|
|
188
|
+
|
|
189
|
+
const EVERY_LINE: StandsAlone = () => true;
|
|
190
|
+
|
|
184
191
|
/**
|
|
185
192
|
* 段落を、中の小見出しの行(「(経済再生)」)とリンクだけの行の後ろで切った片。片ごとに分割すれば、
|
|
186
|
-
* 小見出しが次の文に入らず、1
|
|
193
|
+
* 小見出しが次の文に入らず、1 行ずつ並べたリンクが一つの長い文にならない。詩(lineBreaksEndSentences)なら、どの行の後ろでも切る。
|
|
194
|
+
* 戯曲(stageDirections)では、ト書きも台詞と別の片にする。
|
|
187
195
|
*/
|
|
188
|
-
const piecesOf = (prose: string, paragraphs: readonly Span[], source: string, links: readonly Span[]): Span[] =>
|
|
196
|
+
const piecesOf = (prose: string, paragraphs: readonly Span[], source: string, links: readonly Span[], profile: DocumentProfile | undefined): Span[] =>
|
|
189
197
|
paragraphs.flatMap((paragraph) =>
|
|
190
|
-
subheadingPieces(
|
|
198
|
+
subheadingPieces(
|
|
199
|
+
prose.slice(paragraph.start, paragraph.end),
|
|
200
|
+
profile?.lineBreaksEndSentences === true ? EVERY_LINE : linkLineIn(source, links, paragraph),
|
|
201
|
+
).flatMap((piece) => withoutStageDirections(prose, shift(piece, paragraph.start), profile?.stageDirections)),
|
|
191
202
|
);
|
|
192
203
|
|
|
193
204
|
/**
|
|
@@ -213,12 +224,12 @@ type LineLayout = {
|
|
|
213
224
|
readonly paragraphs: readonly Span[];
|
|
214
225
|
};
|
|
215
226
|
|
|
216
|
-
const lineLayoutOf = (root: Node, source: string, prose: string, paragraphs: readonly Span[]): LineLayout => {
|
|
227
|
+
const lineLayoutOf = (root: Node, source: string, prose: string, paragraphs: readonly Span[], profile: DocumentProfile | undefined): LineLayout => {
|
|
217
228
|
const links = [...spansOfType(root, "link"), ...spansOfType(root, "linkReference")];
|
|
218
229
|
const linkItems = linkItemsOf(prose, paragraphs, source, links);
|
|
219
230
|
return {
|
|
220
231
|
links,
|
|
221
|
-
pieces: piecesOf(prose, paragraphs, source, links),
|
|
232
|
+
pieces: piecesOf(prose, paragraphs, source, links, profile),
|
|
222
233
|
listSpans: [...spansOfType(root, "listItem"), ...linkItems],
|
|
223
234
|
paragraphs: cutTextSpans(paragraphs, linkItems, source),
|
|
224
235
|
};
|
|
@@ -323,7 +334,7 @@ const documentOf = (path: string, source: string, adapter: LanguageAdapter, team
|
|
|
323
334
|
const headings = headingsOf(root, source, maskSpans(source, syntax), emailLayout.replyQuotes);
|
|
324
335
|
// Markdown は段落を流し込んで表示するので、段落の中の改行は読み手に見えない。テキストの文書は行をそのまま見せる(法令は 1 行 1 号)。
|
|
325
336
|
const softBreaks = markdown ? unmaskedSoftBreaks(source, prose) : [];
|
|
326
|
-
const layout = lineLayoutOf(root, source, prose, paragraphSpans);
|
|
337
|
+
const layout = lineLayoutOf(root, source, prose, paragraphSpans, profile);
|
|
327
338
|
const sentences = sentencesOf(prose, layout.pieces, adapter, softBreaks);
|
|
328
339
|
const lexicons = teamLexicons(adapter, team);
|
|
329
340
|
const tagged = sentences.some((sentence) => sentence.tokens !== undefined);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** A heading that ends with a colon, as a label does ("Phone:"). */
|
|
2
|
+
const COLON_END = /[::]$/u;
|
|
3
|
+
|
|
4
|
+
/** A line that ends a sentence: a full stop, a question or an exclamation mark, then closing quotes, brackets or emphasis. */
|
|
5
|
+
const SENTENCE_END = /[.!?。!?][”’"')\]」』)*_]*$/u;
|
|
6
|
+
|
|
7
|
+
/** A line of markup that holds items, not a value: a list item, a table row, a quotation, a code fence. */
|
|
8
|
+
const MARKUP_LINE = /^(?:[-*+>|]|\d+[.)]\s|```|~~~)/u;
|
|
9
|
+
|
|
10
|
+
/** What a value holds: a number (a street number, a postcode, a phone number) or an address (@). */
|
|
11
|
+
const VALUE_MARK = /[\d0-9@@]/u;
|
|
12
|
+
|
|
13
|
+
/** A value is short: an address of a few lines, a number. Longer lines without a full stop are prose that left it off. */
|
|
14
|
+
const MAX_VALUE_LINES = 3;
|
|
15
|
+
const MAX_VALUE_WORDS = 6;
|
|
16
|
+
const MAX_VALUE_CHARS = 40;
|
|
17
|
+
|
|
18
|
+
const WORD = /\S+/gu;
|
|
19
|
+
|
|
20
|
+
const isValueLine = (line: string): boolean =>
|
|
21
|
+
!SENTENCE_END.test(line) && !MARKUP_LINE.test(line) && [...line].length <= MAX_VALUE_CHARS && (line.match(WORD) ?? []).length <= MAX_VALUE_WORDS;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Whether a heading is the label of a field ("Mailing Address:", "Phone:") rather than the title of a section: it ends with a
|
|
25
|
+
* colon, and what stands under it (body: the text up to the next heading) is a value: a few short lines with no sentence or
|
|
26
|
+
* list in them, holding a number or an address (a mailing address, a phone number). A page's contact block is set this way,
|
|
27
|
+
* and its labels are not compared with the section titles.
|
|
28
|
+
*/
|
|
29
|
+
export const isFieldLabel = (heading: string, body: string): boolean => {
|
|
30
|
+
const lines = body
|
|
31
|
+
.split("\n")
|
|
32
|
+
.map((line) => line.trim())
|
|
33
|
+
.filter((line) => line !== "");
|
|
34
|
+
return (
|
|
35
|
+
COLON_END.test(heading.trim()) &&
|
|
36
|
+
lines.length > 0 &&
|
|
37
|
+
lines.length <= MAX_VALUE_LINES &&
|
|
38
|
+
lines.every(isValueLine) &&
|
|
39
|
+
lines.some((line) => VALUE_MARK.test(line))
|
|
40
|
+
);
|
|
41
|
+
};
|
package/src/furigana.ts
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import type { Span } from "./plugin.ts";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
const KANA_ASIDE = /[((][\p{Script=Hiragana}
|
|
3
|
+
/** かなと、読みの中に書く長音・中黒・空白だけの括弧書き。 */
|
|
4
|
+
const KANA_ASIDE = /[((][\p{Script=Hiragana}\p{Script=Katakana}ー・\p{Zs}]+[))]/gu;
|
|
5
5
|
|
|
6
6
|
const HIRAGANA = /\p{Script=Hiragana}/u;
|
|
7
|
+
const KATAKANA = /\p{Script=Katakana}/u;
|
|
7
8
|
/** 読みを付ける語の終わりの字。ひらがなの後ろの括弧書きは読みではなく挟んだ言葉(「これは(たぶん)」)。 */
|
|
8
9
|
const WORD_END = /[\p{L}\p{N}]/u;
|
|
10
|
+
/** 番号の読み(#8891(はやくワンストップ))は語呂合わせで、片仮名が交じる。語の後ろの片仮名の括弧は言い換え(電話(スマホ))。 */
|
|
11
|
+
const NUMBER_END = /\p{N}/u;
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
|
-
* text の中の、語の直後のふりがなの括弧(「HTTP
|
|
12
|
-
*
|
|
14
|
+
* text の中の、語の直後のふりがなの括弧(「HTTP(えいちてぃーてぃーぴー)」「脆弱性(ぜいじゃくせい)」)と、番号の直後の読みの括弧
|
|
15
|
+
* (「#8891(はやくワンストップ)」)の範囲。括弧を含む。語の読みであって、語の書き方ではない。位置は text の先頭を 0 とする。
|
|
13
16
|
*/
|
|
14
17
|
export const furiganaSpans = (text: string): Span[] =>
|
|
15
18
|
[...text.matchAll(KANA_ASIDE)]
|
|
16
19
|
.filter((match) => {
|
|
17
20
|
const before = text.charAt(match.index - 1);
|
|
18
|
-
|
|
21
|
+
const reads = HIRAGANA.test(match[0]) && WORD_END.test(before) && !HIRAGANA.test(before);
|
|
22
|
+
return reads && (!KATAKANA.test(match[0]) || NUMBER_END.test(before));
|
|
19
23
|
})
|
|
20
24
|
.map((match) => ({ start: match.index, end: match.index + match[0].length }));
|
package/src/genre-load.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { parse } from "yaml";
|
|
3
3
|
import { parseGenres, presetLevelsOf, presetProfileOf, withRuleOffs, type GenreData, type PresetLevels } from "./genre-parse.ts";
|
|
4
|
-
import { loadRuleOffs } from "./rule-offs.ts";
|
|
4
|
+
import { IGNORE_MEASURED_OFFS_ENV, loadRuleOffs, offsInForce } from "./rule-offs.ts";
|
|
5
5
|
import { PACKAGE_DIR, readText } from "./package-files.ts";
|
|
6
6
|
|
|
7
7
|
const GENRES_FILE = join(PACKAGE_DIR, "genres.yaml");
|
|
@@ -13,7 +13,8 @@ const loaded: { value: GenreData | undefined } = { value: undefined };
|
|
|
13
13
|
export const loadGenres = (): GenreData => {
|
|
14
14
|
if (loaded.value !== undefined) return loaded.value;
|
|
15
15
|
try {
|
|
16
|
-
|
|
16
|
+
const offs = offsInForce(loadRuleOffs(RULES_DIR), process.env[IGNORE_MEASURED_OFFS_ENV] === "1");
|
|
17
|
+
loaded.value = withRuleOffs(parseGenres(parse(readText(GENRES_FILE))), offs);
|
|
17
18
|
} catch (error) {
|
|
18
19
|
throw new Error(`cannot read ${GENRES_FILE}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
19
20
|
}
|
package/src/heading-numbering.ts
CHANGED
|
@@ -54,6 +54,9 @@ const markOf = (heading: string, labels: readonly NumberLabel[]): NumberMark =>
|
|
|
54
54
|
/** 見出しの言葉から、番号の書き方を読む。番号を持つ語(第1章)を先に、字だけの形(1.)を後に見る。 */
|
|
55
55
|
export const numberingStyleOf = (heading: string, labels: readonly NumberLabel[]): string => markOf(heading, labels).style;
|
|
56
56
|
|
|
57
|
+
/** 見出しの番号の印そのもの(「Q. 」の Q.、「1. 」の 1.)。空白は除く。番号が無ければ空。 */
|
|
58
|
+
export const numberMarkOf = (heading: string, labels: readonly NumberLabel[]): string => markOf(heading, labels).mark.replace(/\s/gu, "");
|
|
59
|
+
|
|
57
60
|
/** 番号の中の数の一つ一つ(「7.1」の 7 と 1、「Chapter II」の II)。番号は印の最後に来るので、語の頭の大文字(Chapter の C)は最後にならない。 */
|
|
58
61
|
const NUMBER_TOKEN = /[0-90-9]+|[A-ZⅠ-Ⅻ①-⑳一二三四五六七八九十百]+/gu;
|
|
59
62
|
const FIRST_NUMBERS: ReadonlySet<string> = new Set(["1", "1", "I", "Ⅰ", "A", "①", "一"]);
|
|
@@ -64,8 +67,11 @@ export const opensNumbering = (heading: string, labels: readonly NumberLabel[]):
|
|
|
64
67
|
return last !== undefined && FIRST_NUMBERS.has(last);
|
|
65
68
|
};
|
|
66
69
|
|
|
67
|
-
/**
|
|
68
|
-
|
|
70
|
+
/**
|
|
71
|
+
* 見出し 1 つ。depth は深さ(#の数)、style は番号の書き方、skipped は番号を付けない前後の見出し(目次・参考文献)、opens は番号が 1 から始まるか。
|
|
72
|
+
* mark は番号の印そのもの(Q.)で、無ければ字の番号を並びとして読む。
|
|
73
|
+
*/
|
|
74
|
+
export type NumberedHeading = { readonly depth: number; readonly style: string; readonly skipped: boolean; readonly opens: boolean; readonly mark?: string };
|
|
69
75
|
|
|
70
76
|
/** 親(直前の浅い見出し)と深さが同じ見出しの組。番号は兄弟の見出しのあいだで揃える。位置は渡した並びの添え字。 */
|
|
71
77
|
export const siblingGroups = (headings: readonly NumberedHeading[]): number[][] => {
|
|
@@ -112,6 +118,19 @@ const leadingFrontMatter = (members: readonly number[], headings: readonly Numbe
|
|
|
112
118
|
return new Set(members.filter((at) => at < first));
|
|
113
119
|
};
|
|
114
120
|
|
|
121
|
+
/** 同じ字を付けた兄弟がこれだけあれば、その字は番号でなく印。 */
|
|
122
|
+
const MIN_REPEATED_LETTERS = 2;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 兄弟が字の番号にみな同じ字を付けている(「Q. 〜」「Q. 〜」)なら、その字は並びの番号でなく質問の印。番号の無い見出しと読む。
|
|
126
|
+
* 番号なら字は進む(A. B. C.)。
|
|
127
|
+
*/
|
|
128
|
+
const prefixLetters = (members: readonly number[], headings: readonly NumberedHeading[]): ReadonlySet<number> => {
|
|
129
|
+
const letters = members.filter((at) => headings[at]?.style === "letter");
|
|
130
|
+
const marks = new Set(letters.map((at) => headings[at]?.mark));
|
|
131
|
+
return letters.length >= MIN_REPEATED_LETTERS && marks.size === 1 && !marks.has(undefined) ? new Set(letters) : new Set();
|
|
132
|
+
};
|
|
133
|
+
|
|
115
134
|
/**
|
|
116
135
|
* 兄弟の見出しのうち、少ないほうの書き方のもの。先に番号の有無を比べ(「1. 概要」「2. 手順」「まとめ」の「まとめ」)、
|
|
117
136
|
* 番号の付いた見出しのあいだで書き方を比べる(「1.」「2.」「3)」の「3)」)。同じ数なら言わない(二つだけの兄弟は必ず同じ数か一つの書き方)。前後の見出し(目次・参考文献)と、1 から始まる番号の前の見出しは数えない。
|
|
@@ -121,7 +140,8 @@ export const numberingMinorities = (headings: readonly NumberedHeading[]): Numbe
|
|
|
121
140
|
const listed = group.filter((at) => headings[at]?.skipped !== true);
|
|
122
141
|
const front = leadingFrontMatter(listed, headings);
|
|
123
142
|
const members = listed.filter((at) => !front.has(at));
|
|
124
|
-
const
|
|
143
|
+
const prefixed = prefixLetters(members, headings);
|
|
144
|
+
const styleOf = (at: number): string => (prefixed.has(at) ? UNNUMBERED : (headings[at]?.style ?? UNNUMBERED));
|
|
125
145
|
const numbered = members.filter((at) => styleOf(at) !== UNNUMBERED);
|
|
126
146
|
return [
|
|
127
147
|
...minoritiesOf(
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Token } from "./plugin.ts";
|
|
2
|
+
|
|
3
|
+
const touches = (left: Token | undefined, right: Token | undefined): boolean => left !== undefined && right !== undefined && left.span.end === right.span.start;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 人の集まりを敬って呼ぶ語(皆様、方々)の直前の助詞で、呼び方がさらに同じ助詞で次の語に係るもの。「国民の皆様の期待」の
|
|
7
|
+
* 「国民の皆様」は一つの呼び方として次の語に係り、その中の「の」は入れ子を深くしない。呼び方で連なりが終わるとき
|
|
8
|
+
* (それ以外の全てのVim使いの皆様が)は、呼び方が連なりの頭の語なので数える。particles は数える助詞(の)、groups は呼び方の語(皆様)。
|
|
9
|
+
*/
|
|
10
|
+
export const honorificGroupParticles = (tokens: readonly Token[], particles: readonly string[], groups: readonly string[]): ReadonlySet<Token> =>
|
|
11
|
+
new Set(
|
|
12
|
+
tokens.filter((token, at) => {
|
|
13
|
+
const [group, after] = [tokens[at + 1], tokens[at + 2]];
|
|
14
|
+
return (
|
|
15
|
+
particles.includes(token.surface) &&
|
|
16
|
+
groups.includes(group?.surface ?? "") &&
|
|
17
|
+
touches(token, group) &&
|
|
18
|
+
touches(group, after) &&
|
|
19
|
+
particles.includes(after?.surface ?? "")
|
|
20
|
+
);
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
@@ -53,7 +53,7 @@ const SCHEME_AND_HOST = /^(?:[a-z][a-z0-9+.-]*:)?\/\/[^/?#]*/iu;
|
|
|
53
53
|
// A link that opens no page (tel:, mailto:, sms:) carries its own content, a number or an address.
|
|
54
54
|
const OTHER_SCHEME = /^\s*(?!https?:)[a-z][a-z0-9+.-]*:(?!\/\/)/iu;
|
|
55
55
|
|
|
56
|
-
const hrefOf = (link: string): string => {
|
|
56
|
+
export const hrefOf = (link: string): string => {
|
|
57
57
|
const href = HREF.exec(link);
|
|
58
58
|
return href?.[1] ?? href?.[2] ?? href?.[3] ?? "";
|
|
59
59
|
};
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
// sentence it follows ("recessions.1 Over"), so the mark is dropped; the note itself stays where the page has it. A
|
|
4
4
|
// superscript that is a link is a mark wherever the link goes (the notes may be on another page); a link around a
|
|
5
5
|
// superscript is one only when it stays on this page, since "Brand<a href=…><sup>TM</sup></a>" is a sign. A superscript
|
|
6
|
-
// with no link ("25<sup>th</sup>") is text.
|
|
6
|
+
// with no link ("25<sup>th</sup>") is text. A mark written with a sign of its own (※1, 注2) sticks to nothing: it stays
|
|
7
|
+
// as text, so the note it points at is still pointed at. Pure.
|
|
8
|
+
import { decodeEntities } from "./markup-text.ts";
|
|
7
9
|
|
|
8
|
-
const LINK_IN_SUPERSCRIPT = /<sup\b[^>]*>\s*<a\b[^>]*>[^<]
|
|
10
|
+
const LINK_IN_SUPERSCRIPT = /<sup\b[^>]*>\s*<a\b[^>]*>([^<]*)<\/a\s*>\s*<\/sup\s*>/giu;
|
|
9
11
|
|
|
10
12
|
const SUPERSCRIPT_LINK = /<a\b([^>]*)>\s*<sup\b[^>]*>([^<]*)<\/sup\s*>\s*<\/a\s*>/giu;
|
|
11
13
|
|
|
@@ -14,7 +16,13 @@ const IN_PAGE_HREF = /\shref\s*=\s*(?:"#[^"\s]+"|'#[^'\s]+'|#[^\s"'>]+)/iu;
|
|
|
14
16
|
|
|
15
17
|
const isFootnoteLink = (attributes: string, mark: string): boolean => IN_PAGE_HREF.test(attributes) && mark.trim() !== "";
|
|
16
18
|
|
|
19
|
+
// Neither ASCII, a digit, a bracket nor a space: a sign or a word the mark is written with (※, 注, †).
|
|
20
|
+
const WRITTEN_SIGN = /[^\p{ASCII}\p{Nd}\p{Ps}\p{Pe}\s]/u;
|
|
21
|
+
|
|
22
|
+
/** What a footnote mark leaves in the text: the mark itself when it is written with a sign († as †), else nothing. */
|
|
23
|
+
const markText = (mark: string): string => (WRITTEN_SIGN.test(decodeEntities(mark)) ? mark.trim() : "");
|
|
24
|
+
|
|
17
25
|
export const withoutFootnoteMarks = (html: string): string =>
|
|
18
26
|
html
|
|
19
|
-
.replace(LINK_IN_SUPERSCRIPT,
|
|
20
|
-
.replace(SUPERSCRIPT_LINK, (link: string, attributes: string, mark: string) => (isFootnoteLink(attributes, mark) ?
|
|
27
|
+
.replace(LINK_IN_SUPERSCRIPT, (_link: string, mark: string) => markText(mark))
|
|
28
|
+
.replace(SUPERSCRIPT_LINK, (link: string, attributes: string, mark: string) => (isFootnoteLink(attributes, mark) ? markText(mark) : link));
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
// A heading's link to its own section (a permalink beside or after the title), taken out of an HTML page
|
|
1
|
+
// A heading's link to its own section (a permalink beside or after the title), taken out of an HTML page, and a
|
|
2
|
+
// heading's other links within the page (an accordion's panel title) read as its words. Pure.
|
|
2
3
|
import { ANY_LINK, ATTRIBUTES, elementRanges, hasNoWords, plainText, type ElementRange } from "./html-elements.ts";
|
|
4
|
+
import { withoutFootnoteMarks } from "./html-footnote-marks.ts";
|
|
3
5
|
import { decodeEntities } from "./markup-text.ts";
|
|
4
6
|
|
|
5
7
|
const ID = new RegExp(String.raw`<([a-z][a-z0-9-]*)${ATTRIBUTES}\s+id\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))`, "giu");
|
|
@@ -80,7 +82,7 @@ const rangesByTag = (html: string): ((tag: string) => readonly ElementRange[]) =
|
|
|
80
82
|
* A heading's link to its own section goes when it stands just after the heading ("Copy link to Context"), or inside
|
|
81
83
|
* it as a mark without words ("Scope ¶"). A link with words inside the heading is its title and stays.
|
|
82
84
|
*/
|
|
83
|
-
|
|
85
|
+
const withoutHeadingSelfLinks = (html: string): string => {
|
|
84
86
|
const page = { ids: idTargets(html), html, rangesOf: rangesByTag(html) };
|
|
85
87
|
const cut = [...html.matchAll(HEADING_THEN_LINK)].reduce<{ readonly parts: readonly string[]; readonly from: number }>(
|
|
86
88
|
(acc, match) => ({
|
|
@@ -91,3 +93,24 @@ export const withoutHeadingSelfLinks = (html: string): string => {
|
|
|
91
93
|
);
|
|
92
94
|
return [...cut.parts, html.slice(cut.from)].join("");
|
|
93
95
|
};
|
|
96
|
+
|
|
97
|
+
const IN_PAGE_HREF = new RegExp(String.raw`^<a${ATTRIBUTES}\s+href\s*=\s*["']?\s*#`, "iu");
|
|
98
|
+
|
|
99
|
+
const HEADING = /(<h([1-6])\b[^>]*>)([\s\S]*?)(<\/h\2\s*>)/giu;
|
|
100
|
+
|
|
101
|
+
/** The link's words without the link. */
|
|
102
|
+
const linkText = (link: string): string => link.replace(/^<a\b[^>]*>/iu, "").replace(/<\/a\s*>$/iu, "");
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* A link within the page inside a heading is part of the heading: an accordion draws each panel's title as a link
|
|
106
|
+
* that opens the panel. Its words stay and the link goes, so that a block holding the heading is not read as a menu.
|
|
107
|
+
* A footnote mark in the heading goes first, as it does everywhere else.
|
|
108
|
+
*/
|
|
109
|
+
const withHeadingAnchorsAsText = (html: string): string =>
|
|
110
|
+
html.replace(HEADING, (_whole: string, open: string, _level: string, inside: string, close: string) => {
|
|
111
|
+
const words = withoutFootnoteMarks(inside).replace(ANY_LINK, (link: string) => (IN_PAGE_HREF.test(link) ? linkText(link) : link));
|
|
112
|
+
return `${open}${words}${close}`;
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
/** A heading's links read as the page means them: a self-link gone, a link within the page as the heading's words. */
|
|
116
|
+
export const withHeadingLinksRead = (html: string): string => withHeadingAnchorsAsText(withoutHeadingSelfLinks(html));
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Where a page's links point, kept without changing its text. A link's text stays as it is read; its address, when
|
|
2
|
+
// it is an absolute http(s) one, goes into a comment closing the section the link is in (<!-- https://… -->), so the
|
|
3
|
+
// document still holds what the section links to while the sentences are untouched. A relative address names no page
|
|
4
|
+
// without the page's own address, and a link without text is a picture. Pure.
|
|
5
|
+
import { ANY_LINK, hrefOf, stripTags } from "./html-elements.ts";
|
|
6
|
+
import { decodeEntities } from "./markup-text.ts";
|
|
7
|
+
|
|
8
|
+
const ADDRESS_START = "\u0004";
|
|
9
|
+
const ADDRESS_END = "\u0005";
|
|
10
|
+
|
|
11
|
+
const MARKED_ADDRESS = new RegExp(`${ADDRESS_START}([^${ADDRESS_END}]*)${ADDRESS_END}`, "gu");
|
|
12
|
+
|
|
13
|
+
const ABSOLUTE_WEB = /^https?:\/\/[^\s/?#]+/iu;
|
|
14
|
+
|
|
15
|
+
// Escaped as a browser sends them: a space would split the comment's list, a control character (the marks among
|
|
16
|
+
// them) would break the line or the mark, and "<", ">" and a second "-" would end or break the comment.
|
|
17
|
+
const UNSAFE_IN_COMMENT = /[\s\p{Cc}<>]|(?<=-)-/gu;
|
|
18
|
+
|
|
19
|
+
const percentEncoded = (character: string): string => (character === "-" ? "%2D" : encodeURIComponent(character));
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The address as it will be read once the page's character references are decoded: decoded and escaped here, its
|
|
23
|
+
* "&" written back as a reference so that the one decoding left gives the address again.
|
|
24
|
+
*/
|
|
25
|
+
const address = (href: string): string => decodeEntities(href).trim().replace(UNSAFE_IN_COMMENT, percentEncoded).replaceAll("&", "&");
|
|
26
|
+
|
|
27
|
+
const hasText = (link: string): boolean => decodeEntities(stripTags(link)).trim() !== "";
|
|
28
|
+
|
|
29
|
+
const marked = (link: string): string => {
|
|
30
|
+
const href = hrefOf(link);
|
|
31
|
+
if (!ABSOLUTE_WEB.test(decodeEntities(href).trim()) || !hasText(link)) return link;
|
|
32
|
+
return link.replace(/<\/a\s*>$/iu, `${ADDRESS_START}${address(href)}${ADDRESS_END}$&`);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** Each link to an absolute web address with its address marked after its text, for withSectionLinks to collect. */
|
|
36
|
+
export const withLinkAddressesMarked = (html: string): string => html.replace(ANY_LINK, marked);
|
|
37
|
+
|
|
38
|
+
const HEADING = /^#{1,6} /u;
|
|
39
|
+
|
|
40
|
+
const SPACED_MARK = new RegExp(`( ?)${MARKED_ADDRESS.source}( ?)`, "gu");
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A mark goes with the spacing the text had without it: between two spaces (a link's text ending in one) it leaves
|
|
44
|
+
* one, and a space it kept at the line's edge from the trimming goes.
|
|
45
|
+
*/
|
|
46
|
+
const withoutMarks = (line: string): string =>
|
|
47
|
+
line.replace(SPACED_MARK, (mark: string, before: string, _address: string, after: string, at: number) => {
|
|
48
|
+
if (before !== "" && after !== "") return " ";
|
|
49
|
+
return at === 0 || at + mark.length === line.length ? "" : `${before}${after}`;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const closing = (addresses: readonly string[]): string[] => (addresses.length === 0 ? [] : ["", `<!-- ${addresses.join(" ")} -->`, ""]);
|
|
53
|
+
|
|
54
|
+
/** The lines without their marks, each section closed by a comment listing the addresses its lines linked to. */
|
|
55
|
+
export const withSectionLinks = (lines: readonly string[]): string[] => {
|
|
56
|
+
const kept: string[] = [];
|
|
57
|
+
const pending: string[] = [];
|
|
58
|
+
const close = (): void => {
|
|
59
|
+
kept.push(...closing(pending));
|
|
60
|
+
pending.length = 0;
|
|
61
|
+
};
|
|
62
|
+
lines.forEach((line) => {
|
|
63
|
+
const text = withoutMarks(line);
|
|
64
|
+
if (HEADING.test(text)) close();
|
|
65
|
+
kept.push(text);
|
|
66
|
+
pending.push(...[...line.matchAll(MARKED_ADDRESS)].map((mark) => mark[1] ?? ""));
|
|
67
|
+
});
|
|
68
|
+
close();
|
|
69
|
+
return kept;
|
|
70
|
+
};
|