@sushichan044/kg-core 0.7.0 → 0.8.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 CHANGED
@@ -85,8 +85,12 @@ a quarter em between Japanese and a numeral, unit symbol, or Western character,
85
85
  solid where two of those punctuation marks meet.
86
86
 
87
87
  An overflowing line is answered by reducing that space or by hanging a comma or full
88
- stop; a short line is answered by stretching eligible space; a line that admits none
89
- of these is forced. The choice is made for the paragraph rather than line by line,
88
+ stop; a short line is answered by opening up space where JLReq 3.8.4 and appendix 表6
89
+ allow it — the Japanese-to-Western quarter em first, up to a half, then a solid pair
90
+ between kana, kanji, and the marks that go with them, up to a quarter. Space around
91
+ brackets, commas, full stops, middle dots, hyphens, and an ideographic space is never
92
+ opened up. A line that admits none of these is forced. The choice is made for the
93
+ paragraph rather than line by line,
90
94
  minimizing in order the number of forced lines, then stretched, then hanging, then
91
95
  shrunk lines that spent visible space. Which space may be reduced, and in which
92
96
  order, follows JLReq 3.8.3 and appendix 表3: the space at the line end goes first and
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
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-Cl6LJXOA.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-CROZLBqt.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() }) };
@@ -366,13 +366,40 @@ const REDUCTION_STAGE = {
366
366
  mixedText: 3
367
367
  };
368
368
  /**
369
- * 無印 in 表1: the pair is set solid.
369
+ * The stages JLReq 3.8.4 adds inter-character space in, as glue priorities on the same reading as
370
+ * {@link REDUCTION_STAGE}: the lower the number, the earlier the paragraph optimizer takes it. A
371
+ * line is either reduced or expanded, never both, so the two scales never meet.
372
+ *
373
+ * Stage 1 is the western word space (cl-26), absent for the same reason it is absent from the
374
+ * reduction stages. Stage 4 spreads whatever a、b and c could not absorb across every character gap
375
+ * that is not unbreakable, and is deliberately not implemented: it would justify every line that
376
+ * currently falls short, which reads as prose combed out to the margin rather than a novel.
377
+ */
378
+ const EXPANSION_STAGE = {
379
+ /**
380
+ * Stage 2: the quarter em between Japanese and a numeral, unit symbol or western character.
381
+ */
382
+ mixedText: 1,
383
+ /**
384
+ * Stage 3: everywhere else 表6 admits, from solid up to a quarter em.
385
+ */
386
+ solid: 2
387
+ };
388
+ /**
389
+ * 無印 in 表1 with no colour in 表6: the pair is set solid and line adjustment leaves it alone.
370
390
  */
371
391
  const SOLID = {
392
+ kind: "glue",
393
+ naturalWidthEm: 0
394
+ };
395
+ /**
396
+ * `1/4` in 表6: set solid, but line adjustment may open it up to a quarter em.
397
+ */
398
+ const SOLID_EXPANDABLE = {
372
399
  kind: "glue",
373
400
  naturalWidthEm: 0,
374
401
  stretch: {
375
- priority: 3,
402
+ priority: EXPANSION_STAGE.solid,
376
403
  amountEm: .25
377
404
  }
378
405
  };
@@ -413,9 +440,26 @@ const FIXED_QUARTER = {
413
440
  naturalWidthEm: .25
414
441
  };
415
442
  /**
416
- * `1/4-1/8` in 表3: the Japanese-to-western quarter em, reducible to an eighth.
443
+ * `1/4-1/8` in 表3 with `1/4-1/2` in 表6: the Japanese-to-western quarter em, reducible to an eighth
444
+ * and expandable to a half.
417
445
  */
