@sushichan044/kg-core 0.4.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -4
- package/dist/index.d.mts +312 -255
- package/dist/index.mjs +404 -50
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,7 +63,8 @@ element has source, display, and grapheme ranges; empty placement elements use
|
|
|
63
63
|
Parsers implement `ManuscriptParser`. Composers implement `ManuscriptComposer`
|
|
64
64
|
and provide Valibot schemas for their settings and layout. Proofreading rules
|
|
65
65
|
carry `kind: "parsed"` or `kind: "composed"` to declare which manuscript they
|
|
66
|
-
need, and report findings through `context.report`.
|
|
66
|
+
need, and report findings through `context.report`. A report may name a
|
|
67
|
+
`severity`; omitting it means `error`.
|
|
67
68
|
|
|
68
69
|
A plugin signals its own failure with a `Rejection` — a plain reason string.
|
|
69
70
|
Core turns that into a variant of the stage's error union, so plugins never
|
|
@@ -88,9 +89,45 @@ Grapheme ranges index the normalized grapheme array. Diagnostics include
|
|
|
88
89
|
one-based source line and column positions, so renderers do not need to search
|
|
89
90
|
or recalculate locations.
|
|
90
91
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
## Proofreading rules
|
|
93
|
+
|
|
94
|
+
`createDefaultProofreadingRules()` returns the rules whose answer does not
|
|
95
|
+
depend on the work: how a paragraph opens and how far it is indented,
|
|
96
|
+
punctuation before a closing bracket, spacing after `!` and `?`, ellipsis and
|
|
97
|
+
dash forms and counts, repeated punctuation and interpuncts, a minus sign that
|
|
98
|
+
no number follows, halfwidth Japanese punctuation, Arabic
|
|
99
|
+
numeral length, and Unicode variation sequences.
|
|
100
|
+
|
|
101
|
+
Rules that depend on the work's own conventions are exported individually and
|
|
102
|
+
report `warning` instead of `error`, so a caller opts into them:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
import {
|
|
106
|
+
consistentKanjiOpeningRule,
|
|
107
|
+
consistentLatinWidthRule,
|
|
108
|
+
consistentNumeralWidthRule,
|
|
109
|
+
createConsistentKanjiOpeningRule,
|
|
110
|
+
createDefaultProofreadingRules,
|
|
111
|
+
} from "@sushichan044/kg-core";
|
|
112
|
+
|
|
113
|
+
const rules = [
|
|
114
|
+
...createDefaultProofreadingRules(),
|
|
115
|
+
consistentNumeralWidthRule(),
|
|
116
|
+
consistentLatinWidthRule(),
|
|
117
|
+
consistentKanjiOpeningRule(),
|
|
118
|
+
];
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`createConsistentKanjiOpeningRule({ pairs })` replaces the built-in kanji and
|
|
122
|
+
kana pairs; like every configurable rule it returns a `ManuscriptResult` and
|
|
123
|
+
fails with `InvalidRuleOptions` rather than dropping bad options.
|
|
124
|
+
|
|
125
|
+
`dashRule()` prefers `―` (U+2015). Use `createDashRule({ preferred: "—" })` or
|
|
126
|
+
`createDashRule({ preferred: "─" })` when a work uses U+2014 or U+2500 instead.
|
|
127
|
+
The selected character must appear in even-length runs. Repeated choonpu (`ー`)
|
|
128
|
+
are not treated as dashes.
|
|
129
|
+
|
|
130
|
+
Diagnostics do not modify the source and do not contain automatic fixes.
|
|
94
131
|
|
|
95
132
|
## Browser support
|
|
96
133
|
|