@sushichan044/kg-core 0.9.4 → 0.9.5

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/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { c as ManuscriptResult, d as NamespacedId, f as ManuscriptRange, h as readonlyObject, l as ManuscriptDiagnostic, o as graphemeSegmenter, s as ValidationIssue } from "./question-or-exclamation-spacing-B5o23ZLf.mjs";
2
- import { c as ManuscriptOffsets, d as FontSizePt, f as FontPresetId, i as PaperSize, l as ManuscriptAppearanceSettings, n as novelComposer, o as NovelCompositionSettings, p as ParsedManuscript, r as ManuscriptGeometry, s as NovelFlowSettings, u as PaperSizeId } from "./novel-composer-DRgsEA2s.mjs";
1
+ import { c as ValidationIssue, f as NamespacedId, g as readonlyObject, l as ManuscriptResult, p as ManuscriptRange, s as graphemeSegmenter, u as ManuscriptDiagnostic } from "./question-or-exclamation-spacing-1tnZ4CLb.mjs";
2
+ import { c as ManuscriptOffsets, d as FontSizePt, f as FontPresetId, i as PaperSize, l as ManuscriptAppearanceSettings, n as novelComposer, o as NovelCompositionSettings, p as ParsedManuscript, r as ManuscriptGeometry, s as NovelFlowSettings, u as PaperSizeId } from "./novel-composer-BC8W63vw.mjs";
3
3
  import { n as assertNever, t as describeCause } from "./describe-cause-BV8mZ3Um.mjs";
4
4
  import * as v from "valibot";
5
5
  const Rejection = { schema: readonlyObject({ reason: v.string() }) };
package/dist/lint.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as characterClass, c as ManuscriptResult, d as NamespacedId, f as ManuscriptRange, h as readonlyObject, i as OPENING_BRACKETS, l as ManuscriptDiagnostic, m as readonlyArray, n as leadingSpaces, o as graphemeSegmenter, r as CLOSING_BRACKETS, s as ValidationIssue, t as questionOrExclamationSpacings, u as DiagnosticSeverity } from "./question-or-exclamation-spacing-B5o23ZLf.mjs";
1
+ import { a as OPENING_BRACKETS, c as ValidationIssue, d as DiagnosticSeverity, f as NamespacedId, g as readonlyObject, h as readonlyArray, i as CLOSING_BRACKETS, l as ManuscriptResult, n as leadingSpaces, o as characterClass, p as ManuscriptRange, s as graphemeSegmenter, t as questionOrExclamationSpacings, u as ManuscriptDiagnostic } from "./question-or-exclamation-spacing-1tnZ4CLb.mjs";
2
2
  import { n as assertNever, t as describeCause } from "./describe-cause-BV8mZ3Um.mjs";
3
3
  import * as v from "valibot";
4
4
  //#region src/proofreading/invalid-rule-options.ts
@@ -1,4 +1,4 @@
1
- import { c as ManuscriptResult, d as NamespacedId, f as ManuscriptRange, h as readonlyObject, i as OPENING_BRACKETS, m as readonlyArray, o as graphemeSegmenter, p as nonNegativeInteger, r as CLOSING_BRACKETS, t as questionOrExclamationSpacings } from "./question-or-exclamation-spacing-B5o23ZLf.mjs";
1
+ import { a as OPENING_BRACKETS, f as NamespacedId, g as readonlyObject, h as readonlyArray, i as CLOSING_BRACKETS, l as ManuscriptResult, m as nonNegativeInteger, p as ManuscriptRange, r as DIVIDING_PUNCTUATION, s as graphemeSegmenter, t as questionOrExclamationSpacings } from "./question-or-exclamation-spacing-1tnZ4CLb.mjs";
2
2
  import * as v from "valibot";
3
3
  import { eastAsianWidth } from "get-east-asian-width";