418
446
  const MIXED_TEXT_QUARTER = {
447
+ kind: "glue",
448
+ naturalWidthEm: .25,
449
+ shrink: {
450
+ priority: REDUCTION_STAGE.mixedText,
451
+ amountEm: .125
452
+ },
453
+ stretch: {
454
+ priority: EXPANSION_STAGE.mixedText,
455
+ amountEm: .25
456
+ }
457
+ };
458
+ /**
459
+ * The same quarter em where 表6 leaves it out of the expansion: between a unit symbol and the
460
+ * quantity on either side of it.
461
+ */
462
+ const UNIT_SYMBOL_QUARTER = {
419
463
  kind: "glue",
420
464
  naturalWidthEm: .25,
421
465
  shrink: {
@@ -502,6 +546,39 @@ const PUNCTUATION_TAKING_SPACE_AFTER = [
502
546
  "cl-07"
503
547
  ];
504
548
  /**
549
+ * 表6 の色付きの小間: the classes a solid pair may be opened up between at stage 3. Neither list holds a
550
+ * bracket, a middle dot, a full stop, a comma, a hyphen, an ideographic space or a word space —
551
+ * JLReq opens none of those — and only the left-hand list holds a numeral, unit symbol or western
552
+ * character, since the space on their Japanese side belongs to stage 2 instead.
553
+ */
554
+ const EXPANDABLE_BEFORE = [
555
+ "cl-08",
556
+ "cl-09",
557
+ "cl-10",
558
+ "cl-11",
559
+ "cl-12",
560
+ "cl-13",
561
+ "cl-15",
562
+ "cl-16",
563
+ "cl-19",
564
+ "cl-24",
565
+ "cl-25",
566
+ "cl-27",
567
+ "cl-30"
568
+ ];
569
+ const EXPANDABLE_AFTER = [
570
+ "cl-08",
571
+ "cl-09",
572
+ "cl-10",
573
+ "cl-11",
574
+ "cl-12",
575
+ "cl-13",
576
+ "cl-15",
577
+ "cl-16",
578
+ "cl-19",
579
+ "cl-30"
580
+ ];
581
+ /**
505
582
  * The classes JLReq 3.1.2 sets on a half em rather than a full one.
506
583
  */
507
584
  const HALF_EM_CLASSES = /* @__PURE__ */ new Set([
@@ -517,6 +594,44 @@ const PAIR_SPACING_TABLE = new Map([
517
594
  right: "any",
518
595
  spacing: SOLID
519
596
  },
597
+ {
598
+ left: EXPANDABLE_BEFORE,
599
+ right: EXPANDABLE_AFTER,
600
+ spacing: SOLID_EXPANDABLE
601
+ },
602
+ {
603
+ left: [
604
+ "cl-08",
605
+ "cl-12",
606
+ "cl-13"
607
+ ],
608
+ right: NUMERAL_UNIT_OR_WESTERN,
609
+ spacing: SOLID_EXPANDABLE
610
+ },
611
+ {
612
+ left: ["cl-08"],
613
+ right: ["cl-24", "cl-25"],
614
+ spacing: SOLID
615
+ },
616
+ {
617
+ left: ["cl-12"],
618
+ right: ["cl-24"],
619
+ spacing: SOLID
620
+ },
621
+ {
622
+ left: ["cl-24"],
623
+ right: ["cl-13"],
624
+ spacing: SOLID
625
+ },
626
+ {
627
+ left: [
628
+ "cl-09",
629
+ "cl-10",
630
+ "cl-11"
631
+ ],
632
+ right: ["cl-08"],
633
+ spacing: SOLID
634
+ },
520
635
  {
521
636
  left: "any",
522
637
  right: ["cl-01"],
@@ -545,12 +660,12 @@ const PAIR_SPACING_TABLE = new Map([
545
660
  {
546
661
  left: ["cl-25"],
547
662
  right: ["cl-24"],
548
- spacing: MIXED_TEXT_QUARTER
663
+ spacing: UNIT_SYMBOL_QUARTER
549
664
  },
550
665
  {
551
666
  left: ["cl-27"],
552
667
  right: ["cl-25"],
553
- spacing: MIXED_TEXT_QUARTER
668
+ spacing: UNIT_SYMBOL_QUARTER
554
669
  },
555
670
  {
556
671
  left: ["cl-24"],
package/dist/plugin.mjs CHANGED
@@ -1,3 +1,3 @@
1
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-Cl6LJXOA.mjs";
2
+ import { a as logicalInlineMeasurer, p as ParsedManuscript, t as createNovelComposer } from "./novel-composer-CROZLBqt.mjs";
3
3
  export { ManuscriptResult, NamespacedId, ParsedManuscript, ValidationIssue, createNovelComposer, logicalInlineMeasurer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sushichan044/kg-core",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Framework-independent parsing, composition, and proofreading for Japanese manuscripts",
5
5
  "keywords": [
6
6
  "japanese",