postext 0.3.35 → 0.3.37
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/__tests__/columnBalancing.test.js +28 -0
- package/dist/__tests__/columnBalancing.test.js.map +1 -1
- package/dist/__tests__/continuation.test.js +21 -0
- package/dist/__tests__/continuation.test.js.map +1 -1
- package/dist/__tests__/exports.test.js +13 -0
- package/dist/__tests__/exports.test.js.map +1 -1
- package/dist/__tests__/headingStyles.test.d.ts +2 -0
- package/dist/__tests__/headingStyles.test.d.ts.map +1 -0
- package/dist/__tests__/headingStyles.test.js +134 -0
- package/dist/__tests__/headingStyles.test.js.map +1 -0
- package/dist/__tests__/parse/containers.test.js +1 -1
- package/dist/__tests__/parse/containers.test.js.map +1 -1
- package/dist/__tests__/pipeline/segmentBalancing.test.d.ts +2 -0
- package/dist/__tests__/pipeline/segmentBalancing.test.d.ts.map +1 -0
- package/dist/__tests__/pipeline/segmentBalancing.test.js +70 -0
- package/dist/__tests__/pipeline/segmentBalancing.test.js.map +1 -0
- package/dist/__tests__/toc.test.d.ts +2 -0
- package/dist/__tests__/toc.test.d.ts.map +1 -0
- package/dist/__tests__/toc.test.js +199 -0
- package/dist/__tests__/toc.test.js.map +1 -0
- package/dist/canvas-backend/blockRender.d.ts.map +1 -1
- package/dist/canvas-backend/blockRender.js +21 -11
- package/dist/canvas-backend/blockRender.js.map +1 -1
- package/dist/canvas-backend/index.d.ts.map +1 -1
- package/dist/canvas-backend/index.js +9 -0
- package/dist/canvas-backend/index.js.map +1 -1
- package/dist/defaults/headerFooter.d.ts.map +1 -1
- package/dist/defaults/headerFooter.js +17 -0
- package/dist/defaults/headerFooter.js.map +1 -1
- package/dist/defaults/headingStyles.d.ts +10 -0
- package/dist/defaults/headingStyles.d.ts.map +1 -0
- package/dist/defaults/headingStyles.js +85 -0
- package/dist/defaults/headingStyles.js.map +1 -0
- package/dist/defaults/headings.d.ts +6 -1
- package/dist/defaults/headings.d.ts.map +1 -1
- package/dist/defaults/headings.js +32 -0
- package/dist/defaults/headings.js.map +1 -1
- package/dist/defaults/index.d.ts +2 -0
- package/dist/defaults/index.d.ts.map +1 -1
- package/dist/defaults/index.js +18 -0
- package/dist/defaults/index.js.map +1 -1
- package/dist/defaults/paragraphStyles.d.ts.map +1 -1
- package/dist/defaults/paragraphStyles.js +4 -1
- package/dist/defaults/paragraphStyles.js.map +1 -1
- package/dist/defaults/toc.d.ts +26 -0
- package/dist/defaults/toc.d.ts.map +1 -0
- package/dist/defaults/toc.js +167 -0
- package/dist/defaults/toc.js.map +1 -0
- package/dist/design/layout.d.ts +15 -3
- package/dist/design/layout.d.ts.map +1 -1
- package/dist/design/layout.js +66 -1
- package/dist/design/layout.js.map +1 -1
- package/dist/html-backend.d.ts.map +1 -1
- package/dist/html-backend.js +16 -5
- package/dist/html-backend.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/numbering.d.ts +5 -1
- package/dist/numbering.d.ts.map +1 -1
- package/dist/numbering.js +7 -1
- package/dist/numbering.js.map +1 -1
- package/dist/parse/blockParser.d.ts.map +1 -1
- package/dist/parse/blockParser.js +1 -1
- package/dist/parse/blockParser.js.map +1 -1
- package/dist/parse/index.d.ts +1 -1
- package/dist/parse/index.d.ts.map +1 -1
- package/dist/parse/index.js.map +1 -1
- package/dist/parse/types.d.ts +24 -1
- package/dist/parse/types.d.ts.map +1 -1
- package/dist/pipeline/build.d.ts.map +1 -1
- package/dist/pipeline/build.js +459 -142
- package/dist/pipeline/build.js.map +1 -1
- package/dist/pipeline/buildBlockKind.d.ts +4 -0
- package/dist/pipeline/buildBlockKind.d.ts.map +1 -1
- package/dist/pipeline/buildBlockKind.js +2 -2
- package/dist/pipeline/buildBlockKind.js.map +1 -1
- package/dist/pipeline/columnBalancing.d.ts +27 -5
- package/dist/pipeline/columnBalancing.d.ts.map +1 -1
- package/dist/pipeline/columnBalancing.js +51 -10
- package/dist/pipeline/columnBalancing.js.map +1 -1
- package/dist/pipeline/config.d.ts.map +1 -1
- package/dist/pipeline/config.js +3 -1
- package/dist/pipeline/config.js.map +1 -1
- package/dist/pipeline/continuation.d.ts +10 -1
- package/dist/pipeline/continuation.d.ts.map +1 -1
- package/dist/pipeline/continuation.js +16 -1
- package/dist/pipeline/continuation.js.map +1 -1
- package/dist/pipeline/headerFooter.d.ts +5 -2
- package/dist/pipeline/headerFooter.d.ts.map +1 -1
- package/dist/pipeline/headerFooter.js +90 -15
- package/dist/pipeline/headerFooter.js.map +1 -1
- package/dist/pipeline/headingStyles.d.ts +58 -0
- package/dist/pipeline/headingStyles.d.ts.map +1 -0
- package/dist/pipeline/headingStyles.js +157 -0
- package/dist/pipeline/headingStyles.js.map +1 -0
- package/dist/pipeline/index.d.ts +2 -1
- package/dist/pipeline/index.d.ts.map +1 -1
- package/dist/pipeline/index.js +2 -1
- package/dist/pipeline/index.js.map +1 -1
- package/dist/pipeline/measureContentBlock.d.ts.map +1 -1
- package/dist/pipeline/measureContentBlock.js +4 -0
- package/dist/pipeline/measureContentBlock.js.map +1 -1
- package/dist/pipeline/outline.d.ts +37 -0
- package/dist/pipeline/outline.d.ts.map +1 -0
- package/dist/pipeline/outline.js +146 -0
- package/dist/pipeline/outline.js.map +1 -0
- package/dist/pipeline/pageRoles.d.ts +2 -1
- package/dist/pipeline/pageRoles.d.ts.map +1 -1
- package/dist/pipeline/pageRoles.js +5 -4
- package/dist/pipeline/pageRoles.js.map +1 -1
- package/dist/pipeline/placeholders.d.ts.map +1 -1
- package/dist/pipeline/placeholders.js +6 -0
- package/dist/pipeline/placeholders.js.map +1 -1
- package/dist/pipeline/resourceNumbering.d.ts +3 -1
- package/dist/pipeline/resourceNumbering.d.ts.map +1 -1
- package/dist/pipeline/resourceNumbering.js +4 -2
- package/dist/pipeline/resourceNumbering.js.map +1 -1
- package/dist/pipeline/styles.d.ts +5 -2
- package/dist/pipeline/styles.d.ts.map +1 -1
- package/dist/pipeline/styles.js +7 -3
- package/dist/pipeline/styles.js.map +1 -1
- package/dist/pipeline/toc.d.ts +22 -0
- package/dist/pipeline/toc.d.ts.map +1 -0
- package/dist/pipeline/toc.js +249 -0
- package/dist/pipeline/toc.js.map +1 -0
- package/dist/types.d.ts +273 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/vdt.d.ts +37 -2
- package/dist/vdt.d.ts.map +1 -1
- package/dist/vdt.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `:::toc` — the table of contents. The directive expands, before layout,
|
|
3
|
+
* into ordinary content blocks (one per listed heading, one per part
|
|
4
|
+
* divider) that flow through the column machinery like paragraphs: they
|
|
5
|
+
* break across columns and pages, snap to the grid and map clicks back to
|
|
6
|
+
* the directive line. Measurement is special: an entry is its title (with
|
|
7
|
+
* a right-aligned number in a column of its own), a leader and the page
|
|
8
|
+
* label on its last line, and an optional subtitle line (the chapter
|
|
9
|
+
* authors) under it; a part row is an empty block of a fixed height whose
|
|
10
|
+
* design `buildHeadersAndFooters` lays out from `toc.parts.design`.
|
|
11
|
+
*/
|
|
12
|
+
import { dimensionToPx } from '../units';
|
|
13
|
+
import { buildFontString, measureRichBlock, measureTextWidth } from '../measure';
|
|
14
|
+
import { stampSourceRanges } from './buildHelpers';
|
|
15
|
+
/** The content blocks with every `:::toc` directive replaced by the blocks
|
|
16
|
+
* of the contents it prints. Without an outline (no directive) the input
|
|
17
|
+
* is returned as is. */
|
|
18
|
+
export function expandTocDirectives(blocks, outline, resolved) {
|
|
19
|
+
if (!outline || !blocks.some((b) => b.type === 'directive' && b.directiveName === 'toc')) {
|
|
20
|
+
return blocks;
|
|
21
|
+
}
|
|
22
|
+
const out = [];
|
|
23
|
+
for (const b of blocks) {
|
|
24
|
+
if (b.type !== 'directive' || b.directiveName !== 'toc') {
|
|
25
|
+
out.push(b);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
out.push(...tocBlocksFor(b, outline, resolved));
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
function tocBlocksFor(directive, outline, resolved) {
|
|
33
|
+
const toc = resolved.toc;
|
|
34
|
+
const listedLevels = new Set(toc.levels.map((l) => l.level));
|
|
35
|
+
const out = [];
|
|
36
|
+
const base = { sourceStart: directive.sourceStart, sourceEnd: directive.sourceEnd };
|
|
37
|
+
for (const entry of outline) {
|
|
38
|
+
if (!entry.listed)
|
|
39
|
+
continue;
|
|
40
|
+
if (entry.kind === 'part') {
|
|
41
|
+
if (!toc.parts.enabled)
|
|
42
|
+
continue;
|
|
43
|
+
const info = {
|
|
44
|
+
kind: 'part', level: 0, number: entry.number, numbered: entry.numbered, title: entry.title,
|
|
45
|
+
...(entry.pageLabel !== undefined ? { pageLabel: entry.pageLabel } : {}),
|
|
46
|
+
...(entry.palette ? { palette: entry.palette } : {}),
|
|
47
|
+
};
|
|
48
|
+
out.push({ ...base, type: 'paragraph', text: '', spans: [], sourceMap: [], toc: info });
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (!listedLevels.has(entry.level))
|
|
52
|
+
continue;
|
|
53
|
+
const text = entry.title;
|
|
54
|
+
const spans = entry.spans && entry.spans.length > 0
|
|
55
|
+
? entry.spans.map((s) => ({ text: s.text, bold: s.bold, italic: s.italic }))
|
|
56
|
+
: [{ text, bold: false, italic: false }];
|
|
57
|
+
const subtitle = toc.subtitle.enabled ? entry.attrs?.[toc.subtitle.attr]?.trim() : undefined;
|
|
58
|
+
const info = {
|
|
59
|
+
kind: 'entry', level: entry.level, number: entry.number, numbered: entry.numbered,
|
|
60
|
+
...(entry.pageLabel !== undefined ? { pageLabel: entry.pageLabel } : {}),
|
|
61
|
+
...(subtitle ? { subtitle } : {}),
|
|
62
|
+
};
|
|
63
|
+
// Every character maps to the directive line, so a click on the
|
|
64
|
+
// contents lands on `:::toc`.
|
|
65
|
+
out.push({ ...base, type: 'paragraph', text, spans, sourceMap: new Array(text.length).fill(directive.sourceStart), toc: info });
|
|
66
|
+
}
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
function lineHeightPxOf(lineHeight, fontSizePx, dpi) {
|
|
70
|
+
if (lineHeight.unit === 'em' || lineHeight.unit === 'rem')
|
|
71
|
+
return fontSizePx * lineHeight.value;
|
|
72
|
+
return dimensionToPx(lineHeight, dpi, fontSizePx);
|
|
73
|
+
}
|
|
74
|
+
function segmentsOf(line) {
|
|
75
|
+
if (line.segments && line.segments.length > 0)
|
|
76
|
+
return line.segments;
|
|
77
|
+
const segs = [{ kind: 'text', text: line.text, width: line.bbox.width }];
|
|
78
|
+
line.segments = segs;
|
|
79
|
+
return segs;
|
|
80
|
+
}
|
|
81
|
+
/** Measure one block of an expanded `:::toc` (see the module header). */
|
|
82
|
+
export function measureTocBlock(rawBlock, columnWidth, ctx) {
|
|
83
|
+
const info = rawBlock.toc;
|
|
84
|
+
const { resolved, bodyOffset } = ctx;
|
|
85
|
+
const toc = resolved.toc;
|
|
86
|
+
const dpi = resolved.page.dpi;
|
|
87
|
+
const bodyFontSizePx = dimensionToPx(resolved.bodyText.fontSize, dpi);
|
|
88
|
+
const body = resolved.bodyText;
|
|
89
|
+
if (info.kind === 'part') {
|
|
90
|
+
const rowH = dimensionToPx(toc.parts.height, dpi, bodyFontSizePx);
|
|
91
|
+
const style = {
|
|
92
|
+
fontString: buildFontString(body.fontFamily, bodyFontSizePx, body.fontWeight.toString()),
|
|
93
|
+
fontSizePx: bodyFontSizePx,
|
|
94
|
+
lineHeightPx: rowH,
|
|
95
|
+
color: body.color.hex,
|
|
96
|
+
textAlign: 'left',
|
|
97
|
+
hyphenate: false,
|
|
98
|
+
marginTopPx: dimensionToPx(toc.parts.marginTop, dpi, bodyFontSizePx),
|
|
99
|
+
marginBottomPx: dimensionToPx(toc.parts.marginBottom, dpi, bodyFontSizePx),
|
|
100
|
+
firstLineIndentPx: 0,
|
|
101
|
+
hangingIndent: false,
|
|
102
|
+
};
|
|
103
|
+
const line = {
|
|
104
|
+
text: '', bbox: { x: 0, y: 0, width: columnWidth, height: rowH }, baseline: rowH * 0.7,
|
|
105
|
+
hyphenated: false, segments: [], isLastLine: true,
|
|
106
|
+
};
|
|
107
|
+
const measured = { lines: [line], totalHeight: rowH };
|
|
108
|
+
const { prefixLen, absoluteSourceMap } = stampSourceRanges(measured, rawBlock, rawBlock, bodyOffset);
|
|
109
|
+
return {
|
|
110
|
+
kind: { style, vdtType: 'paragraph', contentBlock: rawBlock, bulletXOffsetInColumn: 0, strikethroughText: false },
|
|
111
|
+
contentBlock: rawBlock,
|
|
112
|
+
measured,
|
|
113
|
+
prefixLen,
|
|
114
|
+
absoluteSourceMap,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
// --- Entry -----------------------------------------------------------
|
|
118
|
+
const level = toc.levels.find((l) => l.level === info.level) ?? toc.levels[0];
|
|
119
|
+
const entry = info.numbered ? level : { ...level, ...toc.unnumbered };
|
|
120
|
+
const fontSizePx = dimensionToPx(entry.fontSize, dpi);
|
|
121
|
+
const lineHeightPx = lineHeightPxOf(entry.lineHeight, fontSizePx, dpi);
|
|
122
|
+
const weight = entry.fontWeight.toString();
|
|
123
|
+
const boldWeight = Math.max(entry.fontWeight, body.boldFontWeight).toString();
|
|
124
|
+
const upright = entry.italic ? 'italic' : 'normal';
|
|
125
|
+
const flipped = entry.italic ? 'normal' : 'italic';
|
|
126
|
+
const fontString = buildFontString(entry.fontFamily, fontSizePx, weight, upright);
|
|
127
|
+
const boldFontString = buildFontString(entry.fontFamily, fontSizePx, boldWeight, upright);
|
|
128
|
+
const italicFontString = buildFontString(entry.fontFamily, fontSizePx, weight, flipped);
|
|
129
|
+
const boldItalicFontString = buildFontString(entry.fontFamily, fontSizePx, boldWeight, flipped);
|
|
130
|
+
const color = entry.color.hex;
|
|
131
|
+
const style = {
|
|
132
|
+
fontString, boldFontString, italicFontString, boldItalicFontString,
|
|
133
|
+
fontSizePx, lineHeightPx, color, boldColor: color, italicColor: color,
|
|
134
|
+
textAlign: 'left', hyphenate: false,
|
|
135
|
+
marginTopPx: dimensionToPx(entry.marginTop, dpi, fontSizePx),
|
|
136
|
+
marginBottomPx: dimensionToPx(entry.marginBottom, dpi, fontSizePx),
|
|
137
|
+
firstLineIndentPx: 0, hangingIndent: false,
|
|
138
|
+
};
|
|
139
|
+
// Number column (numbered entries): the title starts after it.
|
|
140
|
+
const indentPx = dimensionToPx(entry.indent, dpi, fontSizePx);
|
|
141
|
+
const hasNumber = info.numbered && info.number.length > 0;
|
|
142
|
+
const numberWidthPx = hasNumber ? dimensionToPx(entry.numberWidth, dpi, fontSizePx) : 0;
|
|
143
|
+
const numberGapPx = hasNumber ? dimensionToPx(entry.numberGap, dpi, fontSizePx) : 0;
|
|
144
|
+
const textX = indentPx + numberWidthPx + numberGapPx;
|
|
145
|
+
const availableW = Math.max(1, columnWidth - textX);
|
|
146
|
+
let listBullet;
|
|
147
|
+
let bulletXOffsetInColumn = 0;
|
|
148
|
+
if (hasNumber) {
|
|
149
|
+
const numberFontSizePx = dimensionToPx(entry.numberFontSize, dpi);
|
|
150
|
+
const numberFont = buildFontString(entry.numberFontFamily, numberFontSizePx, entry.numberFontWeight.toString());
|
|
151
|
+
const numberW = measureTextWidth(info.number, numberFont);
|
|
152
|
+
listBullet = {
|
|
153
|
+
indentPx, bulletText: info.number, bulletFontString: numberFont, bulletColor: entry.numberColor.hex,
|
|
154
|
+
bulletWidthPx: numberWidthPx, gapPx: numberGapPx, hangingIndent: true, itemSpacingPx: 0,
|
|
155
|
+
textFontSizePx: fontSizePx, verticalOffsetPx: 0,
|
|
156
|
+
};
|
|
157
|
+
bulletXOffsetInColumn = indentPx + Math.max(0, numberWidthPx - numberW);
|
|
158
|
+
}
|
|
159
|
+
// Page label + leader on the last title line.
|
|
160
|
+
const label = info.pageLabel ?? '';
|
|
161
|
+
const pn = toc.pageNumber;
|
|
162
|
+
const labelFontSizePx = dimensionToPx(pn.fontSize, dpi);
|
|
163
|
+
const labelFont = buildFontString(pn.fontFamily, labelFontSizePx, pn.fontWeight.toString(), pn.italic ? 'italic' : 'normal');
|
|
164
|
+
const labelColor = pn.color.hex;
|
|
165
|
+
const reservePx = label.length > 0 ? dimensionToPx(pn.width, dpi, fontSizePx) : 0;
|
|
166
|
+
const gapPx = label.length > 0 ? dimensionToPx(toc.leader.gap, dpi, fontSizePx) : 0;
|
|
167
|
+
const labelW = label.length > 0 ? measureTextWidth(label, labelFont) : 0;
|
|
168
|
+
const measureTitle = (maxW) => measureRichBlock(rawBlock.spans, fontString, boldFontString, italicFontString, boldItalicFontString, maxW, lineHeightPx, { textAlign: 'left', hyphenate: false });
|
|
169
|
+
let measured = measureTitle(availableW);
|
|
170
|
+
if (measured.lines.length === 0)
|
|
171
|
+
return null;
|
|
172
|
+
const lastOf = (lines) => lines[lines.length - 1];
|
|
173
|
+
if (label.length > 0 && lastOf(measured.lines).bbox.width + gapPx + reservePx > availableW + 0.01) {
|
|
174
|
+
// The label does not fit beside the last line: narrow the measure so
|
|
175
|
+
// the title leaves it room (every line, so wrapped lines stay level).
|
|
176
|
+
const narrowed = measureTitle(Math.max(1, availableW - gapPx - reservePx));
|
|
177
|
+
if (narrowed.lines.length > 0)
|
|
178
|
+
measured = narrowed;
|
|
179
|
+
}
|
|
180
|
+
const lines = measured.lines;
|
|
181
|
+
if (label.length > 0) {
|
|
182
|
+
const last = lastOf(lines);
|
|
183
|
+
const segs = segmentsOf(last);
|
|
184
|
+
const contentW = segs.reduce((s, seg) => s + seg.width, 0);
|
|
185
|
+
const leaderStart = contentW + gapPx;
|
|
186
|
+
const leaderEnd = availableW - reservePx;
|
|
187
|
+
let x = contentW;
|
|
188
|
+
const pushSpace = (w) => { if (w > 0) {
|
|
189
|
+
segs.push({ kind: 'space', text: ' ', width: w });
|
|
190
|
+
x += w;
|
|
191
|
+
} };
|
|
192
|
+
if (toc.leader.enabled && toc.leader.char.length > 0 && leaderEnd - leaderStart > 0) {
|
|
193
|
+
const unit = measureTextWidth(toc.leader.char, labelFont);
|
|
194
|
+
const n = unit > 0 ? Math.floor((leaderEnd - leaderStart) / unit) : 0;
|
|
195
|
+
if (n > 0) {
|
|
196
|
+
const dots = toc.leader.char.repeat(n);
|
|
197
|
+
const dotsW = measureTextWidth(dots, labelFont);
|
|
198
|
+
pushSpace(leaderEnd - dotsW - x);
|
|
199
|
+
segs.push({ kind: 'text', text: dots, width: dotsW, fontString: labelFont, color: labelColor });
|
|
200
|
+
x += dotsW;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
pushSpace(availableW - labelW - x);
|
|
204
|
+
segs.push({ kind: 'text', text: label, width: labelW, fontString: labelFont, color: labelColor });
|
|
205
|
+
last.text = `${last.text} ${label}`;
|
|
206
|
+
last.bbox.width = availableW;
|
|
207
|
+
}
|
|
208
|
+
// Subtitle line(s) under the title (the chapter authors).
|
|
209
|
+
if (info.subtitle) {
|
|
210
|
+
const sub = toc.subtitle;
|
|
211
|
+
const subSizePx = dimensionToPx(sub.fontSize, dpi);
|
|
212
|
+
const subFont = buildFontString(sub.fontFamily, subSizePx, sub.fontWeight.toString(), sub.italic ? 'italic' : 'normal');
|
|
213
|
+
const subIndentPx = dimensionToPx(sub.indent, dpi, fontSizePx);
|
|
214
|
+
const subMeasured = measureRichBlock([{ text: info.subtitle, bold: false, italic: false }], subFont, subFont, subFont, subFont, Math.max(1, availableW - subIndentPx), lineHeightPx, { textAlign: 'left', hyphenate: false });
|
|
215
|
+
for (const line of subMeasured.lines) {
|
|
216
|
+
for (const seg of segmentsOf(line)) {
|
|
217
|
+
if (seg.kind === 'space')
|
|
218
|
+
continue;
|
|
219
|
+
seg.fontString = subFont;
|
|
220
|
+
seg.color = sub.color.hex;
|
|
221
|
+
}
|
|
222
|
+
line.bbox.x += subIndentPx;
|
|
223
|
+
line.isLastLine = true;
|
|
224
|
+
lines.push(line);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
for (const line of lines)
|
|
228
|
+
line.bbox.x += textX;
|
|
229
|
+
// Uniform line pitch: the placement loop re-seats every line at the
|
|
230
|
+
// block's line height (`resetLinePositions`).
|
|
231
|
+
const total = lines.length * lineHeightPx;
|
|
232
|
+
const finalMeasured = { lines, totalHeight: total };
|
|
233
|
+
const { prefixLen, absoluteSourceMap } = stampSourceRanges(finalMeasured, rawBlock, rawBlock, bodyOffset);
|
|
234
|
+
return {
|
|
235
|
+
kind: {
|
|
236
|
+
style,
|
|
237
|
+
vdtType: hasNumber ? 'listItem' : 'paragraph',
|
|
238
|
+
contentBlock: rawBlock,
|
|
239
|
+
...(listBullet ? { listBullet, listDepth: 1, listKind: 'ordered' } : {}),
|
|
240
|
+
bulletXOffsetInColumn,
|
|
241
|
+
strikethroughText: false,
|
|
242
|
+
},
|
|
243
|
+
contentBlock: rawBlock,
|
|
244
|
+
measured: finalMeasured,
|
|
245
|
+
prefixLen,
|
|
246
|
+
absoluteSourceMap,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
//# sourceMappingURL=toc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toc.js","sourceRoot":"","sources":["../../src/pipeline/toc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAKjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;yBAEyB;AACzB,MAAM,UAAU,mBAAmB,CACjC,MAA+B,EAC/B,OAA4C,EAC5C,QAAwB;IAExB,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,CAAC,aAAa,KAAK,KAAK,CAAC,EAAE,CAAC;Q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AE,KAAK;SACzB;QACD,YAAY,EAAE,QAAQ;QACtB,QAAQ,EAAE,aAAa;QACvB,SAAS;QACT,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -202,6 +202,47 @@ export interface PostextContent {
|
|
|
202
202
|
* book chapter laid out on its own continues the numbering of the
|
|
203
203
|
* chapters before it. Omit for a self-contained document. */
|
|
204
204
|
continuation?: LayoutContinuation;
|
|
205
|
+
/** The book's outline — every heading and part the `:::toc` directive
|
|
206
|
+
* lists, with the page label each one landed on. A chapter laid out on
|
|
207
|
+
* its own gets the whole book's outline from its host; when absent, the
|
|
208
|
+
* engine derives it from the document itself, laying it out again until
|
|
209
|
+
* the page labels the contents print no longer change. */
|
|
210
|
+
outline?: OutlineEntry[];
|
|
211
|
+
}
|
|
212
|
+
/** One line of a book's outline: a heading of a listed level, or a part
|
|
213
|
+
* divider. Produced from the parsed markdown (page labels unknown) or from
|
|
214
|
+
* a laid-out document (page labels known); consumed by `:::toc`. */
|
|
215
|
+
export interface OutlineEntry {
|
|
216
|
+
kind: 'heading' | 'part';
|
|
217
|
+
/** Heading level (1–6); `0` for a part. */
|
|
218
|
+
level: number;
|
|
219
|
+
/** Title as plain text (forced title breaks flattened to spaces). */
|
|
220
|
+
title: string;
|
|
221
|
+
/** Inline runs of the title (bold / italic), so a title set in italics
|
|
222
|
+
* keeps its emphasis in the contents. Absent for a part. */
|
|
223
|
+
spans?: {
|
|
224
|
+
text: string;
|
|
225
|
+
bold: boolean;
|
|
226
|
+
italic: boolean;
|
|
227
|
+
}[];
|
|
228
|
+
/** Printed number: the level's `numberingTemplate` output, else the
|
|
229
|
+
* chapter ordinal for a level-1 heading; the part's `number` as written.
|
|
230
|
+
* Empty for an unnumbered heading. */
|
|
231
|
+
number: string;
|
|
232
|
+
/** False for a heading whose style has `numbered: false`. */
|
|
233
|
+
numbered: boolean;
|
|
234
|
+
/** Id of the heading style (`{style="…"}`), when the heading has one. */
|
|
235
|
+
styleId?: string;
|
|
236
|
+
/** Heading attributes (`{author="…"}`), for the contents' subtitle line. */
|
|
237
|
+
attrs?: Record<string, string>;
|
|
238
|
+
/** Palette overrides of a part (`palette="band=#…"`), so its row in the
|
|
239
|
+
* contents takes the part's colours. */
|
|
240
|
+
palette?: Record<string, string>;
|
|
241
|
+
/** Label of the page the entry starts on; absent until laid out. */
|
|
242
|
+
pageLabel?: string;
|
|
243
|
+
/** Whether the entry appears in the contents (a heading style's `toc`
|
|
244
|
+
* or a `{toc="false"}` attribute may exclude it). */
|
|
245
|
+
listed: boolean;
|
|
205
246
|
}
|
|
206
247
|
/** Heading counters (1-indexed by level) in effect at a point in a document. */
|
|
207
248
|
export interface HeadingCounters {
|
|
@@ -419,7 +460,7 @@ export interface ResolvedLayoutConfig {
|
|
|
419
460
|
lineWidth: Dimension;
|
|
420
461
|
};
|
|
421
462
|
}
|
|
422
|
-
export type TextAlign = 'left' | 'justify' | 'center';
|
|
463
|
+
export type TextAlign = 'left' | 'justify' | 'center' | 'right';
|
|
423
464
|
export type HyphenationLocale = 'en-us' | 'es' | 'fr' | 'de' | 'it' | 'pt' | 'ca' | 'nl';
|
|
424
465
|
export interface HyphenationConfig {
|
|
425
466
|
enabled?: boolean;
|
|
@@ -749,8 +790,11 @@ export interface ParagraphStyleConfig {
|
|
|
749
790
|
lineHeight?: Dimension;
|
|
750
791
|
/** Defaults to the body text colour. */
|
|
751
792
|
color?: ColorValue;
|
|
752
|
-
/** Defaults to the body alignment
|
|
753
|
-
|
|
793
|
+
/** Defaults to the body alignment. `'center'` and `'right'` set every
|
|
794
|
+
* line ragged from the other side (a dedication, a signature block). */
|
|
795
|
+
textAlign?: TextAlign;
|
|
796
|
+
/** Colour of bold runs. Defaults to `bodyText.boldColor`. */
|
|
797
|
+
boldColor?: ColorValue;
|
|
754
798
|
/** Hyphenate when justified. Defaults to the body hyphenation setting. */
|
|
755
799
|
hyphenation?: boolean;
|
|
756
800
|
/** Defaults to the body first-line indent. Ignored when
|
|
@@ -775,7 +819,8 @@ export interface ResolvedParagraphStyleConfig {
|
|
|
775
819
|
fontSize: Dimension;
|
|
776
820
|
lineHeight: Dimension;
|
|
777
821
|
color: ColorValue;
|
|
778
|
-
textAlign:
|
|
822
|
+
textAlign: TextAlign;
|
|
823
|
+
boldColor?: ColorValue;
|
|
779
824
|
hyphenation: boolean;
|
|
780
825
|
firstLineIndent: Dimension;
|
|
781
826
|
hangingIndent: Dimension;
|
|
@@ -1632,6 +1677,9 @@ export interface DesignTextElement {
|
|
|
1632
1677
|
/** When true, break long words at syllable boundaries while wrapping.
|
|
1633
1678
|
* Uses the document's active hyphenation locale. */
|
|
1634
1679
|
hyphenate?: boolean;
|
|
1680
|
+
/** Letter-case transform applied to the resolved text (a part title set
|
|
1681
|
+
* in capitals in the contents). Default `'none'`. */
|
|
1682
|
+
textTransform?: 'none' | 'uppercase';
|
|
1635
1683
|
box?: ElementBoxStyle;
|
|
1636
1684
|
}
|
|
1637
1685
|
export interface DesignRuleElement {
|
|
@@ -1654,7 +1702,22 @@ export interface DesignBoxElement {
|
|
|
1654
1702
|
placement: ElementPlacement;
|
|
1655
1703
|
style: ElementBoxStyle;
|
|
1656
1704
|
}
|
|
1657
|
-
|
|
1705
|
+
/** An image drawn from a resource (a bitmap or SVG `Resource`, e.g. a
|
|
1706
|
+
* publisher logo on a title page). Sized by `placement.size`: with one of
|
|
1707
|
+
* `width` / `height` left `'auto'` the other follows the image's aspect
|
|
1708
|
+
* ratio; with both set the image is fitted inside the box, centred. A
|
|
1709
|
+
* missing resource draws nothing. */
|
|
1710
|
+
export interface DesignImageElement {
|
|
1711
|
+
kind: 'image';
|
|
1712
|
+
id: string;
|
|
1713
|
+
parity?: PageParity;
|
|
1714
|
+
/** Page roles this element renders on. Default `'all'`. */
|
|
1715
|
+
pages?: PageRoleFilter;
|
|
1716
|
+
placement: ElementPlacement;
|
|
1717
|
+
/** `Resource.id` of a bitmap or SVG resource. */
|
|
1718
|
+
resourceId: string;
|
|
1719
|
+
}
|
|
1720
|
+
export type DesignElement = DesignTextElement | DesignRuleElement | DesignBoxElement | DesignImageElement;
|
|
1658
1721
|
export interface DesignSlot {
|
|
1659
1722
|
/** Array order = paint order: first = back, last = front. */
|
|
1660
1723
|
elements: DesignElement[];
|
|
@@ -1675,7 +1738,10 @@ export interface ResolvedDesignRuleElement extends Omit<DesignRuleElement, 'pari
|
|
|
1675
1738
|
export interface ResolvedDesignBoxElement extends Omit<DesignBoxElement, 'parity'> {
|
|
1676
1739
|
parity: PageParity;
|
|
1677
1740
|
}
|
|
1678
|
-
export
|
|
1741
|
+
export interface ResolvedDesignImageElement extends Omit<DesignImageElement, 'parity'> {
|
|
1742
|
+
parity: PageParity;
|
|
1743
|
+
}
|
|
1744
|
+
export type ResolvedDesignElement = ResolvedDesignTextElement | ResolvedDesignRuleElement | ResolvedDesignBoxElement | ResolvedDesignImageElement;
|
|
1679
1745
|
export interface ResolvedDesignSlot {
|
|
1680
1746
|
elements: ResolvedDesignElement[];
|
|
1681
1747
|
}
|
|
@@ -1800,6 +1866,201 @@ export interface ResolvedPartsConfig {
|
|
|
1800
1866
|
versoDesign: ResolvedDesignSlot;
|
|
1801
1867
|
bodyStyle: ResolvedPartsBodyStyleConfig;
|
|
1802
1868
|
}
|
|
1869
|
+
/** Typography of the body blocks in a section opened by a styled heading.
|
|
1870
|
+
* Same shape as a part's body style. */
|
|
1871
|
+
export type SectionBodyStyleConfig = PartsBodyStyleConfig;
|
|
1872
|
+
export type ResolvedSectionBodyStyleConfig = ResolvedPartsBodyStyleConfig;
|
|
1873
|
+
export interface HeadingStyleConfig extends Omit<HeadingLevelConfig, 'level' | 'numberingTemplate'> {
|
|
1874
|
+
/** Identifier referenced from `{style="…"}` on a heading line. */
|
|
1875
|
+
id: string;
|
|
1876
|
+
/** Human-readable name (editor UI only). Defaults to {@link id}. */
|
|
1877
|
+
name?: string;
|
|
1878
|
+
/** Whether the heading counts: advances the level's counter and the
|
|
1879
|
+
* chapter ordinal (`{chapterNumber}`), and is numbered in the contents.
|
|
1880
|
+
* `false` for a preface, an authors list, an index. Default `true`. */
|
|
1881
|
+
numbered?: boolean;
|
|
1882
|
+
/** Whether the heading is listed by `:::toc`. Default `true`; a heading
|
|
1883
|
+
* may override it with `{toc="false"}` / `{toc="true"}`. */
|
|
1884
|
+
toc?: boolean;
|
|
1885
|
+
/** Running heads of the section's pages, replacing the document's
|
|
1886
|
+
* `header` / `footer` there (element `pages` / `parity` filters still
|
|
1887
|
+
* apply). Unset = the document's own. */
|
|
1888
|
+
header?: HeaderFooterSlot;
|
|
1889
|
+
footer?: HeaderFooterSlot;
|
|
1890
|
+
/** Body area of the section's pages. Each side inherits the page margin
|
|
1891
|
+
* when unset. Takes effect on the pages the section opens, so pair it
|
|
1892
|
+
* with `breakBefore`. */
|
|
1893
|
+
margins?: PageMargins;
|
|
1894
|
+
/** Column layout of the section's pages (a single wide column for a
|
|
1895
|
+
* preface set in a two-column book). Inherits `layout` when unset. */
|
|
1896
|
+
layout?: LayoutConfig;
|
|
1897
|
+
/** Typography of the body blocks in the section. */
|
|
1898
|
+
bodyStyle?: SectionBodyStyleConfig;
|
|
1899
|
+
/** Palette overrides (palette id → hex) applied to the design slots of
|
|
1900
|
+
* the section's pages, like a part's `palette` attribute. */
|
|
1901
|
+
palette?: Record<string, string>;
|
|
1902
|
+
}
|
|
1903
|
+
/** The level fields a heading style may override, resolved. */
|
|
1904
|
+
export type ResolvedHeadingStyleOverrides = Partial<Omit<ResolvedHeadingLevelConfig, 'level' | 'numberingTemplate'>>;
|
|
1905
|
+
export interface ResolvedHeadingStyleConfig {
|
|
1906
|
+
id: string;
|
|
1907
|
+
name: string;
|
|
1908
|
+
numbered: boolean;
|
|
1909
|
+
toc: boolean;
|
|
1910
|
+
/** Level fields the style sets; merged over the heading's level config. */
|
|
1911
|
+
overrides: ResolvedHeadingStyleOverrides;
|
|
1912
|
+
header?: ResolvedDesignSlot;
|
|
1913
|
+
footer?: ResolvedDesignSlot;
|
|
1914
|
+
margins?: Required<PageMargins>;
|
|
1915
|
+
layout?: ResolvedLayoutConfig;
|
|
1916
|
+
bodyStyle?: ResolvedSectionBodyStyleConfig;
|
|
1917
|
+
palette: Record<string, string>;
|
|
1918
|
+
}
|
|
1919
|
+
/** Typography of one kind of contents entry. Every field inherits the body
|
|
1920
|
+
* text (or the `toc`-wide value) when unset. */
|
|
1921
|
+
export interface TocEntryStyleConfig {
|
|
1922
|
+
fontFamily?: string;
|
|
1923
|
+
fontSize?: Dimension;
|
|
1924
|
+
/** Leading of the entry's lines (title and subtitle alike). Defaults to
|
|
1925
|
+
* the body line height so the contents sit on the baseline grid. */
|
|
1926
|
+
lineHeight?: Dimension;
|
|
1927
|
+
fontWeight?: number;
|
|
1928
|
+
italic?: boolean;
|
|
1929
|
+
color?: ColorValue;
|
|
1930
|
+
/** Left indent of the whole entry. Default `0`. */
|
|
1931
|
+
indent?: Dimension;
|
|
1932
|
+
/** Width of the number column: the title starts after it plus
|
|
1933
|
+
* `numberGap`; numbers are right-aligned in it. Default `2em`. */
|
|
1934
|
+
numberWidth?: Dimension;
|
|
1935
|
+
/** Gap between the number column and the title. Default `0.5em`. */
|
|
1936
|
+
numberGap?: Dimension;
|
|
1937
|
+
numberFontFamily?: string;
|
|
1938
|
+
numberFontSize?: Dimension;
|
|
1939
|
+
numberFontWeight?: number;
|
|
1940
|
+
numberColor?: ColorValue;
|
|
1941
|
+
/** Space above / below the entry (subtitle included). Default `0`. */
|
|
1942
|
+
marginTop?: Dimension;
|
|
1943
|
+
marginBottom?: Dimension;
|
|
1944
|
+
}
|
|
1945
|
+
export interface TocLevelConfig extends TocEntryStyleConfig {
|
|
1946
|
+
/** Heading level (1–6). */
|
|
1947
|
+
level: number;
|
|
1948
|
+
}
|
|
1949
|
+
export interface TocConfig {
|
|
1950
|
+
/** Heading levels listed, each with its entry typography. Default: level
|
|
1951
|
+
* 1 only. */
|
|
1952
|
+
levels?: TocLevelConfig[];
|
|
1953
|
+
/** Entry typography of headings whose style has `numbered: false`
|
|
1954
|
+
* (a preface). They print no number and start flush at the level's
|
|
1955
|
+
* `indent`. Inherits the level's style. */
|
|
1956
|
+
unnumbered?: TocEntryStyleConfig;
|
|
1957
|
+
/** The page number at the right edge of an entry. */
|
|
1958
|
+
pageNumber?: {
|
|
1959
|
+
fontFamily?: string;
|
|
1960
|
+
fontSize?: Dimension;
|
|
1961
|
+
fontWeight?: number;
|
|
1962
|
+
italic?: boolean;
|
|
1963
|
+
color?: ColorValue;
|
|
1964
|
+
/** Width reserved for the number at the right edge. Default `2em`. */
|
|
1965
|
+
width?: Dimension;
|
|
1966
|
+
};
|
|
1967
|
+
/** Leader between the title and the page number. */
|
|
1968
|
+
leader?: {
|
|
1969
|
+
/** Default `true`. */
|
|
1970
|
+
enabled?: boolean;
|
|
1971
|
+
/** Repeated across the gap, right-aligned so dots line up. Default `'.'`;
|
|
1972
|
+
* `'. '` spaces them out. */
|
|
1973
|
+
char?: string;
|
|
1974
|
+
/** Minimum gap between the title and the leader / page number. Default
|
|
1975
|
+
* `0.5em`. */
|
|
1976
|
+
gap?: Dimension;
|
|
1977
|
+
};
|
|
1978
|
+
/** A second line under the entry taken from a heading attribute — the
|
|
1979
|
+
* chapter authors (`{author="…"}`). Absent when unset. */
|
|
1980
|
+
subtitle?: {
|
|
1981
|
+
/** Attribute name, e.g. `'author'`. Default `'author'`. */
|
|
1982
|
+
attr?: string;
|
|
1983
|
+
/** Default `false`. */
|
|
1984
|
+
enabled?: boolean;
|
|
1985
|
+
fontFamily?: string;
|
|
1986
|
+
fontSize?: Dimension;
|
|
1987
|
+
fontWeight?: number;
|
|
1988
|
+
italic?: boolean;
|
|
1989
|
+
color?: ColorValue;
|
|
1990
|
+
/** Extra indent beyond the title's. Default `0`. */
|
|
1991
|
+
indent?: Dimension;
|
|
1992
|
+
};
|
|
1993
|
+
/** Part dividers get a row of their own. */
|
|
1994
|
+
parts?: {
|
|
1995
|
+
/** Default `true`. */
|
|
1996
|
+
enabled?: boolean;
|
|
1997
|
+
/** Row design; its container is the row (column width × `height`).
|
|
1998
|
+
* Placeholders: `{number}`, `{numberRoman}`…, `{titleText}` and
|
|
1999
|
+
* `{pageNumber}` (the part page's label). Palette-linked colours take
|
|
2000
|
+
* the part's own palette. When empty, `{number} {titleText}` and the
|
|
2001
|
+
* page number are set in the level-1 entry typography. */
|
|
2002
|
+
design?: DesignSlot;
|
|
2003
|
+
/** Row height. Default: two body lines. */
|
|
2004
|
+
height?: Dimension;
|
|
2005
|
+
marginTop?: Dimension;
|
|
2006
|
+
marginBottom?: Dimension;
|
|
2007
|
+
};
|
|
2008
|
+
}
|
|
2009
|
+
export interface ResolvedTocEntryStyleConfig {
|
|
2010
|
+
fontFamily: string;
|
|
2011
|
+
fontSize: Dimension;
|
|
2012
|
+
lineHeight: Dimension;
|
|
2013
|
+
fontWeight: number;
|
|
2014
|
+
italic: boolean;
|
|
2015
|
+
color: ColorValue;
|
|
2016
|
+
indent: Dimension;
|
|
2017
|
+
numberWidth: Dimension;
|
|
2018
|
+
numberGap: Dimension;
|
|
2019
|
+
numberFontFamily: string;
|
|
2020
|
+
numberFontSize: Dimension;
|
|
2021
|
+
numberFontWeight: number;
|
|
2022
|
+
numberColor: ColorValue;
|
|
2023
|
+
marginTop: Dimension;
|
|
2024
|
+
marginBottom: Dimension;
|
|
2025
|
+
}
|
|
2026
|
+
export interface ResolvedTocLevelConfig extends ResolvedTocEntryStyleConfig {
|
|
2027
|
+
level: number;
|
|
2028
|
+
}
|
|
2029
|
+
export interface ResolvedTocConfig {
|
|
2030
|
+
levels: ResolvedTocLevelConfig[];
|
|
2031
|
+
/** Overrides applied on top of the level's entry style for unnumbered headings. */
|
|
2032
|
+
unnumbered: Partial<ResolvedTocEntryStyleConfig>;
|
|
2033
|
+
pageNumber: {
|
|
2034
|
+
fontFamily: string;
|
|
2035
|
+
fontSize: Dimension;
|
|
2036
|
+
fontWeight: number;
|
|
2037
|
+
italic: boolean;
|
|
2038
|
+
color: ColorValue;
|
|
2039
|
+
width: Dimension;
|
|
2040
|
+
};
|
|
2041
|
+
leader: {
|
|
2042
|
+
enabled: boolean;
|
|
2043
|
+
char: string;
|
|
2044
|
+
gap: Dimension;
|
|
2045
|
+
};
|
|
2046
|
+
subtitle: {
|
|
2047
|
+
enabled: boolean;
|
|
2048
|
+
attr: string;
|
|
2049
|
+
fontFamily: string;
|
|
2050
|
+
fontSize: Dimension;
|
|
2051
|
+
fontWeight: number;
|
|
2052
|
+
italic: boolean;
|
|
2053
|
+
color: ColorValue;
|
|
2054
|
+
indent: Dimension;
|
|
2055
|
+
};
|
|
2056
|
+
parts: {
|
|
2057
|
+
enabled: boolean;
|
|
2058
|
+
design: ResolvedDesignSlot;
|
|
2059
|
+
height: Dimension;
|
|
2060
|
+
marginTop: Dimension;
|
|
2061
|
+
marginBottom: Dimension;
|
|
2062
|
+
};
|
|
2063
|
+
}
|
|
1803
2064
|
export interface PostextConfig {
|
|
1804
2065
|
page?: PageConfig;
|
|
1805
2066
|
layout?: LayoutConfig;
|
|
@@ -1819,6 +2080,12 @@ export interface PostextConfig {
|
|
|
1819
2080
|
/** Part dividers (`:::part` containers): page breaks, body area,
|
|
1820
2081
|
* opener design and body typography. */
|
|
1821
2082
|
parts?: PartsConfig;
|
|
2083
|
+
/** Named heading styles applied with `# Title {style="…"}`: a front
|
|
2084
|
+
* matter chapter, an unnumbered appendix, a preface with its own running
|
|
2085
|
+
* heads and page geometry. */
|
|
2086
|
+
headingStyles?: HeadingStyleConfig[];
|
|
2087
|
+
/** The table of contents a `:::toc` directive prints. */
|
|
2088
|
+
toc?: TocConfig;
|
|
1822
2089
|
unorderedLists?: UnorderedListsConfig;
|
|
1823
2090
|
orderedLists?: OrderedListsConfig;
|
|
1824
2091
|
math?: MathConfig;
|