@sushichan044/kg-core 0.11.2 → 0.12.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 +19 -0
- package/dist/index.d.mts +344 -317
- package/dist/index.mjs +156 -5
- package/dist/{novel-composer-tcseYHc8.mjs → novel-composer-DNsKrJIP.mjs} +85 -41
- package/dist/plugin.d.mts +1 -1
- package/dist/plugin.mjs +5 -1
- package/dist/{presentation-kind-DnJkvxHU.d.mts → presentation-kind-B9FtjZvc.d.mts} +1026 -982
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as ManuscriptRange, d as graphemeSegmenter, f as ValidationIssue, g as NamespacedId, m as ManuscriptDiagnostic, p as ManuscriptResult, u as assertNever, x as readonlyObject } from "./question-or-exclamation-spacing-D7TSDUG8.mjs";
|
|
2
|
-
import { _ as ParsedManuscript, c as NovelFlowSettings, d as ManuscriptPageSettings, f as PaperSize, g as FontPresetId, h as FontSizeQ, l as ManuscriptOffsets, m as PaperSizeId, n as novelComposer, p as ManuscriptAppearanceSettings, s as NovelCompositionSettings, u as ManuscriptGeometry } from "./novel-composer-
|
|
2
|
+
import { _ as ParsedManuscript, c as NovelFlowSettings, d as ManuscriptPageSettings, f as PaperSize, g as FontPresetId, h as FontSizeQ, l as ManuscriptOffsets, m as PaperSizeId, n as novelComposer, p as ManuscriptAppearanceSettings, s as NovelCompositionSettings, u as ManuscriptGeometry } from "./novel-composer-DNsKrJIP.mjs";
|
|
3
3
|
import { t as describeCause } from "./describe-cause-SABI_1ex.mjs";
|
|
4
4
|
import * as v from "valibot";
|
|
5
5
|
const Rejection = { schema: readonlyObject({ reason: v.string() }) };
|
|
@@ -598,16 +598,48 @@ function joinIssues(issues) {
|
|
|
598
598
|
}
|
|
599
599
|
//#endregion
|
|
600
600
|
//#region src/appearance/font-preset.ts
|
|
601
|
+
const FIXED_PITCH = {
|
|
602
|
+
features: {
|
|
603
|
+
palt: 0,
|
|
604
|
+
vpal: 0,
|
|
605
|
+
halt: 0,
|
|
606
|
+
vhal: 0,
|
|
607
|
+
vkrn: 0,
|
|
608
|
+
liga: 1
|
|
609
|
+
},
|
|
610
|
+
westernKerning: "normal",
|
|
611
|
+
synthesis: "weight style"
|
|
612
|
+
};
|
|
601
613
|
const FONT_PRESETS = {
|
|
602
614
|
mincho: {
|
|
603
615
|
id: "mincho",
|
|
604
|
-
label: "
|
|
605
|
-
|
|
616
|
+
label: "倫明朝",
|
|
617
|
+
fontName: "KGRinMincho100",
|
|
618
|
+
family: "\"KGRinMincho100\", \"Yu Mincho\", \"Hiragino Mincho ProN\", serif",
|
|
619
|
+
textTransforms: ["combine-kana-voicing-marks"],
|
|
620
|
+
measurement: "browser-shaped",
|
|
621
|
+
rendering: {
|
|
622
|
+
...FIXED_PITCH,
|
|
623
|
+
synthesis: "style"
|
|
624
|
+
}
|
|
606
625
|
},
|
|
607
626
|
gothic: {
|
|
608
627
|
id: "gothic",
|
|
609
628
|
label: "ゴシック",
|
|
610
|
-
|
|
629
|
+
fontName: "",
|
|
630
|
+
family: "\"Yu Gothic\", \"Hiragino Kaku Gothic ProN\", system-ui, sans-serif",
|
|
631
|
+
textTransforms: [],
|
|
632
|
+
measurement: "logical",
|
|
633
|
+
rendering: FIXED_PITCH
|
|
634
|
+
},
|
|
635
|
+
"genei-koburi": {
|
|
636
|
+
id: "genei-koburi",
|
|
637
|
+
label: "源暎こぶり明朝",
|
|
638
|
+
fontName: "KGGenEiKoburi61",
|
|
639
|
+
family: "\"KGGenEiKoburi61\", \"Yu Mincho\", \"Hiragino Mincho ProN\", serif",
|
|
640
|
+
textTransforms: [],
|
|
641
|
+
measurement: "browser-shaped",
|
|
642
|
+
rendering: FIXED_PITCH
|
|
611
643
|
}
|
|
612
644
|
};
|
|
613
645
|
const FontPreset = {
|
|
@@ -615,4 +647,123 @@ const FontPreset = {
|
|
|
615
647
|
all: Object.values(FONT_PRESETS)
|
|
616
648
|
};
|
|
617
649
|
//#endregion
|
|
618
|
-
|
|
650
|
+
//#region src/appearance/internal/font-text-transforms.ts
|
|
651
|
+
const transforms = { "combine-kana-voicing-marks": (text) => text.replace(/([\u3041-\u3096\u30A1-\u30FA\u31F0-\u31FF])([\u309B\u309C])/gu, (_, kana, mark) => kana + (mark === "゛" ? "゙" : "゚")) };
|
|
652
|
+
function applyFontTextTransforms(text, rules) {
|
|
653
|
+
return rules.reduce((value, rule) => transforms[rule](value), text);
|
|
654
|
+
}
|
|
655
|
+
//#endregion
|
|
656
|
+
//#region src/appearance/font-preparation.ts
|
|
657
|
+
function prepareTextForFont(text, fontPreset) {
|
|
658
|
+
return applyFontTextTransforms(text, FontPreset.of(fontPreset).textTransforms);
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Prepare display text after parsing; source and UTF-16 offsets remain unchanged.
|
|
662
|
+
*/
|
|
663
|
+
function prepareManuscriptForFont(parsed, fontPreset) {
|
|
664
|
+
if (FontPreset.of(fontPreset).textTransforms.length === 0) return {
|
|
665
|
+
parsed,
|
|
666
|
+
mapRange: (range) => range
|
|
667
|
+
};
|
|
668
|
+
const boundaries = /* @__PURE__ */ new Set([0, parsed.displayText.length]);
|
|
669
|
+
for (const annotation of parsed.annotations) {
|
|
670
|
+
boundaries.add(annotation.range.display.start);
|
|
671
|
+
boundaries.add(annotation.range.display.end);
|
|
672
|
+
if (annotation.kind === "ruby" && annotation.reading.kind !== "group") for (const member of parsed.graphemes.slice(annotation.range.graphemes.start, annotation.range.graphemes.end)) boundaries.add(member.range.display.start);
|
|
673
|
+
}
|
|
674
|
+
for (const [index, member] of parsed.graphemes.entries()) {
|
|
675
|
+
const previous = parsed.graphemes[index - 1];
|
|
676
|
+
if (previous !== void 0 && previous.range.source.end !== member.range.source.start) boundaries.add(member.range.display.start);
|
|
677
|
+
}
|
|
678
|
+
const ordered = [...boundaries].sort((a, b) => a - b);
|
|
679
|
+
const parts = [];
|
|
680
|
+
const graphemes = [];
|
|
681
|
+
let originalIndex = 0;
|
|
682
|
+
for (let i = 1; i < ordered.length; i += 1) {
|
|
683
|
+
const start = ordered[i - 1];
|
|
684
|
+
const end = ordered[i];
|
|
685
|
+
if (start === void 0 || end === void 0) continue;
|
|
686
|
+
const text = prepareTextForFont(parsed.displayText.slice(start, end), fontPreset);
|
|
687
|
+
parts.push(text);
|
|
688
|
+
for (const { segment, index } of graphemeSegmenter.segment(text)) {
|
|
689
|
+
const displayStart = start + index;
|
|
690
|
+
const displayEnd = displayStart + segment.length;
|
|
691
|
+
while ((parsed.graphemes[originalIndex]?.range.display.end ?? Infinity) <= displayStart) originalIndex += 1;
|
|
692
|
+
const first = parsed.graphemes[originalIndex];
|
|
693
|
+
let last = first;
|
|
694
|
+
while (last !== void 0 && last.range.display.end < displayEnd) {
|
|
695
|
+
originalIndex += 1;
|
|
696
|
+
last = parsed.graphemes[originalIndex];
|
|
697
|
+
}
|
|
698
|
+
if (first === void 0 || last === void 0) throw new Error("Font preparation lost a source member");
|
|
699
|
+
graphemes.push({
|
|
700
|
+
value: segment,
|
|
701
|
+
range: ManuscriptRange.of({
|
|
702
|
+
source: {
|
|
703
|
+
start: first.range.source.start,
|
|
704
|
+
end: last.range.source.end
|
|
705
|
+
},
|
|
706
|
+
display: {
|
|
707
|
+
start: displayStart,
|
|
708
|
+
end: displayEnd
|
|
709
|
+
},
|
|
710
|
+
graphemes: {
|
|
711
|
+
start: graphemes.length,
|
|
712
|
+
end: graphemes.length + 1
|
|
713
|
+
}
|
|
714
|
+
})
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
const boundaryIndex = (offset, end) => {
|
|
719
|
+
let low = 0;
|
|
720
|
+
let high = graphemes.length;
|
|
721
|
+
while (low < high) {
|
|
722
|
+
const mid = Math.floor((low + high) / 2);
|
|
723
|
+
const member = graphemes[mid];
|
|
724
|
+
if (member !== void 0 && (end ? member.range.display.start < offset : member.range.display.end <= offset)) low = mid + 1;
|
|
725
|
+
else high = mid;
|
|
726
|
+
}
|
|
727
|
+
return low;
|
|
728
|
+
};
|
|
729
|
+
const mapRange = (range) => {
|
|
730
|
+
const start = boundaryIndex(range.display.start, false);
|
|
731
|
+
return ManuscriptRange.of({
|
|
732
|
+
...range,
|
|
733
|
+
graphemes: {
|
|
734
|
+
start,
|
|
735
|
+
end: range.display.start === range.display.end ? start : boundaryIndex(range.display.end, true)
|
|
736
|
+
}
|
|
737
|
+
});
|
|
738
|
+
};
|
|
739
|
+
const annotations = parsed.annotations.map((annotation) => {
|
|
740
|
+
const range = mapRange(annotation.range);
|
|
741
|
+
if (annotation.kind !== "ruby") return {
|
|
742
|
+
...annotation,
|
|
743
|
+
range
|
|
744
|
+
};
|
|
745
|
+
const reading = annotation.reading.kind === "group" ? {
|
|
746
|
+
kind: "group",
|
|
747
|
+
text: prepareTextForFont(annotation.reading.text, fontPreset)
|
|
748
|
+
} : {
|
|
749
|
+
...annotation.reading,
|
|
750
|
+
segments: annotation.reading.segments.map((text) => prepareTextForFont(text, fontPreset))
|
|
751
|
+
};
|
|
752
|
+
return {
|
|
753
|
+
...annotation,
|
|
754
|
+
range,
|
|
755
|
+
reading
|
|
756
|
+
};
|
|
757
|
+
});
|
|
758
|
+
return {
|
|
759
|
+
parsed: v.parse(ParsedManuscript.contractFor(parsed.source), {
|
|
760
|
+
source: parsed.source,
|
|
761
|
+
displayText: parts.join(""),
|
|
762
|
+
graphemes,
|
|
763
|
+
annotations
|
|
764
|
+
}),
|
|
765
|
+
mapRange
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
//#endregion
|
|
769
|
+
export { ComposeError, FontPreset, FontPresetId, FontSizeQ, ManuscriptAppearanceSettings, ManuscriptDiagnostic, ManuscriptGeometry, ManuscriptOffsets, ManuscriptPageSettings, ManuscriptRange, ManuscriptResult, NovelCompositionSettings, NovelFlowSettings, PaperSize, PaperSizeId, ParseError, composeManuscript, kakuyomuParser, novelComposer, parseManuscript, pixivParser, plainTextParser, prepareManuscriptForFont, prepareTextForFont };
|
|
@@ -134,7 +134,11 @@ const A6_PAGE_FORMAT = {
|
|
|
134
134
|
};
|
|
135
135
|
//#endregion
|
|
136
136
|
//#region src/appearance/font-preset-id.ts
|
|
137
|
-
const FontPresetIdSchema = v.picklist([
|
|
137
|
+
const FontPresetIdSchema = v.picklist([
|
|
138
|
+
"mincho",
|
|
139
|
+
"gothic",
|
|
140
|
+
"genei-koburi"
|
|
141
|
+
]);
|
|
138
142
|
const FontPresetId = {
|
|
139
143
|
schema: FontPresetIdSchema,
|
|
140
144
|
is: (value) => v.is(FontPresetIdSchema, value)
|
|
@@ -1139,7 +1143,7 @@ const HYPHENS = /* @__PURE__ */ new Set("‐‑⁃–");
|
|
|
1139
1143
|
const DIVIDING_MARKS = new Set(SENTENCE_ENDING_MARKS);
|
|
1140
1144
|
const COMBINED_DIVIDING_MARKS = new Set(TATE_CHU_YOKO_MARKS);
|
|
1141
1145
|
const MIDDLE_DOTS = /* @__PURE__ */ new Set("・:;");
|
|
1142
|
-
const SMALL_KANA = /* @__PURE__ */ new Set("
|
|
1146
|
+
const SMALL_KANA = /* @__PURE__ */ new Set("ァィゥェォッャュョヮヵヶㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿぁぃぅぇぉっゃゅょゎゕゖ");
|
|
1143
1147
|
const ITERATION_MARKS = /* @__PURE__ */ new Set("ヽヾゝゞ々〻");
|
|
1144
1148
|
const INSEPARABLE = /* @__PURE__ */ new Set("—―…‥─〳〴〵");
|
|
1145
1149
|
const PREFIXED_ABBREVIATIONS = /* @__PURE__ */ new Set("¥$£##");
|
|
@@ -1162,6 +1166,7 @@ const WESTERN = /^[\p{Script=Latin}\p{Script=Greek}\p{Script=Cyrillic}]$/u;
|
|
|
1162
1166
|
* the same as a tate-chu-yoko run's 3.2.5.
|
|
1163
1167
|
*/
|
|
1164
1168
|
function classify({ value, presentation }) {
|
|
1169
|
+
value = value.replace(/[\u3099\u309A]/gu, "");
|
|
1165
1170
|
switch (presentation) {
|
|
1166
1171
|
case "tate-chu-yoko": return COMBINED_DIVIDING_MARKS.has(value) ? "cl-04" : "cl-30";
|
|
1167
1172
|
case "upright": return "cl-19";
|
|
@@ -1923,10 +1928,11 @@ const RunMeasurement = {
|
|
|
1923
1928
|
//#region src/composer/internal/measurement-session.ts
|
|
1924
1929
|
const MeasurementSession = { create: (provider, settings) => {
|
|
1925
1930
|
const cache = /* @__PURE__ */ new Map();
|
|
1926
|
-
const get = (text, kind, presentation = "mixed") => {
|
|
1931
|
+
const get = (text, kind, presentation = "mixed", style) => {
|
|
1927
1932
|
const request = kind === "base" ? {
|
|
1928
1933
|
text,
|
|
1929
1934
|
kind,
|
|
1935
|
+
...style === void 0 ? {} : { style },
|
|
1930
1936
|
presentation,
|
|
1931
1937
|
fontPreset: settings.appearance.fontPreset,
|
|
1932
1938
|
fontSizeQ: settings.appearance.fontSizeQ,
|
|
@@ -1935,6 +1941,7 @@ const MeasurementSession = { create: (provider, settings) => {
|
|
|
1935
1941
|
} : {
|
|
1936
1942
|
text,
|
|
1937
1943
|
kind,
|
|
1944
|
+
...style === void 0 ? {} : { style },
|
|
1938
1945
|
presentation: "mixed",
|
|
1939
1946
|
fontPreset: settings.appearance.fontPreset,
|
|
1940
1947
|
fontSizeQ: settings.appearance.fontSizeQ,
|
|
@@ -1949,8 +1956,8 @@ const MeasurementSession = { create: (provider, settings) => {
|
|
|
1949
1956
|
};
|
|
1950
1957
|
return {
|
|
1951
1958
|
get,
|
|
1952
|
-
pieces: (text, kind, presentation) => {
|
|
1953
|
-
const full = get(text, kind, presentation);
|
|
1959
|
+
pieces: (text, kind, presentation, style) => {
|
|
1960
|
+
const full = get(text, kind, presentation, style);
|
|
1954
1961
|
if (full === void 0) return void 0;
|
|
1955
1962
|
if (full.kind === "clustered") return full.clusters.map((cluster) => ({
|
|
1956
1963
|
textRange: cluster.textRange,
|
|
@@ -1980,7 +1987,7 @@ const MeasurementSession = { create: (provider, settings) => {
|
|
|
1980
1987
|
const pieces = [];
|
|
1981
1988
|
let offsetEm = 0;
|
|
1982
1989
|
for (const { segment, index } of segments) {
|
|
1983
|
-
const measured = get(segment, kind, presentation);
|
|
1990
|
+
const measured = get(segment, kind, presentation, style);
|
|
1984
1991
|
if (measured === void 0) return void 0;
|
|
1985
1992
|
const cluster = measured.kind === "clustered" ? measured.clusters[0] : void 0;
|
|
1986
1993
|
pieces.push({
|
|
@@ -2929,44 +2936,81 @@ function displayedLines(graphemes) {
|
|
|
2929
2936
|
if (lines.length > 1 && endedWithLineBreak) lines.pop();
|
|
2930
2937
|
return lines;
|
|
2931
2938
|
}
|
|
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
|
+
*/
|
|
2932
2967
|
function measureSourceLine(sourceLine, annotations, measurements, additionalSentenceEndingMarks) {
|
|
2933
2968
|
const runs = CompositionRun.recognize(sourceLine, additionalSentenceEndingMarks);
|
|
2934
2969
|
const rubyAssociations = RubyAssociation.collect(annotations, sourceLine);
|
|
2970
|
+
const styles = annotations.filter(({ kind }) => kind === "bold" || kind === "italic");
|
|
2935
2971
|
const atoms = [];
|
|
2972
|
+
let renderGroup = 0;
|
|
2936
2973
|
for (const [runIndex, run] of runs.entries()) {
|
|
2937
|
-
const
|
|
2938
|
-
const
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
const
|
|
2945
|
-
const
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
const
|
|
2949
|
-
const
|
|
2950
|
-
const
|
|
2951
|
-
const
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
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;
|
|
2968
3013
|
}
|
|
2969
|
-
memberStart += memberCount;
|
|
2970
3014
|
}
|
|
2971
3015
|
}
|
|
2972
3016
|
const candidateReadings = [];
|
|
@@ -2975,8 +3019,8 @@ function measureSourceLine(sourceLine, annotations, measurements, additionalSent
|
|
|
2975
3019
|
const physicalRange = (first, last) => {
|
|
2976
3020
|
const left = atoms[first];
|
|
2977
3021
|
const right = atoms[last];
|
|
2978
|
-
while (first > 0 && left?.combineRun === true && atoms[first - 1]?.
|
|
2979
|
-
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;
|
|
2980
3024
|
return {
|
|
2981
3025
|
start: first,
|
|
2982
3026
|
end: last + 1
|
|
@@ -3113,7 +3157,7 @@ function renderUnits(raw) {
|
|
|
3113
3157
|
const members = [first];
|
|
3114
3158
|
if (first.atom.combineRun) while (index + 1 < raw.length) {
|
|
3115
3159
|
const next = raw[index + 1];
|
|
3116
|
-
if (next?.kind !== "member" || next.atom.
|
|
3160
|
+
if (next?.kind !== "member" || next.atom.renderGroup !== first.atom.renderGroup) break;
|
|
3117
3161
|
members.push(next);
|
|
3118
3162
|
index += 1;
|
|
3119
3163
|
}
|
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-B9FtjZvc.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
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-
|
|
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)),
|