@uniweb/press 0.4.11 → 0.4.13
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/package.json +1 -1
- package/src/adapters/epub.js +8 -2
- package/src/adapters/math-css.js +19 -0
- package/src/adapters/pagedjs.js +8 -2
package/package.json
CHANGED
package/src/adapters/epub.js
CHANGED
|
@@ -63,7 +63,14 @@ export async function compileEpub(input, options = {}) {
|
|
|
63
63
|
const { meta = {}, stylesheet, identifier, cover, loadAsset } = options
|
|
64
64
|
|
|
65
65
|
const resolvedMeta = { ...(metadata || {}), ...meta }
|
|
66
|
-
|
|
66
|
+
// Math CSS is emitted ahead of the design stylesheet, not inside it.
|
|
67
|
+
// Temml's MathML needs these rules to lay out at all -- without them a
|
|
68
|
+
// pmatrix's rows touch and an aligned environment's = signs drift -- and a
|
|
69
|
+
// foundation that supplies its own `stylesheet` REPLACES the default, so
|
|
70
|
+
// folding them into DEFAULT_STYLESHEET meant customizing the design
|
|
71
|
+
// silently broke the maths. Emitting first also leaves the foundation's
|
|
72
|
+
// sheet able to override any of it.
|
|
73
|
+
const css = `${MATH_CSS}\n${stylesheet || DEFAULT_STYLESHEET}`
|
|
67
74
|
const id = identifier || resolvedMeta.identifier || generateUuid()
|
|
68
75
|
const coverUrl = cover || resolvedMeta.cover || resolvedMeta.coverImage
|
|
69
76
|
|
|
@@ -626,5 +633,4 @@ pre {
|
|
|
626
633
|
overflow: auto;
|
|
627
634
|
white-space: pre-wrap;
|
|
628
635
|
}
|
|
629
|
-
${MATH_CSS}
|
|
630
636
|
`
|
package/src/adapters/math-css.js
CHANGED
|
@@ -54,4 +54,23 @@ math mtable.tml-jot mtd { padding-top: 0.7ex; padding-bottom: 0.7ex; }
|
|
|
54
54
|
}
|
|
55
55
|
body {
|
|
56
56
|
counter-reset: tmlEqnNo;
|
|
57
|
+
}
|
|
58
|
+
/* Display math needs CSS block layout, not MathML layout, for an equation TAG
|
|
59
|
+
to reach the right margin: the tag rides in an mtable whose width:100%
|
|
60
|
+
Chromium ignores under display: block math, collapsing the spacer cells so
|
|
61
|
+
"(1)" sits glued to the equation instead of at the margin.
|
|
62
|
+
|
|
63
|
+
!important is not decoration. Temml emits style=display:block math on
|
|
64
|
+
every display formula unconditionally — no option turns it off — so an inline
|
|
65
|
+
style beats any rule we write, including Temml's own math.tml-display { display: block }, which is exactly what this restores. Fixing it here
|
|
66
|
+
rather than in the generator also repairs math that was already built.
|
|
67
|
+
|
|
68
|
+
Scoped with :has() to formulas that actually carry a tag. Switching every
|
|
69
|
+
display formula to CSS block layout would left-align the lot -- MathML layout
|
|
70
|
+
is what centres them -- so an unnumbered derivation or matrix keeps
|
|
71
|
+
display: block math and stays centred. Where :has() is unsupported the tag
|
|
72
|
+
simply does not reach the margin; nothing else changes. */
|
|
73
|
+
math.tml-display:has(.tml-eqn) {
|
|
74
|
+
display: block !important;
|
|
75
|
+
width: 100%;
|
|
57
76
|
}`
|
package/src/adapters/pagedjs.js
CHANGED
|
@@ -131,7 +131,14 @@ async function compileServerSide(htmlDoc, options = {}) {
|
|
|
131
131
|
export function emitDocument({ body = '', meta = {}, stylesheet, polyfillUrl } = {}) {
|
|
132
132
|
const lang = meta.language ?? 'en'
|
|
133
133
|
const title = meta.title ?? 'Book'
|
|
134
|
-
|
|
134
|
+
// Math CSS is emitted ahead of the design stylesheet, not inside it.
|
|
135
|
+
// Temml's MathML needs these rules to lay out at all -- without them a
|
|
136
|
+
// pmatrix's rows touch and an aligned environment's = signs drift -- and a
|
|
137
|
+
// foundation that supplies its own `stylesheet` REPLACES the default, so
|
|
138
|
+
// folding them into DEFAULT_STYLESHEET meant customizing the design
|
|
139
|
+
// silently broke the maths. Emitting first also leaves the foundation's
|
|
140
|
+
// sheet able to override any of it.
|
|
141
|
+
const css = `${MATH_CSS}\n${stylesheet || DEFAULT_STYLESHEET}`
|
|
135
142
|
const polyfill = polyfillUrl || DEFAULT_POLYFILL_URL
|
|
136
143
|
|
|
137
144
|
return `<!doctype html>
|
|
@@ -294,5 +301,4 @@ blockquote {
|
|
|
294
301
|
}
|
|
295
302
|
ul, ol { margin: 0.5em 0 0.75em 1.5em; }
|
|
296
303
|
figure { break-inside: avoid; }
|
|
297
|
-
${MATH_CSS}
|
|
298
304
|
`
|