4
4
  const BoldAnnotation = { schema: readonlyObject({
@@ -237,7 +237,10 @@ function graphemeWidth(grapheme) {
237
237
  let width = 1;
238
238
  for (const character of grapheme) {
239
239
  const codePoint = character.codePointAt(0);
240
- if (codePoint !== void 0) width = Math.max(width, eastAsianWidth(codePoint, { ambiguousAsWide: true }));
240
+ if (codePoint !== void 0) {
241
+ const characterWidth = "!?‼⁇⁈⁉".includes(character) ? 2 : eastAsianWidth(codePoint, { ambiguousAsWide: true });
242
+ width = Math.max(width, characterWidth);
243
+ }
241
244
  }
242
245
  return width / 2;
243
246
  }
@@ -293,7 +296,7 @@ const japaneseCharacterClasses = [
293
296
  const OPENING = /* @__PURE__ */ new Set(`${OPENING_BRACKETS}【〘〝⦅«`);
294
297
  const CLOSING = /* @__PURE__ */ new Set(`${CLOSING_BRACKETS}】〙〟⦆»`);
295
298
  const HYPHENS = /* @__PURE__ */ new Set("‐‑⁃–");
296
- const DIVIDING_PUNCTUATION = /* @__PURE__ */ new Set("!?‼⁇⁈⁉");
299
+ const DIVIDING_MARKS = new Set(DIVIDING_PUNCTUATION);
297
300
  const MIDDLE_DOTS = /* @__PURE__ */ new Set("・:;");
298
301
  const SMALL_KANA = /* @__PURE__ */ new Set("ァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖ");
299
302
  const ITERATION_MARKS = /* @__PURE__ */ new Set("ヽヾゝゞ々〻");
@@ -322,7 +325,7 @@ function classify({ value, presentation }) {
322
325
  if (OPENING.has(value)) return "cl-01";
323
326
  if (CLOSING.has(value)) return "cl-02";
324
327
  if (HYPHENS.has(value)) return "cl-03";
325
- if (DIVIDING_PUNCTUATION.has(value)) return "cl-04";
328
+ if (DIVIDING_MARKS.has(value)) return "cl-04";
326
329
  if (MIDDLE_DOTS.has(value)) return "cl-05";
327
330
  if (value === "。" || value === ".") return "cl-06";
328
331
  if (value === "、" || value === ",") return "cl-07";
package/dist/plugin.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { c as ManuscriptResult, d as NamespacedId, s as ValidationIssue } from "./question-or-exclamation-spacing-B5o23ZLf.mjs";
2
- import { a as logicalInlineMeasurer, p as ParsedManuscript, t as createNovelComposer } from "./novel-composer-DRgsEA2s.mjs";
1
+ import { c as ValidationIssue, f as NamespacedId, l as ManuscriptResult } from "./question-or-exclamation-spacing-1tnZ4CLb.mjs";
2
+ import { a as logicalInlineMeasurer, p as ParsedManuscript, t as createNovelComposer } from "./novel-composer-BC8W63vw.mjs";
3
3
  export { ManuscriptResult, NamespacedId, ParsedManuscript, ValidationIssue, createNovelComposer, logicalInlineMeasurer };
@@ -189,6 +189,13 @@ function characterClass(characters) {
189
189
  return characters.replaceAll(/[\\\]^-]/gu, "\\$&");
190
190
  }
191
191
  //#endregion
192
+ //#region src/internal/japanese-punctuation.ts
193
+ /**
194
+ * JLReq cl-04 occupies a full em, including compound marks whose Unicode East Asian Width is
195
+ * neutral.
196
+ */
197
+ const DIVIDING_PUNCTUATION = "!?‼⁇⁈⁉";
198
+ //#endregion
192
199
  //#region src/internal/japanese-spaces.ts
193
200
  const LEADING_SPACES = /^[  \t]+/u;
194
201
  /**
@@ -203,7 +210,7 @@ function leadingSpaces(text) {
203
210
  /**
204
211
  * Runs, not single marks: `!?` is one mark and takes one gap, so the gap belongs after the run.
205
212
  */
206
- const MARKS = /[?!]+/gu;
213
+ const MARKS = new RegExp(`[${characterClass(DIVIDING_PUNCTUATION)}]+`, "gu");
207
214
  function analyzeMatch(line, marks) {
208
215
  const start = marks.index;
209
216
  if (start === void 0) return void 0;
@@ -240,7 +247,7 @@ function analyzeMatch(line, marks) {
240
247
  };
241
248
  }
242
249
  /**
243
- * Classifies the spacing after each run of fullwidth question or exclamation marks in one display
250
+ * Classifies the spacing after each run of Japanese question or exclamation marks in one display
244
251
  * line. Runs at the end of the line or immediately before a closing bracket need no gap and are
245
252
  * omitted from the result.
246
253
  */
@@ -248,4 +255,4 @@ function questionOrExclamationSpacings(line) {
248
255
  return [...line.matchAll(MARKS)].map((marks) => analyzeMatch(line, marks)).filter((spacing) => spacing !== void 0);
249
256
  }
250
257
  //#endregion
251
- export { characterClass as a, ManuscriptResult as c, NamespacedId as d, ManuscriptRange as f, readonlyObject as h, OPENING_BRACKETS as i, ManuscriptDiagnostic as l, readonlyArray as m, leadingSpaces as n, graphemeSegmenter as o, nonNegativeInteger as p, CLOSING_BRACKETS as r, ValidationIssue as s, questionOrExclamationSpacings as t, DiagnosticSeverity as u };
258
+ export { OPENING_BRACKETS as a, ValidationIssue as c, DiagnosticSeverity as d, NamespacedId as f, readonlyObject as g, readonlyArray as h, CLOSING_BRACKETS as i, ManuscriptResult as l, nonNegativeInteger as m, leadingSpaces as n, characterClass as o, ManuscriptRange as p, DIVIDING_PUNCTUATION as r, graphemeSegmenter as s, questionOrExclamationSpacings as t, ManuscriptDiagnostic as u };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sushichan044/kg-core",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
4
4
  "description": "Framework-independent parsing, composition, and proofreading for Japanese manuscripts",
5
5
  "keywords": [
6
6
  "japanese",