postext-epub 0.49.6 → 0.49.8
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/package/pack.d.ts.map +1 -1
- package/dist/package/pack.js +2 -1
- package/dist/package/pack.js.map +1 -1
- package/dist/reflowable/css/apparatus.d.ts +17 -0
- package/dist/reflowable/css/apparatus.d.ts.map +1 -0
- package/dist/reflowable/css/apparatus.js +127 -0
- package/dist/reflowable/css/apparatus.js.map +1 -0
- package/dist/reflowable/css/boxes.d.ts +20 -0
- package/dist/reflowable/css/boxes.d.ts.map +1 -0
- package/dist/reflowable/css/boxes.js +134 -0
- package/dist/reflowable/css/boxes.js.map +1 -0
- package/dist/reflowable/css/figures.d.ts +16 -0
- package/dist/reflowable/css/figures.d.ts.map +1 -0
- package/dist/reflowable/css/figures.js +174 -0
- package/dist/reflowable/css/figures.js.map +1 -0
- package/dist/reflowable/css/helpers.d.ts +32 -0
- package/dist/reflowable/css/helpers.d.ts.map +1 -0
- package/dist/reflowable/css/helpers.js +77 -0
- package/dist/reflowable/css/helpers.js.map +1 -0
- package/dist/reflowable/css/text.d.ts +19 -0
- package/dist/reflowable/css/text.d.ts.map +1 -0
- package/dist/reflowable/css/text.js +151 -0
- package/dist/reflowable/css/text.js.map +1 -0
- package/dist/reflowable/css/types.d.ts +46 -0
- package/dist/reflowable/css/types.d.ts.map +1 -0
- package/dist/reflowable/css/types.js +4 -0
- package/dist/reflowable/css/types.js.map +1 -0
- package/dist/reflowable/css/verse.d.ts +18 -0
- package/dist/reflowable/css/verse.d.ts.map +1 -0
- package/dist/reflowable/css/verse.js +126 -0
- package/dist/reflowable/css/verse.js.map +1 -0
- package/dist/reflowable/css.d.ts +4 -52
- package/dist/reflowable/css.d.ts.map +1 -1
- package/dist/reflowable/css.js +24 -736
- package/dist/reflowable/css.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
// The book stylesheet's rules for figures, picture labels, comic pages,
|
|
2
|
+
// tables and captions (#1276: split out of css.ts).
|
|
3
|
+
import { rule, ALIGN, TRACKED_LIGATURES } from './helpers.js';
|
|
4
|
+
import { round, idOf } from '../inline.js';
|
|
5
|
+
export function createFigureRules(deps) {
|
|
6
|
+
const { config, options, dpi, bodyPx, fam, em, color, px, out } = deps;
|
|
7
|
+
// --- figures, tables, captions ------------------------------------------
|
|
8
|
+
const cap = config.captionStyle;
|
|
9
|
+
const capPx = px(cap.fontSize);
|
|
10
|
+
out.push(rule('figure', ['margin: 1em 0', 'text-align: center', 'page-break-inside: avoid', 'break-inside: avoid']));
|
|
11
|
+
out.push(rule('figure img', ['max-width: 100%', 'height: auto']));
|
|
12
|
+
// The labels drawn over a picture (#955): a box as wide as the image,
|
|
13
|
+
// the SVG laid over all of it.
|
|
14
|
+
if (options.labelLayers) {
|
|
15
|
+
out.push(rule('.pt-labelled', ['display: inline-block', 'position: relative', 'max-width: 100%', 'line-height: 0']));
|
|
16
|
+
out.push(rule('.pt-label-layer', ['position: absolute', 'left: 0', 'top: 0', 'width: 100%', 'height: 100%', 'pointer-events: none']));
|
|
17
|
+
}
|
|
18
|
+
out.push(rule('figure video', ['width: 100%', 'height: auto', 'background-color: #000']));
|
|
19
|
+
// Comic pages (#565): each panel's picture as wide as the text at most,
|
|
20
|
+
// its lettering under it as plain lines.
|
|
21
|
+
out.push(rule('.pt-comic', ['margin: 1em 0']));
|
|
22
|
+
out.push(rule('.pt-comic-panel', ['margin: 1em 0 0.5em']));
|
|
23
|
+
out.push(rule('.pt-comic-panel svg', ['display: block', 'max-width: 100%', 'height: auto', 'margin: 0 auto']));
|
|
24
|
+
out.push(rule('.pt-comic p', ['text-indent: 0', 'margin: 0.25em 0']));
|
|
25
|
+
out.push(rule('a.pt-video-link', ['display: block']));
|
|
26
|
+
out.push(rule('figcaption, caption', [
|
|
27
|
+
fam(cap.fontFamily),
|
|
28
|
+
`font-size: ${round(capPx / bodyPx)}em`,
|
|
29
|
+
color(cap.color),
|
|
30
|
+
`text-align: ${ALIGN[cap.align] ?? 'start'}`,
|
|
31
|
+
cap.descriptionItalic && 'font-style: italic',
|
|
32
|
+
cap.backgroundEnabled && color(cap.background, 'background-color'),
|
|
33
|
+
cap.backgroundEnabled && `padding: ${round(px(cap.padding, capPx) / capPx)}em`,
|
|
34
|
+
`margin: ${round(px(cap.gap, capPx) / capPx)}em 0`,
|
|
35
|
+
'hyphens: manual',
|
|
36
|
+
]));
|
|
37
|
+
out.push(rule('caption.pt-caption-below', ['caption-side: bottom']));
|
|
38
|
+
out.push(rule('.pt-label', [
|
|
39
|
+
color(cap.labelColor),
|
|
40
|
+
cap.labelBold ? 'font-weight: bold' : undefined,
|
|
41
|
+
`font-style: ${cap.labelItalic ? 'italic' : 'normal'}`,
|
|
42
|
+
]));
|
|
43
|
+
const note = cap.note;
|
|
44
|
+
out.push(rule('.pt-note', [
|
|
45
|
+
`font-size: ${em(note.fontSize)}`,
|
|
46
|
+
color(note.color),
|
|
47
|
+
`font-style: ${note.italic ? 'italic' : 'normal'}`,
|
|
48
|
+
`text-align: ${ALIGN[note.align] ?? 'start'}`,
|
|
49
|
+
'text-indent: 0',
|
|
50
|
+
]));
|
|
51
|
+
out.push(rule('figcaption .pt-note', ['display: block', `margin-block-start: ${em(note.gap, px(cap.fontSize))}`]));
|
|
52
|
+
out.push(rule('.pt-missing', ['border: 1px dashed currentColor', 'padding: 1em', 'font-style: italic']));
|
|
53
|
+
const ts = config.tableStyle;
|
|
54
|
+
/** A rule `widthPx` (at the page dpi) wide, in CSS px. */
|
|
55
|
+
const line = (widthPx, c) => `${round(Math.max(0.5, widthPx * (96 / dpi)))}px solid ${c.hex}`;
|
|
56
|
+
/** What a table style decides, by element: on `table` for the document's
|
|
57
|
+
* style; on `table.pt-table-<id>` for a named one (#625), which then
|
|
58
|
+
* also undoes what the document's style (`reset`) sets and it does not. */
|
|
59
|
+
const tableStyleDecls = (st, reset) => {
|
|
60
|
+
const cellPx = px(st.bodyFontSize);
|
|
61
|
+
const booktabs = st.borders && st.rules === 'booktabs';
|
|
62
|
+
const border = st.borders && st.rules !== 'none' && !booktabs && px(st.borderWidth) > 0
|
|
63
|
+
? line(px(st.borderWidth), st.borderColor)
|
|
64
|
+
: undefined;
|
|
65
|
+
const tableBorder = border !== undefined && (st.rules === 'outer' || st.rules === 'grid');
|
|
66
|
+
// Booktabs: a heavy rule above and under the table, a light one under
|
|
67
|
+
// the header and, under a head spanning columns above the last header
|
|
68
|
+
// row, a span rule, trimmed at both ends by a background line (a CSS
|
|
69
|
+
// border cannot be).
|
|
70
|
+
const width = (d) => {
|
|
71
|
+
const v = px(d, cellPx);
|
|
72
|
+
return booktabs && v > 0 ? Math.max(0.25, v) : 0;
|
|
73
|
+
};
|
|
74
|
+
const heavy = width(st.heavyRuleWidth);
|
|
75
|
+
const light = width(st.lightRuleWidth);
|
|
76
|
+
const span = st.spanRules !== 'none' ? width(st.spanRuleWidth) : 0;
|
|
77
|
+
const wasBooktabs = reset?.borders === true && reset.rules === 'booktabs';
|
|
78
|
+
const extra = [];
|
|
79
|
+
if (light > 0)
|
|
80
|
+
extra.push(['thead', [`border-bottom: ${line(light, st.borderColor)}`]]);
|
|
81
|
+
else if (wasBooktabs)
|
|
82
|
+
extra.push(['thead', ['border-bottom: none']]);
|
|
83
|
+
const spanSel = 'thead > tr:not(:last-child) > th[colspan]';
|
|
84
|
+
if (span > 0 && st.spanRules === 'trimmed') {
|
|
85
|
+
extra.push([spanSel, [
|
|
86
|
+
`background-image: linear-gradient(${st.borderColor.hex}, ${st.borderColor.hex})`,
|
|
87
|
+
'background-repeat: no-repeat',
|
|
88
|
+
'background-position: center bottom',
|
|
89
|
+
`background-size: calc(100% - ${round(2 * (px(st.spanRuleTrim, cellPx) / cellPx))}em) ${round(Math.max(0.5, span * (96 / dpi)))}px`,
|
|
90
|
+
]]);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
if (span > 0)
|
|
94
|
+
extra.push([spanSel, [`border-bottom: ${line(span, st.borderColor)}`]]);
|
|
95
|
+
if (wasBooktabs && reset.spanRules === 'trimmed')
|
|
96
|
+
extra.push([spanSel, ['background-image: none']]);
|
|
97
|
+
}
|
|
98
|
+
if (st.groupRules && light > 0) {
|
|
99
|
+
extra.push(['tbody > tr.pt-group:not(:first-child) > *', [`border-top: ${line(light, st.borderColor)}`]]);
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
table: [
|
|
103
|
+
reset && fam(st.bodyFontFamily),
|
|
104
|
+
reset && `font-size: ${round(cellPx / bodyPx)}em`,
|
|
105
|
+
reset && color(st.bodyColor),
|
|
106
|
+
tableBorder ? `border: ${border}` : reset && 'border: none',
|
|
107
|
+
heavy > 0 && `border-top: ${line(heavy, st.borderColor)}`,
|
|
108
|
+
heavy > 0 && `border-bottom: ${line(heavy, st.borderColor)}`,
|
|
109
|
+
],
|
|
110
|
+
cells: [
|
|
111
|
+
reset && `padding: ${round(px(st.cellPadding, cellPx) / cellPx)}em`,
|
|
112
|
+
border && st.rules === 'grid' ? `border: ${border}` : undefined,
|
|
113
|
+
border && st.rules === 'horizontal' ? `border-block: ${border}` : undefined,
|
|
114
|
+
reset && !(border && (st.rules === 'grid' || st.rules === 'horizontal')) && 'border: none',
|
|
115
|
+
],
|
|
116
|
+
td: [st.bodyBackgroundEnabled ? color(st.bodyBackground, 'background-color') : reset && 'background-color: transparent'],
|
|
117
|
+
alt: st.bodyAlternateBackgroundEnabled ? [color(st.bodyAlternateBackground, 'background-color')] : undefined,
|
|
118
|
+
th: [
|
|
119
|
+
fam(st.headerFontFamily),
|
|
120
|
+
`font-size: ${round(px(st.headerFontSize) / cellPx)}em`,
|
|
121
|
+
color(st.headerColor),
|
|
122
|
+
`font-weight: ${st.headerBold ? 'bold' : 'normal'}`,
|
|
123
|
+
st.headerItalic ? 'font-style: italic' : reset && 'font-style: normal',
|
|
124
|
+
st.headerTextTransform === 'uppercase' ? 'text-transform: uppercase' : reset && 'text-transform: none',
|
|
125
|
+
st.headerLetterSpacing.value !== 0 ? `letter-spacing: ${round(px(st.headerLetterSpacing, cellPx) / cellPx)}em` : reset && 'letter-spacing: normal',
|
|
126
|
+
st.headerLetterSpacing.value !== 0 && TRACKED_LIGATURES,
|
|
127
|
+
st.headerBackgroundEnabled ? color(st.headerBackground, 'background-color') : reset && 'background-color: transparent',
|
|
128
|
+
],
|
|
129
|
+
extra,
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
const bodyCellPx = px(ts.bodyFontSize);
|
|
133
|
+
const base = tableStyleDecls(ts, undefined);
|
|
134
|
+
out.push(rule('.pt-table', ['margin: 1em 0', 'overflow-x: auto']));
|
|
135
|
+
out.push(rule('table', [
|
|
136
|
+
'border-collapse: collapse',
|
|
137
|
+
'margin: 0 auto',
|
|
138
|
+
'max-width: 100%',
|
|
139
|
+
fam(ts.bodyFontFamily),
|
|
140
|
+
`font-size: ${round(bodyCellPx / bodyPx)}em`,
|
|
141
|
+
color(ts.bodyColor),
|
|
142
|
+
'text-indent: 0',
|
|
143
|
+
'hyphens: manual',
|
|
144
|
+
...base.table,
|
|
145
|
+
]));
|
|
146
|
+
out.push(rule('th, td', [
|
|
147
|
+
`padding: ${round(px(ts.cellPadding, bodyCellPx) / bodyCellPx)}em`,
|
|
148
|
+
'vertical-align: top',
|
|
149
|
+
'text-align: start',
|
|
150
|
+
...base.cells,
|
|
151
|
+
]));
|
|
152
|
+
out.push(rule('td', base.td));
|
|
153
|
+
if (base.alt)
|
|
154
|
+
out.push(rule('td.pt-alt', base.alt));
|
|
155
|
+
out.push(rule('th', base.th));
|
|
156
|
+
for (const [sel, decls] of base.extra)
|
|
157
|
+
out.push(rule(sel, decls));
|
|
158
|
+
for (const st of config.tableStyles ?? []) {
|
|
159
|
+
const table = `table.${idOf('pt-table-', st.id)}`;
|
|
160
|
+
const sub = (sel) => sel.split(', ').map((x) => `${table} ${x}`).join(', ');
|
|
161
|
+
const d = tableStyleDecls(st, ts);
|
|
162
|
+
out.push(rule(table, d.table));
|
|
163
|
+
out.push(rule(sub('th, td'), d.cells));
|
|
164
|
+
out.push(rule(sub('td'), d.td));
|
|
165
|
+
if (d.alt)
|
|
166
|
+
out.push(rule(sub('td.pt-alt'), d.alt));
|
|
167
|
+
out.push(rule(sub('th'), d.th));
|
|
168
|
+
for (const [sel, decls] of d.extra)
|
|
169
|
+
out.push(rule(sub(sel), decls));
|
|
170
|
+
}
|
|
171
|
+
out.push(rule('td img, th img', ['max-width: 100%', 'height: auto', 'display: block', 'margin: 0 auto']));
|
|
172
|
+
return {};
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=figures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figures.js","sourceRoot":"","sources":["../../../src/reflowable/css/figures.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,oDAAoD;AACpD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAiB3C,MAAM,UAAU,iBAAiB,CAAC,IAAqB;IACrD,MAAM,EACJ,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EACtD,GAAG,IAAI,CAAC;IACT,2EAA2E;IAC3E,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC;IAChC,MAAM,KAAK,GAAG,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC/B,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,eAAe,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC;IACrH,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAClE,sEAAs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,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QACvC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAChC,IAAI,CAAC,CAAC,GAAG;YAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACnD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAChC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK;YAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IACtE,CAAC;IACD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC1G,OAAO,EACN,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type ResolvedConfig } from 'postext';
|
|
2
|
+
import type { CssRule } from './types.js';
|
|
3
|
+
/** The declarations of the Japanese text of a book (#428): kinsoku and,
|
|
4
|
+
* with burasagari (`cjk.hangingPunctuation`, on by default in Japan),
|
|
5
|
+
* 、。,. hanging past the line end; and, in any book that asks for it,
|
|
6
|
+
* lines broken only between phrases (`cjk.wordBreak: 'keep-all'`, #463).
|
|
7
|
+
* None for other books. */
|
|
8
|
+
export declare function japaneseDecls(cjk: ResolvedConfig['cjk']): string[];
|
|
9
|
+
/** The emphasis-mark rule of a class `dotsClasses` gives: a shape and fill
|
|
10
|
+
* (`pt-dots-filled-sesame`), or a side (`pt-dots-over`: over horizontal
|
|
11
|
+
* text and right of vertical text; `pt-dots-under`: under and left). */
|
|
12
|
+
export declare function dotsRule(cls: string): CssRule | '';
|
|
13
|
+
/** A family as a CSS value: the family quoted, then a generic fallback. A
|
|
14
|
+
* feature family (#1237, `Lora@onum`) is its base family's. */
|
|
15
|
+
export declare function familyStack(family: string): string;
|
|
16
|
+
/** The family names the stylesheet asks for (to warn about missing
|
|
17
|
+
* faces). */
|
|
18
|
+
export declare function familyName(family: string): string;
|
|
19
|
+
/** Whether a configuration sets any style's figures (#1237): a family of
|
|
20
|
+
* it is a feature family. */
|
|
21
|
+
export declare function setsFigures(config: ResolvedConfig): boolean;
|
|
22
|
+
export declare const ALIGN: Record<string, string>;
|
|
23
|
+
/** Beside every `letter-spacing` (#703): letter-spacing never changes the
|
|
24
|
+
* glyphs. A reading system turns the common ligatures off where the
|
|
25
|
+
* letter-spacing is not zero; asked for as features they stay, as in the
|
|
26
|
+
* print layout, the fixed-layout pages and the PDF. */
|
|
27
|
+
export declare const TRACKED_LIGATURES = "font-feature-settings: 'liga' 1, 'clig' 1";
|
|
28
|
+
/** A rule from its declarations (the falsy ones left out); none when it
|
|
29
|
+
* declares nothing. */
|
|
30
|
+
export declare function rule(selector: string, decls: (string | false | undefined | null)[]): CssRule | '';
|
|
31
|
+
export declare function ruleText(r: CssRule): string;
|
|
32
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/reflowable/css/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,cAAc,EAAyC,MAAM,SAAS,CAAC;AAErF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAQ1C;;;;4BAI4B;AAC5B,wBAAgB,aAAa,CAAC,GAAG,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG,MAAM,EAAE,CASlE;AAED;;yEAEyE;AACzE,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,EAAE,CAUlD;AAKD;gEACgE;AAChE,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAIlD;AAED;cACc;AACd,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;8BAC8B;AAC9B,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAE3D;AAED,eAAO,MAAM,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAyE,CAAC;AAEnH;;;wDAGwD;AACxD,eAAO,MAAM,iBAAiB,8CAA8C,CAAC;AAE7E;wBACwB;AACxB,wBAAgB,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,MAAM,GAAG,KAAK,GAAG,SAAS,GAAG,IAAI,CAAC,EAAE,GAAG,OAAO,GAAG,EAAE,CAGjG;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAE3C"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// What the stylesheet of a reflowable book is written with: the Japanese
|
|
2
|
+
// line breaks, emphasis marks, family stacks, alignments and a rule from its
|
|
3
|
+
// declarations (#1276: split out of css.ts).
|
|
4
|
+
import { featureFamilyParts, primaryFontFamily } from 'postext';
|
|
5
|
+
import { cssString } from '../../shared/assets.js';
|
|
6
|
+
/** CSS `line-break` for a Japanese kinsoku level (`cjk.lineBreak`, #417):
|
|
7
|
+
* JLReq's strictest rules are CSS `strict` (no small kana, ー or 々 at a
|
|
8
|
+
* line start), the general books' rules CSS `normal` (they may), the
|
|
9
|
+
* newspapers' CSS `loose`. Chinese levels write none, as before. */
|
|
10
|
+
const LINE_BREAK = { 'ja-very-strict': 'strict', 'ja-strict': 'normal', 'ja-loose': 'loose' };
|
|
11
|
+
/** The declarations of the Japanese text of a book (#428): kinsoku and,
|
|
12
|
+
* with burasagari (`cjk.hangingPunctuation`, on by default in Japan),
|
|
13
|
+
* 、。,. hanging past the line end; and, in any book that asks for it,
|
|
14
|
+
* lines broken only between phrases (`cjk.wordBreak: 'keep-all'`, #463).
|
|
15
|
+
* None for other books. */
|
|
16
|
+
export function japaneseDecls(cjk) {
|
|
17
|
+
const out = [];
|
|
18
|
+
if (cjk.wordBreak === 'keep-all')
|
|
19
|
+
out.push('word-break: keep-all');
|
|
20
|
+
const lineBreak = LINE_BREAK[cjk.lineBreak];
|
|
21
|
+
if (lineBreak)
|
|
22
|
+
out.push(`line-break: ${lineBreak}`, `-epub-line-break: ${lineBreak}`, `-webkit-line-break: ${lineBreak}`);
|
|
23
|
+
if (cjk.region === 'japan' && cjk.hangingPunctuation !== 'none') {
|
|
24
|
+
out.push(`hanging-punctuation: ${cjk.hangingPunctuation === 'force' ? 'force-end' : 'allow-end'}`);
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
/** The emphasis-mark rule of a class `dotsClasses` gives: a shape and fill
|
|
29
|
+
* (`pt-dots-filled-sesame`), or a side (`pt-dots-over`: over horizontal
|
|
30
|
+
* text and right of vertical text; `pt-dots-under`: under and left). */
|
|
31
|
+
export function dotsRule(cls) {
|
|
32
|
+
const side = /^pt-dots-(over|under)$/.exec(cls);
|
|
33
|
+
if (side) {
|
|
34
|
+
const pos = side[1] === 'over' ? 'over right' : 'under left';
|
|
35
|
+
return rule(`.pt-dots.${cls}`, [`text-emphasis-position: ${pos}`, `-webkit-text-emphasis-position: ${pos}`]);
|
|
36
|
+
}
|
|
37
|
+
const shape = /^pt-dots-(filled|open)-(dot|circle|sesame)$/.exec(cls);
|
|
38
|
+
if (!shape)
|
|
39
|
+
return '';
|
|
40
|
+
const style = `${shape[1]} ${shape[2]}`;
|
|
41
|
+
return rule(`.pt-dots.${cls}`, [`text-emphasis-style: ${style}`, `-epub-text-emphasis-style: ${style}`, `-webkit-text-emphasis-style: ${style}`]);
|
|
42
|
+
}
|
|
43
|
+
const SANS = /\b(sans|grotesk|grotesque|gothic|helvetica|arial|inter|roboto|lato|montserrat|open sans|source sans|fira sans|heiti|hei\b|黑)/i;
|
|
44
|
+
const MONO = /\b(mono|code|courier|consol)/i;
|
|
45
|
+
/** A family as a CSS value: the family quoted, then a generic fallback. A
|
|
46
|
+
* feature family (#1237, `Lora@onum`) is its base family's. */
|
|
47
|
+
export function familyStack(family) {
|
|
48
|
+
const name = familyName(family);
|
|
49
|
+
const generic = MONO.test(name) ? 'monospace' : SANS.test(name) ? 'sans-serif' : 'serif';
|
|
50
|
+
return `${cssString(name)}, ${generic}`;
|
|
51
|
+
}
|
|
52
|
+
/** The family names the stylesheet asks for (to warn about missing
|
|
53
|
+
* faces). */
|
|
54
|
+
export function familyName(family) {
|
|
55
|
+
return featureFamilyParts(primaryFontFamily(family).trim().replace(/^['"]|['"]$/g, '')).family;
|
|
56
|
+
}
|
|
57
|
+
/** Whether a configuration sets any style's figures (#1237): a family of
|
|
58
|
+
* it is a feature family. */
|
|
59
|
+
export function setsFigures(config) {
|
|
60
|
+
return /"[^"]*@(?:onum|lnum|pnum|tnum)(?:\+(?:onum|lnum|pnum|tnum))*"/.test(JSON.stringify(config));
|
|
61
|
+
}
|
|
62
|
+
export const ALIGN = { left: 'start', right: 'end', center: 'center', justify: 'justify' };
|
|
63
|
+
/** Beside every `letter-spacing` (#703): letter-spacing never changes the
|
|
64
|
+
* glyphs. A reading system turns the common ligatures off where the
|
|
65
|
+
* letter-spacing is not zero; asked for as features they stay, as in the
|
|
66
|
+
* print layout, the fixed-layout pages and the PDF. */
|
|
67
|
+
export const TRACKED_LIGATURES = "font-feature-settings: 'liga' 1, 'clig' 1";
|
|
68
|
+
/** A rule from its declarations (the falsy ones left out); none when it
|
|
69
|
+
* declares nothing. */
|
|
70
|
+
export function rule(selector, decls) {
|
|
71
|
+
const body = decls.filter((d) => typeof d === 'string' && d.length > 0);
|
|
72
|
+
return body.length > 0 ? { selector, decls: body } : '';
|
|
73
|
+
}
|
|
74
|
+
export function ruleText(r) {
|
|
75
|
+
return `${r.selector} {\n${r.decls.map((d) => ` ${d};`).join('\n')}\n}\n`;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/reflowable/css/helpers.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,6EAA6E;AAC7E,6CAA6C;AAC7C,OAAO,EAAuB,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACrF,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGnD;;;qEAGqE;AACrE,MAAM,UAAU,GAA2B,EAAE,gBAAgB,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;AAEtH;;;;4BAI4B;AAC5B,MAAM,UAAU,aAAa,CAAC,GAA0B;IACtD,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,IAAI,GAAG,CAAC,SAAS,KAAK,UAAU;QAAE,GAAG,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACnE,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC5C,IAAI,SAAS;QAAE,GAAG,CAAC,IAAI,CAAC,eAAe,SAAS,EAAE,EAAE,qBAAqB,SAAS,EAAE,EAAE,uBAAuB,SAAS,EAAE,CAAC,CAAC;IAC1H,IAAI,GAAG,CAAC,MAAM,KAAK,OAAO,IAAI,GAAG,CAAC,kBAAkB,KAAK,MAAM,EAAE,CAAC;QAChE,GAAG,CAAC,IAAI,CAAC,wBAAwB,GAAG,CAAC,kBAAkB,KAAK,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;IACrG,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;yEAEyE;AACzE,MAAM,UAAU,QAAQ,CAA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O,kBAAkB,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AACjG,CAAC;AAED;8BAC8B;AAC9B,MAAM,UAAU,WAAW,CAAC,MAAsB;IAChD,OAAO,+DAA+D,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;AACtG,CAAC;AAED,MAAM,CAAC,MAAM,KAAK,GAA2B,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAEnH;;;wDAGwD;AACxD,MAAM,CAAC,MAAM,iBAAiB,GAAG,2CAA2C,CAAC;AAE7E;wBACwB;AACxB,MAAM,UAAU,IAAI,CAAC,QAAgB,EAAE,KAA4C;IACjF,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACrF,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,CAAU;IACjC,OAAO,GAAG,CAAC,CAAC,QAAQ,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;AAC7E,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ResolvedConfig, type Dimension, type ColorValue, type ResolvedBodyTextConfig } from 'postext';
|
|
2
|
+
import type { StylesheetOptions, CssRule } from './types.js';
|
|
3
|
+
/** What createTextRules takes from bookStylesheet. */
|
|
4
|
+
export interface TextRulesDeps {
|
|
5
|
+
config: ResolvedConfig;
|
|
6
|
+
options: StylesheetOptions;
|
|
7
|
+
dpi: number;
|
|
8
|
+
body: ResolvedBodyTextConfig;
|
|
9
|
+
bodyPx: number;
|
|
10
|
+
fam: (f: string) => string;
|
|
11
|
+
em: (d: Dimension, basePx?: number) => string;
|
|
12
|
+
lh: (d: Dimension, fontPx: number) => string;
|
|
13
|
+
color: (c: ColorValue | undefined, prop?: string) => string | undefined;
|
|
14
|
+
px: (d: Dimension, basePx?: number) => number;
|
|
15
|
+
spacingEm: (spacing: boolean | Dimension | undefined, lineHeight: Dimension, basePx?: number) => number;
|
|
16
|
+
out: (string | CssRule)[];
|
|
17
|
+
}
|
|
18
|
+
export declare function createTextRules(deps: TextRulesDeps): {};
|
|
19
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/reflowable/css/text.ts"],"names":[],"mappings":"AAIA,OAAO,EAAiB,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAC3H,OAAO,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE7D,sDAAsD;AACtD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,sBAAsB,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3B,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7C,KAAK,EAAE,CAAC,CAAC,EAAE,UAAU,GAAG,SAAS,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACxE,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IACxG,GAAG,EAAE,CAAC,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;CAC3B;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,aAAa,MAkJlD"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// The book stylesheet's rules for the body text, the headings, quotations and
|
|
2
|
+
// lists (#1276: split out of css.ts).
|
|
3
|
+
import { rule, ALIGN, japaneseDecls, TRACKED_LIGATURES } from './helpers.js';
|
|
4
|
+
import { round, idOf } from '../inline.js';
|
|
5
|
+
import { dimensionToPx } from 'postext';
|
|
6
|
+
export function createTextRules(deps) {
|
|
7
|
+
const { config, options, dpi, body, bodyPx, fam, em, lh, color, px, spacingEm, out } = deps;
|
|
8
|
+
// --- body text -----------------------------------------------------------
|
|
9
|
+
const hyphens = body.hyphenation.enabled;
|
|
10
|
+
if (options.vertical) {
|
|
11
|
+
out.push(rule('html', ['writing-mode: vertical-rl', '-epub-writing-mode: vertical-rl', '-webkit-writing-mode: vertical-rl']));
|
|
12
|
+
}
|
|
13
|
+
out.push(rule('body', [
|
|
14
|
+
fam(body.fontFamily),
|
|
15
|
+
lh(body.lineHeight, bodyPx),
|
|
16
|
+
color(body.color),
|
|
17
|
+
`text-align: ${ALIGN[body.textAlign] ?? 'start'}`,
|
|
18
|
+
hyphens && 'hyphens: auto',
|
|
19
|
+
hyphens && '-epub-hyphens: auto',
|
|
20
|
+
hyphens && '-webkit-hyphens: auto',
|
|
21
|
+
body.fontWeight !== 400 && `font-weight: ${body.fontWeight}`,
|
|
22
|
+
// CSS names the two rules the other way round (#717): `orphans` is
|
|
23
|
+
// the lines a paragraph keeps at the foot of a page (the engine's
|
|
24
|
+
// `avoidWidows`), `widows` the lines at the head of the next (its
|
|
25
|
+
// `avoidOrphans`). A rule that is off writes 1: the initial value of
|
|
26
|
+
// both properties is 2, so leaving one out would keep the rule.
|
|
27
|
+
`orphans: ${body.avoidWidows ? Math.max(1, body.widowMinLines) : 1}`,
|
|
28
|
+
`widows: ${body.avoidOrphans ? Math.max(1, body.orphanMinLines) : 1}`,
|
|
29
|
+
'margin: 0',
|
|
30
|
+
'padding: 0 1em',
|
|
31
|
+
...japaneseDecls(config.cjk),
|
|
32
|
+
]));
|
|
33
|
+
const indent = px(body.firstLineIndent);
|
|
34
|
+
const ratio = round(dimensionToPx(body.lineHeight, dpi, bodyPx) / bodyPx);
|
|
35
|
+
const spacing = spacingEm(body.paragraphSpacing, body.lineHeight);
|
|
36
|
+
out.push(rule('p', [
|
|
37
|
+
'margin: 0',
|
|
38
|
+
spacing === 0 && indent > 0 && `text-indent: ${round(indent / bodyPx)}em`,
|
|
39
|
+
spacing > 0 && `margin-block-end: ${spacing}em`,
|
|
40
|
+
]));
|
|
41
|
+
if (spacing === 0 && indent > 0) {
|
|
42
|
+
// The first paragraph after a heading, a list, a figure… is not
|
|
43
|
+
// indented (unless the book indents after headings).
|
|
44
|
+
const after = ['ul', 'ol', 'blockquote', 'figure', 'div', 'aside', 'nav', 'section > p:first-child'];
|
|
45
|
+
if (!body.indentAfterHeading)
|
|
46
|
+
after.unshift('h1', 'h2', 'h3', 'h4', 'h5', 'h6');
|
|
47
|
+
out.push(rule(after.map((s) => (s.includes(' ') ? s : `${s} + p`)).join(', '), ['text-indent: 0']));
|
|
48
|
+
}
|
|
49
|
+
out.push(rule('strong, b', [`font-weight: ${body.boldFontWeight}`, color(body.boldColor)]));
|
|
50
|
+
out.push(rule('em, i', [color(body.italicColor)]));
|
|
51
|
+
out.push(rule('a', ['color: inherit', 'text-decoration: underline']));
|
|
52
|
+
out.push(rule('a.pt-ref', [
|
|
53
|
+
color(body.referenceColor),
|
|
54
|
+
'text-decoration: none',
|
|
55
|
+
body.referenceBold && `font-weight: ${body.boldFontWeight}`,
|
|
56
|
+
body.referenceItalic && 'font-style: italic',
|
|
57
|
+
]));
|
|
58
|
+
out.push(rule('a.pt-pageref', ['text-decoration: none']));
|
|
59
|
+
out.push(rule('sup, sub', ['line-height: 0', 'font-size: 0.7em']));
|
|
60
|
+
// --- headings ------------------------------------------------------------
|
|
61
|
+
const headings = config.headings;
|
|
62
|
+
/** The body's line pitch, px: a 行取り heading (`lineSpan`, #424) takes
|
|
63
|
+
* whole numbers of it. */
|
|
64
|
+
const bodyLinePx = body.lineHeight.unit === 'em' || body.lineHeight.unit === 'rem'
|
|
65
|
+
? body.lineHeight.value * bodyPx
|
|
66
|
+
: px(body.lineHeight);
|
|
67
|
+
for (const level of headings.levels) {
|
|
68
|
+
if (level.level < 1 || level.level > 6)
|
|
69
|
+
continue;
|
|
70
|
+
const hPx = px(level.fontSize);
|
|
71
|
+
// 行取り: the heading's line centred in N body lines, its margins the
|
|
72
|
+
// rest of them (a reflowable book has no grid to keep).
|
|
73
|
+
const lineSpanMargin = level.lineSpan !== undefined
|
|
74
|
+
? Math.max(0, (level.lineSpan * bodyLinePx - (level.lineHeight.unit === 'em' || level.lineHeight.unit === 'rem' ? level.lineHeight.value * hPx : px(level.lineHeight, hPx))) / 2)
|
|
75
|
+
: undefined;
|
|
76
|
+
out.push(rule(`h${level.level}`, [
|
|
77
|
+
fam(level.fontFamily || headings.fontFamily),
|
|
78
|
+
`font-size: ${round(hPx / bodyPx)}em`,
|
|
79
|
+
lh(level.lineHeight, hPx),
|
|
80
|
+
`font-weight: ${level.fontWeight}`,
|
|
81
|
+
`font-style: ${level.italic ? 'italic' : 'normal'}`,
|
|
82
|
+
color(level.color),
|
|
83
|
+
`text-align: ${ALIGN[headings.textAlign] ?? 'start'}`,
|
|
84
|
+
level.letterSpacing.value !== 0 && `letter-spacing: ${em(level.letterSpacing, hPx)}`,
|
|
85
|
+
level.letterSpacing.value !== 0 && TRACKED_LIGATURES,
|
|
86
|
+
level.textTransform === 'uppercase' && 'text-transform: uppercase',
|
|
87
|
+
lineSpanMargin !== undefined
|
|
88
|
+
? `margin: ${round(lineSpanMargin / hPx)}em 0`
|
|
89
|
+
: `margin: ${round(px(level.marginTop, hPx) / hPx)}em 0 ${round(px(level.marginBottom, hPx) / hPx)}em`,
|
|
90
|
+
// 字下げ: the indent counts body characters.
|
|
91
|
+
level.indent && px(level.indent) > 0 && `margin-inline-start: ${round(px(level.indent) / hPx)}em`,
|
|
92
|
+
'hyphens: manual',
|
|
93
|
+
'-epub-hyphens: manual',
|
|
94
|
+
'page-break-after: avoid',
|
|
95
|
+
'break-after: avoid',
|
|
96
|
+
]));
|
|
97
|
+
}
|
|
98
|
+
for (const style of config.headingStyles) {
|
|
99
|
+
const o = style.overrides;
|
|
100
|
+
const sPx = o.fontSize ? px(o.fontSize) : undefined;
|
|
101
|
+
out.push(rule(`.${idOf('hs-', style.id)}`, [
|
|
102
|
+
o.fontFamily && fam(o.fontFamily),
|
|
103
|
+
sPx !== undefined && `font-size: ${round(sPx / bodyPx)}em`,
|
|
104
|
+
o.fontWeight !== undefined && `font-weight: ${o.fontWeight}`,
|
|
105
|
+
o.italic !== undefined && `font-style: ${o.italic ? 'italic' : 'normal'}`,
|
|
106
|
+
o.color && color(o.color),
|
|
107
|
+
o.textTransform && `text-transform: ${o.textTransform === 'uppercase' ? 'uppercase' : 'none'}`,
|
|
108
|
+
]));
|
|
109
|
+
}
|
|
110
|
+
out.push(rule('.pt-part-title', ['text-align: center', 'margin-block-start: 3em']));
|
|
111
|
+
out.push(rule('.pt-part-number', ['display: block', 'font-size: 0.6em', 'margin-block-end: 0.5em']));
|
|
112
|
+
out.push(rule('.pt-hidden', [
|
|
113
|
+
'position: absolute',
|
|
114
|
+
'width: 1px',
|
|
115
|
+
'height: 1px',
|
|
116
|
+
'overflow: hidden',
|
|
117
|
+
'clip: rect(0 0 0 0)',
|
|
118
|
+
'white-space: nowrap',
|
|
119
|
+
]));
|
|
120
|
+
// --- quotations, lists ---------------------------------------------------
|
|
121
|
+
const bq = body.blockquote;
|
|
122
|
+
out.push(rule('blockquote', [
|
|
123
|
+
`margin: ${ratio / 2}em 0`,
|
|
124
|
+
`margin-inline-start: ${em(bq.indent)}`,
|
|
125
|
+
color(bq.color),
|
|
126
|
+
bq.italic && 'font-style: italic',
|
|
127
|
+
]));
|
|
128
|
+
if (bq.italic)
|
|
129
|
+
out.push(rule('blockquote em', ['font-style: normal']));
|
|
130
|
+
const ul = config.unorderedLists;
|
|
131
|
+
const ol = config.orderedLists;
|
|
132
|
+
out.push(rule('ul, ol', [
|
|
133
|
+
'list-style: none',
|
|
134
|
+
`margin: ${em(ol.marginTop)} 0 ${em(ol.marginBottom)}`,
|
|
135
|
+
'padding-inline-start: 1.6em',
|
|
136
|
+
'text-indent: 0',
|
|
137
|
+
]));
|
|
138
|
+
out.push(rule('li', [ol.itemSpacing.value > 0 && `margin-block-start: ${em(ol.itemSpacing)}`]));
|
|
139
|
+
out.push(rule('li li', ['margin-block-start: 0']));
|
|
140
|
+
out.push(rule('li > .pt-lbl:first-child', [
|
|
141
|
+
'display: inline-block',
|
|
142
|
+
'min-width: 1.6em',
|
|
143
|
+
'margin-inline-start: -1.6em',
|
|
144
|
+
'text-indent: 0',
|
|
145
|
+
]));
|
|
146
|
+
out.push(rule('ul > li > .pt-lbl:first-child', [color(ul.color), ul.fontWeight !== body.fontWeight && `font-weight: ${ul.fontWeight}`]));
|
|
147
|
+
out.push(rule('ol > li > .pt-lbl:first-child', [color(ol.color), ol.fontWeight !== body.fontWeight && `font-weight: ${ol.fontWeight}`]));
|
|
148
|
+
out.push(rule('.pt-done', ['text-decoration: line-through']));
|
|
149
|
+
return {};
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/reflowable/css/text.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,sCAAsC;AACtC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAqF,MAAM,SAAS,CAAC;AAmB3H,MAAM,UAAU,eAAe,CAAC,IAAmB;IACjD,MAAM,EACJ,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,EAC3E,GAAG,IAAI,CAAC;IACT,4EAA4E;IAC5E,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;IACzC,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,2BAA2B,EAAE,iCAAiC,EAAE,mCAAmC,CAAC,CAAC,CAAC,CAAC;IAChI,CAAC;IACD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;QACpB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC;QACpB,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;QACjB,eAAe,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,OAAO,EAAE;QACjD,OAAO,IAAI,eAAe;QAC1B,OAAO,IAAI,qBAAqB;QAChC,OAAO,IAAI,uBAAuB;QAClC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AAC,KAAK,CAAC,EAAE,EAAE,CAAC,UAAU,KAAK,IAAI,CAAC,UAAU,IAAI,gBAAgB,EAAE,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;IACzI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,+BAA+B,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,UAAU,KAAK,IAAI,CAAC,UAAU,IAAI,gBAAgB,EAAE,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;IACzI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,+BAA+B,CAAC,CAAC,CAAC,CAAC;IAC9D,OAAO,EACN,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** What the walk found that decides the writing mode of the book. */
|
|
2
|
+
export interface StylesheetOptions {
|
|
3
|
+
/** Vertical Chinese / Japanese (`layout.writingMode: 'vertical-rl'`). */
|
|
4
|
+
vertical: boolean;
|
|
5
|
+
/** The book sets a `:::verse` poem (its rules are written only then). */
|
|
6
|
+
verse?: boolean;
|
|
7
|
+
/** The book sets a poem line by line (#620): the stanza rules. */
|
|
8
|
+
stanzas?: boolean;
|
|
9
|
+
/** Lines of verse carry their numbers (#621): the margin they stand in. */
|
|
10
|
+
lineNumbers?: boolean;
|
|
11
|
+
/** A line holds a tab at its stop (#622): the tab rows. */
|
|
12
|
+
tabs?: boolean;
|
|
13
|
+
/** The book sets a code listing (#624): the listing's box and lines. */
|
|
14
|
+
code?: boolean;
|
|
15
|
+
/** The drop caps the paragraphs open with (#623), as `lines-sink`. */
|
|
16
|
+
dropCaps?: readonly string[];
|
|
17
|
+
/** A figure or a box text wraps round (#627): the float rules. */
|
|
18
|
+
wraps?: boolean;
|
|
19
|
+
/** A picture carries its labels drawn over it (#955): the box and the
|
|
20
|
+
* layer they are drawn in. */
|
|
21
|
+
labelLayers?: boolean;
|
|
22
|
+
/** Classes of emphasis marks the text uses beyond `pt-dots` (the
|
|
23
|
+
* filled dot on the default side): their rules are written only then
|
|
24
|
+
* (`inline.ts` `dotsClasses`, #428). */
|
|
25
|
+
dots?: readonly string[];
|
|
26
|
+
/** The book sets composed pages (#862): the frame rules, and the
|
|
27
|
+
* callout styles their frames are set in (their boxes are styled on a
|
|
28
|
+
* frame's block too). */
|
|
29
|
+
composed?: {
|
|
30
|
+
frameStyles: readonly string[];
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** A rule of the stylesheet: its selector and declarations
|
|
34
|
+
* (`property: value`). */
|
|
35
|
+
export interface CssRule {
|
|
36
|
+
selector: string;
|
|
37
|
+
decls: string[];
|
|
38
|
+
}
|
|
39
|
+
/** The book's stylesheet: its text, the families it names, and its rules
|
|
40
|
+
* (at-rules aside), which {@link stylesheetOverrides} compares. */
|
|
41
|
+
export interface Stylesheet {
|
|
42
|
+
css: string;
|
|
43
|
+
families: Set<string>;
|
|
44
|
+
rules: CssRule[];
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/reflowable/css/types.ts"],"names":[],"mappings":"AAIA,qEAAqE;AACrE,MAAM,WAAW,iBAAiB;IAChC,yEAAyE;IACzE,QAAQ,EAAE,OAAO,CAAC;IAClB,yEAAyE;IACzE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kEAAkE;IAClE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,2EAA2E;IAC3E,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,wEAAwE;IACxE,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,sEAAsE;IACtE,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,kEAAkE;IAClE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;mCAC+B;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;6CAEyC;IACzC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB;;8BAE0B;IAC1B,QAAQ,CAAC,EAAE;QAAE,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,CAAC;CAC/C;AAED;2BAC2B;AAC3B,MAAM,WAAW,OAAO;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;oEACoE;AACpE,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,KAAK,EAAE,OAAO,EAAE,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/reflowable/css/types.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,kDAAkD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Dimension, type ResolvedConfig, type ColorValue, type ResolvedBodyTextConfig } from 'postext';
|
|
2
|
+
import type { StylesheetOptions, CssRule } from './types.js';
|
|
3
|
+
/** What createVerseRules takes from bookStylesheet. */
|
|
4
|
+
export interface VerseRulesDeps {
|
|
5
|
+
config: ResolvedConfig;
|
|
6
|
+
options: StylesheetOptions;
|
|
7
|
+
dpi: number;
|
|
8
|
+
body: ResolvedBodyTextConfig;
|
|
9
|
+
bodyPx: number;
|
|
10
|
+
fam: (f: string) => string;
|
|
11
|
+
em: (d: Dimension, basePx?: number) => string;
|
|
12
|
+
lh: (d: Dimension, fontPx: number) => string;
|
|
13
|
+
color: (c: ColorValue | undefined, prop?: string) => string | undefined;
|
|
14
|
+
px: (d: Dimension, basePx?: number) => number;
|
|
15
|
+
out: (string | CssRule)[];
|
|
16
|
+
}
|
|
17
|
+
export declare function createVerseRules(deps: VerseRulesDeps): {};
|
|
18
|
+
//# sourceMappingURL=verse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verse.d.ts","sourceRoot":"","sources":["../../../src/reflowable/css/verse.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoC,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,KAAK,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAE9I,OAAO,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE7D,uDAAuD;AACvD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,sBAAsB,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3B,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7C,KAAK,EAAE,CAAC,CAAC,EAAE,UAAU,GAAG,SAAS,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACxE,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C,GAAG,EAAE,CAAC,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;CAC3B;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,MAyHpD"}
|