@sushichan044/kg-core 0.11.1 → 0.11.3
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 +46 -3
- package/dist/index.d.mts +344 -317
- package/dist/index.mjs +157 -6
- package/dist/lint.d.mts +5 -7
- package/dist/lint.mjs +29 -18
- package/dist/{novel-composer-z0cv8OHb.mjs → novel-composer-DNsKrJIP.mjs} +141 -56
- package/dist/plugin.d.mts +1 -1
- package/dist/plugin.mjs +6 -2
- package/dist/{presentation-kind-CvlmQ3AY.d.mts → presentation-kind-BmW1Edu7.d.mts} +1068 -1010
- package/dist/{question-or-exclamation-spacing-C5cFLeKr.mjs → question-or-exclamation-spacing-D7TSDUG8.mjs} +38 -22
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { _ as ManuscriptRange, a as characterClass, b as readonlyArray, c as isSentenceEndingMark, d as graphemeSegmenter, g as NamespacedId, i as OPENING_BRACKETS, l as validAdditionalSentenceEndingMarks, o as SENTENCE_ENDING_MARKS, p as ManuscriptResult, r as CLOSING_BRACKETS, s as TATE_CHU_YOKO_MARKS, t as questionOrExclamationSpacings, u as assertNever, v as TextRange, x as readonlyObject, y as nonNegativeInteger } from "./question-or-exclamation-spacing-D7TSDUG8.mjs";
|
|
2
2
|
import * as v from "valibot";
|
|
3
3
|
import { eastAsianWidth } from "get-east-asian-width";
|
|
4
4
|
const BoldAnnotation = { schema: readonlyObject({
|
|
@@ -116,9 +116,29 @@ const A5_PAGE_FORMAT = {
|
|
|
116
116
|
outerMm: 13
|
|
117
117
|
}
|
|
118
118
|
};
|
|
119
|
+
const A6_PAGE_FORMAT = {
|
|
120
|
+
fontSizeQ: 12,
|
|
121
|
+
flow: {
|
|
122
|
+
lineLengthEm: 41,
|
|
123
|
+
linesPerStage: 17,
|
|
124
|
+
stagesPerPage: 1
|
|
125
|
+
},
|
|
126
|
+
page: {
|
|
127
|
+
lineGapMm: 7 / 4,
|
|
128
|
+
stageGapMm: 0,
|
|
129
|
+
topMm: 12.5,
|
|
130
|
+
bottomMm: 12.5,
|
|
131
|
+
innerMm: 16,
|
|
132
|
+
outerMm: 10
|
|
133
|
+
}
|
|
134
|
+
};
|
|
119
135
|
//#endregion
|
|
120
136
|
//#region src/appearance/font-preset-id.ts
|
|
121
|
-
const FontPresetIdSchema = v.picklist([
|
|
137
|
+
const FontPresetIdSchema = v.picklist([
|
|
138
|
+
"mincho",
|
|
139
|
+
"gothic",
|
|
140
|
+
"genei-koburi"
|
|
141
|
+
]);
|
|
122
142
|
const FontPresetId = {
|
|
123
143
|
schema: FontPresetIdSchema,
|
|
124
144
|
is: (value) => v.is(FontPresetIdSchema, value)
|
|
@@ -331,6 +351,7 @@ const NovelFlowSettings = {
|
|
|
331
351
|
//#endregion
|
|
332
352
|
//#region src/composer/composition-settings.ts
|
|
333
353
|
const NovelCompositionSettingsSchema = v.pipe(readonlyObject({
|
|
354
|
+
additionalSentenceEndingMarks: v.optional(v.pipe(v.string(), v.check(validAdditionalSentenceEndingMarks))),
|
|
334
355
|
flow: NovelFlowSettings.schema,
|
|
335
356
|
offsets: ManuscriptOffsets.schema,
|
|
336
357
|
appearance: ManuscriptAppearanceSettings.schema,
|
|
@@ -338,7 +359,10 @@ const NovelCompositionSettingsSchema = v.pipe(readonlyObject({
|
|
|
338
359
|
}), v.check(({ flow, offsets }) => LineOffset.total(offsets.stage) <= ManuscriptOffsets.maxStageTotal(flow) && LineOffset.total(offsets.page) <= ManuscriptOffsets.maxPageTotal(flow, offsets.stage), "page or stage offsets leave no usable novel lines"), v.check(({ flow, appearance, page }) => {
|
|
339
360
|
const geometry = ManuscriptGeometry.of(flow, appearance, page);
|
|
340
361
|
return Math.abs(geometry.contentHeightMm + page.topMm + page.bottomMm - geometry.paperHeightMm) <= 1e-6 && Math.abs(geometry.contentWidthMm + page.innerMm + page.outerMm - geometry.paperWidthMm) <= 1e-6;
|
|
341
|
-
}, "text dimensions and margins must match the paper dimensions"), v.check(({ appearance, page }) => page.lineGapMm + 1e-6 >= appearance.fontSizeQ / 8, "line gap must leave room for half-size annotations"), v.check(({ flow, appearance, page }) =>
|
|
362
|
+
}, "text dimensions and margins must match the paper dimensions"), v.check(({ appearance, page }) => page.lineGapMm + 1e-6 >= appearance.fontSizeQ / 8, "line gap must leave room for half-size annotations"), v.check(({ flow, appearance, page }) => {
|
|
363
|
+
const format = appearance.paperSize === "a5" ? A5_PAGE_FORMAT : appearance.paperSize === "a6" ? A6_PAGE_FORMAT : null;
|
|
364
|
+
return format === null || appearance.fontSizeQ === format.fontSizeQ && flow.lineLengthEm === format.flow.lineLengthEm && flow.linesPerStage === format.flow.linesPerStage && flow.stagesPerPage === format.flow.stagesPerPage && page.lineGapMm === format.page.lineGapMm && page.stageGapMm === format.page.stageGapMm && page.topMm === format.page.topMm && page.bottomMm === format.page.bottomMm && page.innerMm === format.page.innerMm && page.outerMm === format.page.outerMm;
|
|
365
|
+
}, "A5 and A6 use their fixed page formats"));
|
|
342
366
|
const NovelCompositionSettings = {
|
|
343
367
|
schema: NovelCompositionSettingsSchema,
|
|
344
368
|
defaults: {
|
|
@@ -348,21 +372,22 @@ const NovelCompositionSettings = {
|
|
|
348
372
|
page: ManuscriptPageSettings.defaults
|
|
349
373
|
},
|
|
350
374
|
/**
|
|
351
|
-
* Select the fixed A5 format, or centre the current grid on another paper size.
|
|
375
|
+
* Select the fixed A5 or A6 format, or centre the current grid on another paper size.
|
|
352
376
|
*/
|
|
353
377
|
forPaper: (paperSize, settings) => {
|
|
354
378
|
const appearance = {
|
|
355
379
|
...settings.appearance,
|
|
356
380
|
paperSize
|
|
357
381
|
};
|
|
358
|
-
|
|
382
|
+
const format = paperSize === "a5" ? A5_PAGE_FORMAT : paperSize === "a6" ? A6_PAGE_FORMAT : null;
|
|
383
|
+
if (format !== null) return {
|
|
359
384
|
...settings,
|
|
360
|
-
flow:
|
|
385
|
+
flow: format.flow,
|
|
361
386
|
appearance: {
|
|
362
387
|
...appearance,
|
|
363
|
-
fontSizeQ:
|
|
388
|
+
fontSizeQ: format.fontSizeQ
|
|
364
389
|
},
|
|
365
|
-
page:
|
|
390
|
+
page: format.page
|
|
366
391
|
};
|
|
367
392
|
return {
|
|
368
393
|
...settings,
|
|
@@ -524,7 +549,7 @@ function presentationOf(text) {
|
|
|
524
549
|
* Recognize sentence-wide presentation while keeping words as separate line-break units. Standalone
|
|
525
550
|
* dotted abbreviations retain the existing per-token presentation.
|
|
526
551
|
*/
|
|
527
|
-
function
|
|
552
|
+
function recognizeText(graphemes) {
|
|
528
553
|
const runs = [];
|
|
529
554
|
const push = (members, presentation) => {
|
|
530
555
|
const range = ManuscriptRange.merge(members.map((member) => member.range));
|
|
@@ -569,6 +594,25 @@ function recognize(graphemes) {
|
|
|
569
594
|
}
|
|
570
595
|
return runs;
|
|
571
596
|
}
|
|
597
|
+
/**
|
|
598
|
+
* Split configured symbols before recognizing western words and presentation runs.
|
|
599
|
+
*/
|
|
600
|
+
function recognize(graphemes, additionalSentenceEndingMarks = "") {
|
|
601
|
+
const runs = [];
|
|
602
|
+
let start = 0;
|
|
603
|
+
for (const [index, grapheme] of graphemes.entries()) {
|
|
604
|
+
if (!isSentenceEndingMark(grapheme.value, additionalSentenceEndingMarks) || isSentenceEndingMark(grapheme.value)) continue;
|
|
605
|
+
runs.push(...recognizeText(graphemes.slice(start, index)));
|
|
606
|
+
runs.push({
|
|
607
|
+
range: grapheme.range,
|
|
608
|
+
members: [grapheme],
|
|
609
|
+
presentation: "mixed"
|
|
610
|
+
});
|
|
611
|
+
start = index + 1;
|
|
612
|
+
}
|
|
613
|
+
runs.push(...recognizeText(graphemes.slice(start)));
|
|
614
|
+
return runs;
|
|
615
|
+
}
|
|
572
616
|
const CompositionRun = { recognize };
|
|
573
617
|
//#endregion
|
|
574
618
|
//#region src/composer/internal/emphasis-placement.ts
|
|
@@ -1096,10 +1140,10 @@ const boundaryClasses = [
|
|
|
1096
1140
|
const OPENING = /* @__PURE__ */ new Set(`${OPENING_BRACKETS}【〘〝⦅«`);
|
|
1097
1141
|
const CLOSING = /* @__PURE__ */ new Set(`${CLOSING_BRACKETS}】〙〟⦆»`);
|
|
1098
1142
|
const HYPHENS = /* @__PURE__ */ new Set("‐‑⁃–");
|
|
1099
|
-
const DIVIDING_MARKS = new Set(
|
|
1143
|
+
const DIVIDING_MARKS = new Set(SENTENCE_ENDING_MARKS);
|
|
1100
1144
|
const COMBINED_DIVIDING_MARKS = new Set(TATE_CHU_YOKO_MARKS);
|
|
1101
1145
|
const MIDDLE_DOTS = /* @__PURE__ */ new Set("・:;");
|
|
1102
|
-
const SMALL_KANA = /* @__PURE__ */ new Set("
|
|
1146
|
+
const SMALL_KANA = /* @__PURE__ */ new Set("ァィゥェォッャュョヮヵヶㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿぁぃぅぇぉっゃゅょゎゕゖ");
|
|
1103
1147
|
const ITERATION_MARKS = /* @__PURE__ */ new Set("ヽヾゝゞ々〻");
|
|
1104
1148
|
const INSEPARABLE = /* @__PURE__ */ new Set("—―…‥─〳〴〵");
|
|
1105
1149
|
const PREFIXED_ABBREVIATIONS = /* @__PURE__ */ new Set("¥$£##");
|
|
@@ -1122,6 +1166,7 @@ const WESTERN = /^[\p{Script=Latin}\p{Script=Greek}\p{Script=Cyrillic}]$/u;
|
|
|
1122
1166
|
* the same as a tate-chu-yoko run's 3.2.5.
|
|
1123
1167
|
*/
|
|
1124
1168
|
function classify({ value, presentation }) {
|
|
1169
|
+
value = value.replace(/[\u3099\u309A]/gu, "");
|
|
1125
1170
|
switch (presentation) {
|
|
1126
1171
|
case "tate-chu-yoko": return COMBINED_DIVIDING_MARKS.has(value) ? "cl-04" : "cl-30";
|
|
1127
1172
|
case "upright": return "cl-19";
|
|
@@ -1883,10 +1928,11 @@ const RunMeasurement = {
|
|
|
1883
1928
|
//#region src/composer/internal/measurement-session.ts
|
|
1884
1929
|
const MeasurementSession = { create: (provider, settings) => {
|
|
1885
1930
|
const cache = /* @__PURE__ */ new Map();
|
|
1886
|
-
const get = (text, kind, presentation = "mixed") => {
|
|
1931
|
+
const get = (text, kind, presentation = "mixed", style) => {
|
|
1887
1932
|
const request = kind === "base" ? {
|
|
1888
1933
|
text,
|
|
1889
1934
|
kind,
|
|
1935
|
+
...style === void 0 ? {} : { style },
|
|
1890
1936
|
presentation,
|
|
1891
1937
|
fontPreset: settings.appearance.fontPreset,
|
|
1892
1938
|
fontSizeQ: settings.appearance.fontSizeQ,
|
|
@@ -1895,6 +1941,7 @@ const MeasurementSession = { create: (provider, settings) => {
|
|
|
1895
1941
|
} : {
|
|
1896
1942
|
text,
|
|
1897
1943
|
kind,
|
|
1944
|
+
...style === void 0 ? {} : { style },
|
|
1898
1945
|
presentation: "mixed",
|
|
1899
1946
|
fontPreset: settings.appearance.fontPreset,
|
|
1900
1947
|
fontSizeQ: settings.appearance.fontSizeQ,
|
|
@@ -1909,8 +1956,8 @@ const MeasurementSession = { create: (provider, settings) => {
|
|
|
1909
1956
|
};
|
|
1910
1957
|
return {
|
|
1911
1958
|
get,
|
|
1912
|
-
pieces: (text, kind, presentation) => {
|
|
1913
|
-
const full = get(text, kind, presentation);
|
|
1959
|
+
pieces: (text, kind, presentation, style) => {
|
|
1960
|
+
const full = get(text, kind, presentation, style);
|
|
1914
1961
|
if (full === void 0) return void 0;
|
|
1915
1962
|
if (full.kind === "clustered") return full.clusters.map((cluster) => ({
|
|
1916
1963
|
textRange: cluster.textRange,
|
|
@@ -1940,7 +1987,7 @@ const MeasurementSession = { create: (provider, settings) => {
|
|
|
1940
1987
|
const pieces = [];
|
|
1941
1988
|
let offsetEm = 0;
|
|
1942
1989
|
for (const { segment, index } of segments) {
|
|
1943
|
-
const measured = get(segment, kind, presentation);
|
|
1990
|
+
const measured = get(segment, kind, presentation, style);
|
|
1944
1991
|
if (measured === void 0) return void 0;
|
|
1945
1992
|
const cluster = measured.kind === "clustered" ? measured.clusters[0] : void 0;
|
|
1946
1993
|
pieces.push({
|
|
@@ -2688,8 +2735,8 @@ const RubyLineLayout = {
|
|
|
2688
2735
|
};
|
|
2689
2736
|
//#endregion
|
|
2690
2737
|
//#region src/composer/internal/source-space.ts
|
|
2691
|
-
const SourceSpace = { collect: (graphemes, advancesEm) => {
|
|
2692
|
-
const gaps = new Set(questionOrExclamationSpacings(graphemes.map(({ value }) => value).join("")).filter((spacing) => spacing.kind === "valid").map(({ gap }) => gap.start));
|
|
2738
|
+
const SourceSpace = { collect: (graphemes, advancesEm, additionalSentenceEndingMarks = "") => {
|
|
2739
|
+
const gaps = new Set(questionOrExclamationSpacings(graphemes.map(({ value }) => value).join(""), additionalSentenceEndingMarks).filter((spacing) => spacing.kind === "valid").map(({ gap }) => gap.start));
|
|
2693
2740
|
let offset = 0;
|
|
2694
2741
|
return graphemes.flatMap((grapheme, index) => {
|
|
2695
2742
|
const separator = gaps.has(offset);
|
|
@@ -2854,7 +2901,7 @@ function graphemeWidth(grapheme) {
|
|
|
2854
2901
|
for (const character of grapheme) {
|
|
2855
2902
|
const codePoint = character.codePointAt(0);
|
|
2856
2903
|
if (codePoint !== void 0) {
|
|
2857
|
-
const characterWidth =
|
|
2904
|
+
const characterWidth = SENTENCE_ENDING_MARKS.includes(character) ? 2 : eastAsianWidth(codePoint, { ambiguousAsWide: true });
|
|
2858
2905
|
width = Math.max(width, characterWidth);
|
|
2859
2906
|
}
|
|
2860
2907
|
}
|
|
@@ -2889,43 +2936,81 @@ function displayedLines(graphemes) {
|
|
|
2889
2936
|
if (lines.length > 1 && endedWithLineBreak) lines.pop();
|
|
2890
2937
|
return lines;
|
|
2891
2938
|
}
|
|
2892
|
-
function
|
|
2893
|
-
const
|
|
2939
|
+
function styleGroups(run, annotations) {
|
|
2940
|
+
const groups = [];
|
|
2941
|
+
if (annotations.length === 0) return [{
|
|
2942
|
+
members: run.members,
|
|
2943
|
+
style: {
|
|
2944
|
+
weight: 400,
|
|
2945
|
+
slant: "normal"
|
|
2946
|
+
}
|
|
2947
|
+
}];
|
|
2948
|
+
for (const member of run.members) {
|
|
2949
|
+
const styles = annotations.filter((annotation) => (annotation.kind === "bold" || annotation.kind === "italic") && ManuscriptRange.overlaps(annotation.range, member.range));
|
|
2950
|
+
const weight = styles.some(({ kind }) => kind === "bold") ? 700 : 400;
|
|
2951
|
+
const slant = styles.some(({ kind }) => kind === "italic") ? "italic" : "normal";
|
|
2952
|
+
const last = groups.at(-1);
|
|
2953
|
+
if (last !== void 0 && (run.presentation !== "sideways" || last.style.weight === weight && last.style.slant === slant)) last.members.push(member);
|
|
2954
|
+
else groups.push({
|
|
2955
|
+
members: [member],
|
|
2956
|
+
style: {
|
|
2957
|
+
weight,
|
|
2958
|
+
slant
|
|
2959
|
+
}
|
|
2960
|
+
});
|
|
2961
|
+
}
|
|
2962
|
+
return groups;
|
|
2963
|
+
}
|
|
2964
|
+
/**
|
|
2965
|
+
* Preserve shaped advances while keeping partial annotations on their own bases.
|
|
2966
|
+
*/
|
|
2967
|
+
function measureSourceLine(sourceLine, annotations, measurements, additionalSentenceEndingMarks) {
|
|
2968
|
+
const runs = CompositionRun.recognize(sourceLine, additionalSentenceEndingMarks);
|
|
2894
2969
|
const rubyAssociations = RubyAssociation.collect(annotations, sourceLine);
|
|
2970
|
+
const styles = annotations.filter(({ kind }) => kind === "bold" || kind === "italic");
|
|
2895
2971
|
const atoms = [];
|
|
2972
|
+
let renderGroup = 0;
|
|
2896
2973
|
for (const [runIndex, run] of runs.entries()) {
|
|
2897
|
-
const
|
|
2898
|
-
const
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
const
|
|
2905
|
-
const
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
const
|
|
2909
|
-
const
|
|
2910
|
-
const
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2974
|
+
const partialRuby = run.presentation === "sideways" && rubyAssociations.some(({ baseRange }) => ManuscriptRange.overlaps(baseRange, run.range) && (baseRange.graphemes.start > run.range.graphemes.start || baseRange.graphemes.end < run.range.graphemes.end));
|
|
2975
|
+
for (const group of styleGroups(run, styles)) {
|
|
2976
|
+
renderGroup += 1;
|
|
2977
|
+
const text = group.members.map(({ value }) => value).join("");
|
|
2978
|
+
const style = group.style.weight === 400 && group.style.slant === "normal" ? void 0 : group.style;
|
|
2979
|
+
const pieces = measurements.pieces(text, "base", run.presentation, style);
|
|
2980
|
+
if (pieces === void 0) return void 0;
|
|
2981
|
+
const clusteredSideways = run.presentation === "sideways" && measurements.get(text, "base", run.presentation, style)?.kind === "clustered";
|
|
2982
|
+
const combineRun = run.presentation === "tate-chu-yoko" || pieces.length < group.members.length || clusteredSideways && group.members.length > 1 && !partialRuby;
|
|
2983
|
+
let memberStart = 0;
|
|
2984
|
+
for (const piece of pieces) {
|
|
2985
|
+
const memberCount = [...graphemeSegmenter.segment(piece.value)].length;
|
|
2986
|
+
const members = group.members.slice(memberStart, memberStart + memberCount);
|
|
2987
|
+
const clusterRange = memberCount > 1 ? ManuscriptRange.merge(members.map(({ range }) => range)) : null;
|
|
2988
|
+
for (const [memberIndex, grapheme] of members.entries()) {
|
|
2989
|
+
const first = memberIndex === 0;
|
|
2990
|
+
const renderAdvanceEm = first ? piece.renderSpan.advanceEm : 0;
|
|
2991
|
+
const measuredAdvanceEm = first ? piece.layoutSpan.advanceEm : 0;
|
|
2992
|
+
const sentenceEndingMark = isSentenceEndingMark(grapheme.value, additionalSentenceEndingMarks);
|
|
2993
|
+
const characterClass = sentenceEndingMark ? "cl-04" : TYPESETTING_PROFILE.classify({
|
|
2994
|
+
value: grapheme.value,
|
|
2995
|
+
presentation: run.presentation
|
|
2996
|
+
});
|
|
2997
|
+
const metrics = TYPESETTING_PROFILE.boxMetrics(characterClass, sentenceEndingMark && !combineRun ? 1 : measuredAdvanceEm);
|
|
2998
|
+
atoms.push({
|
|
2999
|
+
grapheme,
|
|
3000
|
+
runIndex,
|
|
3001
|
+
renderGroup,
|
|
3002
|
+
characterClass,
|
|
3003
|
+
intrinsicBoxAdvanceEm: metrics.advanceEm,
|
|
3004
|
+
boxAdvanceEm: metrics.advanceEm,
|
|
3005
|
+
renderAdvanceEm,
|
|
3006
|
+
renderOffsetEm: metrics.renderOffsetEm + (first ? piece.renderSpan.offsetEm - piece.layoutSpan.offsetEm : 0),
|
|
3007
|
+
presentation: run.presentation,
|
|
3008
|
+
clusterRange,
|
|
3009
|
+
combineRun
|
|
3010
|
+
});
|
|
3011
|
+
}
|
|
3012
|
+
memberStart += memberCount;
|
|
2927
3013
|
}
|
|
2928
|
-
memberStart += memberCount;
|
|
2929
3014
|
}
|
|
2930
3015
|
}
|
|
2931
3016
|
const candidateReadings = [];
|
|
@@ -2934,8 +3019,8 @@ function measureSourceLine(sourceLine, annotations, measurements) {
|
|
|
2934
3019
|
const physicalRange = (first, last) => {
|
|
2935
3020
|
const left = atoms[first];
|
|
2936
3021
|
const right = atoms[last];
|
|
2937
|
-
while (first > 0 && left?.combineRun === true && atoms[first - 1]?.
|
|
2938
|
-
while (last + 1 < atoms.length && right?.combineRun === true && atoms[last + 1]?.
|
|
3022
|
+
while (first > 0 && left?.combineRun === true && atoms[first - 1]?.renderGroup === left.renderGroup) first -= 1;
|
|
3023
|
+
while (last + 1 < atoms.length && right?.combineRun === true && atoms[last + 1]?.renderGroup === right.renderGroup) last += 1;
|
|
2939
3024
|
return {
|
|
2940
3025
|
start: first,
|
|
2941
3026
|
end: last + 1
|
|
@@ -2965,7 +3050,7 @@ function measureSourceLine(sourceLine, annotations, measurements) {
|
|
|
2965
3050
|
});
|
|
2966
3051
|
}
|
|
2967
3052
|
}
|
|
2968
|
-
const sourceSpaces = SourceSpace.collect(sourceLine, atoms.map(({ boxAdvanceEm }) => boxAdvanceEm));
|
|
3053
|
+
const sourceSpaces = SourceSpace.collect(sourceLine, atoms.map(({ boxAdvanceEm }) => boxAdvanceEm), additionalSentenceEndingMarks);
|
|
2969
3054
|
return {
|
|
2970
3055
|
atoms,
|
|
2971
3056
|
runs,
|
|
@@ -3072,7 +3157,7 @@ function renderUnits(raw) {
|
|
|
3072
3157
|
const members = [first];
|
|
3073
3158
|
if (first.atom.combineRun) while (index + 1 < raw.length) {
|
|
3074
3159
|
const next = raw[index + 1];
|
|
3075
|
-
if (next?.kind !== "member" || next.atom.
|
|
3160
|
+
if (next?.kind !== "member" || next.atom.renderGroup !== first.atom.renderGroup) break;
|
|
3076
3161
|
members.push(next);
|
|
3077
3162
|
index += 1;
|
|
3078
3163
|
}
|
|
@@ -3408,7 +3493,7 @@ function createCompose(provider) {
|
|
|
3408
3493
|
return (manuscript, settings) => {
|
|
3409
3494
|
const measurements = MeasurementSession.create(provider, settings);
|
|
3410
3495
|
const sourceLines = displayedLines(manuscript.graphemes);
|
|
3411
|
-
const measured = sourceLines.map((line) => measureSourceLine(line, manuscript.annotations, measurements));
|
|
3496
|
+
const measured = sourceLines.map((line) => measureSourceLine(line, manuscript.annotations, measurements, settings.additionalSentenceEndingMarks ?? ""));
|
|
3412
3497
|
if (measured.some((line) => line === void 0)) return ManuscriptResult.fail({ reason: "run measurer returned invalid metrics or cluster mappings" });
|
|
3413
3498
|
const manuscriptLines = [];
|
|
3414
3499
|
for (const line of measured) {
|
package/dist/plugin.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as ManuscriptResult, i as ParsedManuscript, n as ValidationIssue, r as NamespacedId } from "./composed-manuscript-C0f3mxKs.mjs";
|
|
2
|
-
import { a as RunMeasurer, c as MeasurementRequest, f as ManuscriptComposer, m as Rejection, o as logicalRunMeasurer, p as ManuscriptParser, r as createNovelComposer, s as RunMeasurement, t as PresentationKind } from "./presentation-kind-
|
|
2
|
+
import { a as RunMeasurer, c as MeasurementRequest, f as ManuscriptComposer, m as Rejection, o as logicalRunMeasurer, p as ManuscriptParser, r as createNovelComposer, s as RunMeasurement, t as PresentationKind } from "./presentation-kind-BmW1Edu7.mjs";
|
|
3
3
|
import * as v from "valibot";
|
|
4
4
|
//#region src/composer/measurement-text-range.d.ts
|
|
5
5
|
declare const MeasurementTextRangeSchema: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
package/dist/plugin.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _ as ParsedManuscript, a as MeasuredCluster, g as FontPresetId, h as FontSizeQ, i as RunMeasurement, o as MeasurementTextRange, r as logicalRunMeasurer, t as createNovelComposer } from "./novel-composer-
|
|
1
|
+
import { f as ValidationIssue, g as NamespacedId, p as ManuscriptResult, x as readonlyObject } from "./question-or-exclamation-spacing-D7TSDUG8.mjs";
|
|
2
|
+
import { _ as ParsedManuscript, a as MeasuredCluster, g as FontPresetId, h as FontSizeQ, i as RunMeasurement, o as MeasurementTextRange, r as logicalRunMeasurer, t as createNovelComposer } from "./novel-composer-DNsKrJIP.mjs";
|
|
3
3
|
import * as v from "valibot";
|
|
4
4
|
const PresentationKind = { schema: v.picklist([
|
|
5
5
|
"mixed",
|
|
@@ -11,6 +11,10 @@ const PresentationKind = { schema: v.picklist([
|
|
|
11
11
|
//#region src/composer/measurement-request.ts
|
|
12
12
|
const context = {
|
|
13
13
|
text: v.string(),
|
|
14
|
+
style: v.optional(readonlyObject({
|
|
15
|
+
weight: v.picklist([400, 700]),
|
|
16
|
+
slant: v.picklist(["normal", "italic"])
|
|
17
|
+
})),
|
|
14
18
|
fontPreset: FontPresetId.schema,
|
|
15
19
|
fontSizeQ: FontSizeQ.schema,
|
|
16
20
|
scale: v.pipe(v.number(), v.finite(), v.minValue(Number.MIN_VALUE)),
|