@threepenny/md2pdf 2.2.3 → 2.4.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.
Files changed (60) hide show
  1. package/README.md +22 -14
  2. package/bin/md2pdf.js +75 -8
  3. package/lib/math.js +15 -8
  4. package/lib/render.js +24 -3
  5. package/lib/styles.js +4 -0
  6. package/package.json +2 -2
  7. package/styles/academic.css +18 -1
  8. package/styles/classic.css +18 -1
  9. package/styles/cyberpunk.css +710 -0
  10. package/styles/elvish.css +659 -0
  11. package/styles/fonts/chakra-petch/OFL.txt +93 -0
  12. package/styles/fonts/chakra-petch/chakra-petch-latin-400-italic.woff2 +0 -0
  13. package/styles/fonts/chakra-petch/chakra-petch-latin-400-normal.woff2 +0 -0
  14. package/styles/fonts/chakra-petch/chakra-petch-latin-700-italic.woff2 +0 -0
  15. package/styles/fonts/chakra-petch/chakra-petch-latin-700-normal.woff2 +0 -0
  16. package/styles/fonts/cormorant-garamond/OFL.txt +93 -0
  17. package/styles/fonts/cormorant-garamond/cormorant-garamond-latin-500-italic.woff2 +0 -0
  18. package/styles/fonts/cormorant-garamond/cormorant-garamond-latin-500-normal.woff2 +0 -0
  19. package/styles/fonts/cormorant-garamond/cormorant-garamond-latin-700-italic.woff2 +0 -0
  20. package/styles/fonts/cormorant-garamond/cormorant-garamond-latin-700-normal.woff2 +0 -0
  21. package/styles/fonts/cormorant-unicase/OFL.txt +93 -0
  22. package/styles/fonts/cormorant-unicase/cormorant-unicase-latin-600-normal.woff2 +0 -0
  23. package/styles/fonts/grenze-gotisch/OFL.txt +93 -0
  24. package/styles/fonts/grenze-gotisch/grenze-gotisch-latin-600-normal.woff2 +0 -0
  25. package/styles/fonts/im-fell-english/OFL.txt +93 -0
  26. package/styles/fonts/im-fell-english/im-fell-english-latin-400-italic.woff2 +0 -0
  27. package/styles/fonts/im-fell-english/im-fell-english-latin-400-normal.woff2 +0 -0
  28. package/styles/fonts/jetbrains-mono/OFL.txt +93 -0
  29. package/styles/fonts/jetbrains-mono/jetbrains-mono-latin-400-italic.woff2 +0 -0
  30. package/styles/fonts/jetbrains-mono/jetbrains-mono-latin-400-normal.woff2 +0 -0
  31. package/styles/fonts/jetbrains-mono/jetbrains-mono-latin-700-normal.woff2 +0 -0
  32. package/styles/fonts/michroma/OFL.txt +93 -0
  33. package/styles/fonts/michroma/michroma-latin-400-normal.woff2 +0 -0
  34. package/styles/fonts/space-mono/OFL.txt +93 -0
  35. package/styles/fonts/space-mono/space-mono-latin-400-italic.woff2 +0 -0
  36. package/styles/fonts/space-mono/space-mono-latin-400-normal.woff2 +0 -0
  37. package/styles/fonts/space-mono/space-mono-latin-700-normal.woff2 +0 -0
  38. package/styles/fonts/spectral/OFL.txt +93 -0
  39. package/styles/fonts/spectral/spectral-latin-400-italic.woff2 +0 -0
  40. package/styles/fonts/spectral/spectral-latin-400-normal.woff2 +0 -0
  41. package/styles/fonts/spectral/spectral-latin-600-italic.woff2 +0 -0
  42. package/styles/fonts/spectral/spectral-latin-600-normal.woff2 +0 -0
  43. package/styles/github.css +30 -0
  44. package/styles/gothic.css +503 -0
  45. package/styles/modern.css +18 -1
  46. package/styles/print/academic.css +9 -0
  47. package/styles/print/classic.css +9 -0
  48. package/styles/print/cyberpunk.css +101 -0
  49. package/styles/print/elvish.css +78 -0
  50. package/styles/print/github.css +9 -0
  51. package/styles/print/gothic.css +38 -0
  52. package/styles/print/modern.css +9 -0
  53. package/styles/print/report.css +9 -0
  54. package/styles/print/resume.css +9 -0
  55. package/styles/print/sandwake.css +56 -0
  56. package/styles/print/worksheet.css +9 -0
  57. package/styles/report.css +18 -1
  58. package/styles/resume.css +18 -1
  59. package/styles/sandwake.css +556 -0
  60. package/styles/worksheet.css +18 -1
@@ -0,0 +1,503 @@
1
+ /* Gothic: a page from an old book of dread. Blackletter titles and section headings and a
2
+ seventeenth-century book face (both bundled), oxblood for the title and main headings, ornaments,
3
+ quote bars and table rules, a drop cap after the title and a leaf ornament for rules. No page
4
+ background: the paper stays white up to its edges. */
5
+
6
+ /* Variables a page can override, on .markdown-body itself: for all its documents, or for one with
7
+ <article class="markdown-body" style="--md2pdf-font-size: 13pt">. A value set on :root or another
8
+ ancestor doesn't reach the document. :where() gives these defaults no specificity, so the page's
9
+ rule wins wherever it comes. Every style uses the same names. */
10
+ :where(.markdown-body) {
11
+ /* Size and spacing. --md2pdf-font-size is the body text size, an absolute length such as 12pt or 16px; headings and smaller text scale with
12
+ it. --md2pdf-leading scales each line height's excess over 1, and --md2pdf-space the vertical
13
+ gaps between blocks; both are 1 as designed. */
14
+ --md2pdf-font-size: 12pt;
15
+ --md2pdf-leading: 1;
16
+ --md2pdf-space: 1;
17
+ /* Colors: --md2pdf-background the document's background; --md2pdf-text body text; --md2pdf-muted
18
+ secondary text; --md2pdf-accent h1, h2 and h4, the drop cap, links, bold text, list markers,
19
+ quote bars, tick boxes, caution callouts, table headings and rules, and the footnote rule (the
20
+ leaf ornaments stay oxblood); --md2pdf-rule thin rules and borders;
21
+ --md2pdf-surface code and callout backgrounds. */
22
+ --md2pdf-background: #fff;
23
+ --md2pdf-text: #1c1916;
24
+ --md2pdf-muted: #5f574e;
25
+ --md2pdf-accent: #7a1f1f;
26
+ --md2pdf-rule: #c9b9a6;
27
+ --md2pdf-surface: #f7f2eb;
28
+ /* Fonts: --md2pdf-font body text, --md2pdf-heading-font h1, h2, h3 and the drop cap,
29
+ --md2pdf-code-font code. */
30
+ --md2pdf-font: "md2pdf IM Fell English", "Iowan Old Style", Palatino, Georgia, serif;
31
+ --md2pdf-heading-font: "md2pdf Grenze Gotisch", var(--md2pdf-font);
32
+ --md2pdf-code-font: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
33
+ }
34
+
35
+ /* IM Fell English (Igino Marini) and Grenze Gotisch (Omnibus-Type), both under the SIL Open Font
36
+ License; the licences are in fonts/im-fell-english/OFL.txt and fonts/grenze-gotisch/OFL.txt. Their
37
+ latin subsets cover English and Western European languages (Basic Latin and Latin-1, plus œ and
38
+ €); other letters come from the fallbacks. IM Fell has no bold, so bold text is set in color
39
+ instead (see Bold below). */
40
+ @font-face {
41
+ font-family: "md2pdf IM Fell English";
42
+ font-weight: 400;
43
+ font-style: normal;
44
+ src: url("fonts/im-fell-english/im-fell-english-latin-400-normal.woff2") format("woff2");
45
+ }
46
+ @font-face {
47
+ font-family: "md2pdf IM Fell English";
48
+ font-weight: 400;
49
+ font-style: italic;
50
+ src: url("fonts/im-fell-english/im-fell-english-latin-400-italic.woff2") format("woff2");
51
+ }
52
+ @font-face {
53
+ font-family: "md2pdf Grenze Gotisch";
54
+ font-weight: 600;
55
+ font-style: normal;
56
+ src: url("fonts/grenze-gotisch/grenze-gotisch-latin-600-normal.woff2") format("woff2");
57
+ }
58
+
59
+ .markdown-body {
60
+ font-family: var(--md2pdf-font);
61
+ background: var(--md2pdf-background);
62
+ font-size: var(--md2pdf-font-size);
63
+ line-height: calc(1 + 0.5 * var(--md2pdf-leading));
64
+ color: var(--md2pdf-text);
65
+ /* A long web address wraps at the margin instead of making Chrome shrink the page to fit it. */
66
+ overflow-wrap: break-word;
67
+ font-kerning: normal;
68
+ -webkit-print-color-adjust: exact;
69
+ print-color-adjust: exact;
70
+ }
71
+
72
+ .markdown-body p,
73
+ .markdown-body li {
74
+ text-align: justify;
75
+ hyphens: auto;
76
+ orphans: 3;
77
+ widows: 3;
78
+ }
79
+
80
+ .markdown-body p {
81
+ margin: 0 0 calc(0.75em * var(--md2pdf-space));
82
+ }
83
+
84
+ /* The leaf ornament under the title and in place of --- rules: a hedera between two hairlines. The
85
+ fonts have no ornaments of their own. It's an image in the accent's oxblood, so it keeps that color
86
+ when --md2pdf-accent changes: a mask would follow the variable, but Chrome prints a solid block
87
+ beside a masked element. */
88
+ .markdown-body h1::after,
89
+ .markdown-body hr::after {
90
+ content: "";
91
+ display: block;
92
+ height: 1.1em;
93
+ margin: 0 auto;
94
+ background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 24'%3E%3Cg fill='none' stroke='%237a1f1f'%3E%3Cpath d='M4 12H44M80 12H116' stroke-width='1'/%3E%3Cpath d='M54 12C50.5 12 47.5 10 48 7.6C48.4 5.8 50.6 5.6 51.2 7' stroke-width='1.3'/%3E%3C/g%3E%3Cpath fill='%237a1f1f' transform='translate(50 0) rotate(-90 12 12)' d='M12 21C5 15 1 11 1 7C1 3.5 4 1 7 1C9.5 1 11 2.5 12 4C13 2.5 14.5 1 17 1C20 1 23 3.5 23 7C23 11 19 15 12 21Z'/%3E%3C/svg%3E") center / contain no-repeat;
95
+ }
96
+
97
+ /* Headings */
98
+
99
+ .markdown-body h1,
100
+ .markdown-body h2,
101
+ .markdown-body h3,
102
+ .markdown-body h4,
103
+ .markdown-body h5,
104
+ .markdown-body h6 {
105
+ font-weight: normal;
106
+ line-height: calc(1 + 0.2 * var(--md2pdf-leading));
107
+ break-after: avoid;
108
+ }
109
+
110
+ .markdown-body h1,
111
+ .markdown-body h2,
112
+ .markdown-body h3 {
113
+ font-family: var(--md2pdf-heading-font);
114
+ font-weight: 600;
115
+ color: var(--md2pdf-accent);
116
+ }
117
+
118
+ .markdown-body h1 {
119
+ font-size: calc(34 / 12 * var(--md2pdf-font-size));
120
+ text-align: center;
121
+ margin: 0 0 calc(0.75em * var(--md2pdf-space));
122
+ /* The ornament is a block inside the heading; without this a page can break between them. */
123
+ break-inside: avoid;
124
+ }
125
+ .markdown-body h1::after {
126
+ width: 5.5em;
127
+ height: 0.5em;
128
+ margin-top: calc(0.3em * var(--md2pdf-space));
129
+ }
130
+ /* Any later h1 starts a new section with a bit more air. */
131
+ .markdown-body h1:not(:first-child) {
132
+ margin-top: calc(1.6em * var(--md2pdf-space));
133
+ }
134
+
135
+ .markdown-body h2 {
136
+ font-size: calc(21 / 12 * var(--md2pdf-font-size));
137
+ margin: calc(1.5em * var(--md2pdf-space)) 0 calc(0.45em * var(--md2pdf-space));
138
+ }
139
+
140
+ .markdown-body h3 {
141
+ font-size: calc(16 / 12 * var(--md2pdf-font-size));
142
+ color: var(--md2pdf-text);
143
+ margin: calc(1.4em * var(--md2pdf-space)) 0 calc(0.4em * var(--md2pdf-space));
144
+ }
145
+
146
+ .markdown-body h4,
147
+ .markdown-body h5,
148
+ .markdown-body h6 {
149
+ font-size: var(--md2pdf-font-size);
150
+ font-style: italic;
151
+ margin: calc(1.2em * var(--md2pdf-space)) 0 calc(0.3em * var(--md2pdf-space));
152
+ }
153
+ .markdown-body h4 {
154
+ color: var(--md2pdf-accent);
155
+ font-size: calc(13 / 12 * var(--md2pdf-font-size));
156
+ }
157
+ .markdown-body h6 {
158
+ color: var(--md2pdf-muted);
159
+ }
160
+
161
+ /* The drop cap: the first letter of the paragraph under the document's title, sunk three lines deep
162
+ where the browser can size it to the lines (Chrome and Safari). Elsewhere (Firefox) it's a raised
163
+ initial, standing on the first line, since sinking it by hand depends on the font's measurements.
164
+ A paragraph whose first element is code or a key, directly or inside a link or other wrapper, has none:
165
+ its first letter would leave the code's box behind, empty. CSS can't tell whether text comes
166
+ before it, so that paragraph loses the drop cap too. */
167
+ .markdown-body > h1:first-child + p:not(:has(> code:first-child)):not(:has(> kbd:first-child)):not(:has(> :first-child > code:first-child)):not(:has(> :first-child > kbd:first-child))::first-letter {
168
+ font-family: var(--md2pdf-heading-font);
169
+ font-weight: 600;
170
+ color: var(--md2pdf-accent);
171
+ }
172
+ @supports not ((initial-letter: 3) or (-webkit-initial-letter: 3)) {
173
+ .markdown-body > h1:first-child + p:not(:has(> code:first-child)):not(:has(> kbd:first-child)):not(:has(> :first-child > code:first-child)):not(:has(> :first-child > kbd:first-child))::first-letter {
174
+ font-size: 3em;
175
+ line-height: 1;
176
+ margin-right: 0.03em;
177
+ }
178
+ }
179
+ @supports (initial-letter: 3) or (-webkit-initial-letter: 3) {
180
+ /* A paragraph shorter than the letter grows to hold it, so the next block doesn't wrap around it. */
181
+ .markdown-body > h1:first-child + p:not(:has(> code:first-child)):not(:has(> kbd:first-child)):not(:has(> :first-child > code:first-child)):not(:has(> :first-child > kbd:first-child)) {
182
+ display: flow-root;
183
+ }
184
+ .markdown-body > h1:first-child + p:not(:has(> code:first-child)):not(:has(> kbd:first-child)):not(:has(> :first-child > code:first-child)):not(:has(> :first-child > kbd:first-child))::first-letter {
185
+ -webkit-initial-letter: 3;
186
+ initial-letter: 3;
187
+ /* Chrome ignores a sunk letter's margin, so the gap is padding, in body-text units. */
188
+ padding-right: calc(0.35 * var(--md2pdf-font-size));
189
+ }
190
+ }
191
+
192
+ /* Links */
193
+
194
+ .markdown-body a {
195
+ color: var(--md2pdf-accent);
196
+ text-decoration: none;
197
+ }
198
+ .markdown-body a.header-anchor {
199
+ display: none;
200
+ }
201
+
202
+ /* Bold: oxblood at the weight around it, and body-text color inside text that's already oxblood or a
203
+ callout's color. IM Fell has no bold, and Safari fakes one by drawing each letter three times,
204
+ which puts every bold word in the PDF's text three times. */
205
+
206
+ .markdown-body strong,
207
+ .markdown-body b {
208
+ font-weight: inherit;
209
+ color: var(--md2pdf-accent);
210
+ }
211
+ .markdown-body :is(h1, h2, h4, a, th, .markdown-alert-title) :is(strong, b) {
212
+ color: var(--md2pdf-text);
213
+ }
214
+
215
+ /* Lists */
216
+
217
+ .markdown-body ul,
218
+ .markdown-body ol {
219
+ margin: 0 0 calc(0.75em * var(--md2pdf-space));
220
+ padding-left: 1.6em;
221
+ }
222
+ .markdown-body li {
223
+ margin: calc(0.15em * var(--md2pdf-space)) 0;
224
+ }
225
+ .markdown-body li > ul,
226
+ .markdown-body li > ol {
227
+ margin: calc(0.15em * var(--md2pdf-space)) 0 0;
228
+ }
229
+ .markdown-body li::marker {
230
+ color: var(--md2pdf-accent);
231
+ }
232
+ .markdown-body .task-list-item {
233
+ list-style-type: none;
234
+ }
235
+ /* Boxes drawn here at the browser's size: its own are greyed out, as they're disabled. */
236
+ .markdown-body .task-list-item input {
237
+ appearance: none;
238
+ width: 13px;
239
+ height: 13px;
240
+ margin: 0 0.4em 0.2em -1.4em;
241
+ vertical-align: middle;
242
+ border: 1px solid var(--md2pdf-accent);
243
+ border-radius: 1px;
244
+ background: var(--md2pdf-background);
245
+ }
246
+ .markdown-body .task-list-item input:checked {
247
+ background: var(--md2pdf-accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
248
+ }
249
+
250
+ /* Quotes */
251
+
252
+ .markdown-body blockquote {
253
+ margin: calc(1.1em * var(--md2pdf-space)) 2em;
254
+ padding: 0 0 0 1em;
255
+ border-left: 2px solid var(--md2pdf-accent);
256
+ font-style: italic;
257
+ color: #3f3832;
258
+ break-inside: avoid;
259
+ }
260
+ .markdown-body blockquote p {
261
+ text-align: left;
262
+ }
263
+
264
+ /* Callouts (GitHub alerts and Obsidian callouts): a ruled box, its title in small capitals. */
265
+
266
+ .markdown-body .markdown-alert {
267
+ --md2pdf-callout: #3d5468;
268
+ margin: calc(1.1em * var(--md2pdf-space)) 0;
269
+ padding: 0.55em 1em 0.6em;
270
+ border-left: 2px solid var(--md2pdf-callout);
271
+ background: var(--md2pdf-surface);
272
+ break-inside: avoid;
273
+ }
274
+ .markdown-body .markdown-alert-tip {
275
+ --md2pdf-callout: #45603a;
276
+ }
277
+ .markdown-body .markdown-alert-important {
278
+ --md2pdf-callout: #5e3f6b;
279
+ }
280
+ .markdown-body .markdown-alert-warning {
281
+ --md2pdf-callout: #845d12;
282
+ }
283
+ .markdown-body .markdown-alert-caution {
284
+ --md2pdf-callout: var(--md2pdf-accent);
285
+ }
286
+ .markdown-body .markdown-alert-quote {
287
+ --md2pdf-callout: var(--md2pdf-muted);
288
+ }
289
+ .markdown-body .markdown-alert-title {
290
+ margin-bottom: calc(0.3em * var(--md2pdf-space));
291
+ color: var(--md2pdf-callout);
292
+ font-variant: small-caps;
293
+ letter-spacing: 0.05em;
294
+ text-align: left;
295
+ hyphens: manual;
296
+ }
297
+ .markdown-body .markdown-alert-title .octicon {
298
+ margin-right: 0.45em;
299
+ vertical-align: -0.1em;
300
+ width: 0.85em;
301
+ height: 0.85em;
302
+ fill: currentColor;
303
+ }
304
+ .markdown-body .markdown-alert > :last-child {
305
+ margin-bottom: 0;
306
+ }
307
+
308
+ /* Code */
309
+
310
+ .markdown-body code,
311
+ .markdown-body kbd {
312
+ font-family: var(--md2pdf-code-font);
313
+ font-size: 0.78em;
314
+ }
315
+ .markdown-body :not(pre) > code {
316
+ background: var(--md2pdf-surface);
317
+ padding: 0.1em 0.3em;
318
+ border-radius: 2px;
319
+ }
320
+ .markdown-body kbd {
321
+ padding: 0.05em 0.35em;
322
+ border: 1px solid var(--md2pdf-rule);
323
+ border-bottom-width: 2px;
324
+ border-radius: 2px;
325
+ background: var(--md2pdf-background);
326
+ }
327
+ .markdown-body pre {
328
+ background: var(--md2pdf-surface);
329
+ border: 1px solid var(--md2pdf-rule);
330
+ border-radius: 2px;
331
+ padding: 0.9em 1.1em;
332
+ margin: 0 0 calc(1em * var(--md2pdf-space));
333
+ line-height: calc(1 + 0.45 * var(--md2pdf-leading));
334
+ white-space: pre-wrap;
335
+ word-break: break-word;
336
+ break-inside: avoid;
337
+ }
338
+ .markdown-body pre code {
339
+ font-size: calc(8.5 / 12 * var(--md2pdf-font-size));
340
+ }
341
+ /* A highlight.js theme on the host page styles .hljs too; keep code blocks this style's own. */
342
+ .markdown-body pre code.hljs {
343
+ display: inline;
344
+ overflow: visible;
345
+ padding: 0;
346
+ color: inherit;
347
+ background: none;
348
+ }
349
+ /* And its tokens: this outranks a theme's token rules, and this style's colors come after it. */
350
+ .markdown-body [class*="hljs-"] {
351
+ color: inherit;
352
+ background: none;
353
+ font-style: inherit;
354
+ font-weight: inherit;
355
+ text-decoration: none;
356
+ }
357
+
358
+ /* Muted, inky syntax colors. */
359
+ .markdown-body .hljs-comment,
360
+ .markdown-body .hljs-quote {
361
+ color: #6e665d;
362
+ font-style: italic;
363
+ }
364
+ .markdown-body .hljs-keyword,
365
+ .markdown-body .hljs-selector-tag,
366
+ .markdown-body .hljs-literal,
367
+ .markdown-body .hljs-doctag {
368
+ color: #8f2424;
369
+ }
370
+ .markdown-body .hljs-string,
371
+ .markdown-body .hljs-regexp,
372
+ .markdown-body .hljs-addition {
373
+ color: #4a6339;
374
+ }
375
+ .markdown-body .hljs-number,
376
+ .markdown-body .hljs-symbol,
377
+ .markdown-body .hljs-bullet {
378
+ color: #85560a;
379
+ }
380
+ .markdown-body .hljs-title,
381
+ .markdown-body .hljs-section,
382
+ .markdown-body .hljs-name {
383
+ color: #2f4760;
384
+ }
385
+ .markdown-body .hljs-built_in,
386
+ .markdown-body .hljs-type,
387
+ .markdown-body .hljs-attr,
388
+ .markdown-body .hljs-attribute,
389
+ .markdown-body .hljs-variable,
390
+ .markdown-body .hljs-template-variable {
391
+ color: #5f4470;
392
+ }
393
+ .markdown-body .hljs-meta,
394
+ .markdown-body .hljs-deletion {
395
+ color: #8f2424;
396
+ }
397
+ .markdown-body .hljs-emphasis {
398
+ font-style: italic;
399
+ }
400
+ .markdown-body .hljs-strong {
401
+ font-weight: bold;
402
+ }
403
+
404
+ /* Tables: oxblood rules above, below and under the heading row, nothing between the columns. */
405
+
406
+ .markdown-body table {
407
+ border-collapse: collapse;
408
+ margin: calc(1.2em * var(--md2pdf-space)) auto;
409
+ border-top: 1.5px solid var(--md2pdf-accent);
410
+ border-bottom: 1.5px solid var(--md2pdf-accent);
411
+ }
412
+ .markdown-body th,
413
+ .markdown-body td {
414
+ padding: 0.35em 0.9em;
415
+ text-align: left;
416
+ }
417
+ .markdown-body td {
418
+ border-top: 0.5px solid var(--md2pdf-rule);
419
+ }
420
+ .markdown-body th {
421
+ font-weight: normal;
422
+ font-variant: small-caps;
423
+ letter-spacing: 0.05em;
424
+ color: var(--md2pdf-accent);
425
+ border-bottom: 0.75px solid var(--md2pdf-accent);
426
+ }
427
+ .markdown-body tr {
428
+ break-inside: avoid;
429
+ }
430
+
431
+ /* Rules and images */
432
+
433
+ .markdown-body hr {
434
+ border: 0;
435
+ margin: calc(1.4em * var(--md2pdf-space)) 0;
436
+ /* Firefox otherwise splits the ornament across a page break. */
437
+ break-inside: avoid;
438
+ }
439
+ .markdown-body hr::after {
440
+ width: 9em;
441
+ }
442
+
443
+ .markdown-body img {
444
+ display: block;
445
+ max-width: 100%;
446
+ margin: calc(1em * var(--md2pdf-space)) auto;
447
+ break-inside: avoid;
448
+ }
449
+
450
+ /* Footnotes */
451
+
452
+ .markdown-body hr.footnotes-sep {
453
+ display: none;
454
+ }
455
+ .markdown-body .footnotes {
456
+ margin-top: calc(2.5em * var(--md2pdf-space));
457
+ font-size: calc(10 / 12 * var(--md2pdf-font-size));
458
+ color: var(--md2pdf-muted);
459
+ }
460
+ .markdown-body .footnotes::before {
461
+ content: "";
462
+ display: block;
463
+ width: 30%;
464
+ border-top: 0.75px solid var(--md2pdf-accent);
465
+ margin-bottom: calc(0.8em * var(--md2pdf-space));
466
+ /* Keep the line on the page with the first footnote. */
467
+ break-after: avoid;
468
+ }
469
+ .markdown-body .footnotes ol {
470
+ /* Room for the numbers, which Safari sets further left than Chrome. */
471
+ padding-left: 2em;
472
+ }
473
+ .markdown-body .footnote-ref a,
474
+ .markdown-body .footnote-backref {
475
+ color: var(--md2pdf-accent);
476
+ }
477
+
478
+ /* A word joiner keeps a footnote mark on the line with the word before it. */
479
+ .markdown-body .footnote-ref::before {
480
+ content: "\2060";
481
+ }
482
+
483
+ /* An Obsidian embed (![[Other note]]) that can't be shown: a muted placeholder. */
484
+ .markdown-body .markdown-embed {
485
+ color: var(--md2pdf-muted);
486
+ font-style: italic;
487
+ }
488
+
489
+ /* <div class="page-break"></div> starts a new page. */
490
+ .markdown-body .page-break {
491
+ break-after: page;
492
+ }
493
+
494
+ /* Safari's PDFs copy a ligature as the wrong characters ("The" pastes as "!e", "ffi" as "ffi"), so it
495
+ prints without them. An element's own font-feature-settings or `font` shorthand undoes this; set
496
+ its features with font-variant-* instead. */
497
+ @media print {
498
+ @supports (font: -apple-system-body) {
499
+ .markdown-body {
500
+ font-feature-settings: "liga" 0, "clig" 0;
501
+ }
502
+ }
503
+ }
package/styles/modern.css CHANGED
@@ -357,7 +357,8 @@
357
357
  color: var(--md2pdf-muted);
358
358
  }
359
359
  .markdown-body .footnotes ol {
360
- padding-left: 1.3em;
360
+ /* Room for numbers up to 99, which Safari sets further left than Chrome. */
361
+ padding-left: 2.2em;
361
362
  }
362
363
  .markdown-body .footnotes li {
363
364
  margin: calc(0.2em * var(--md2pdf-space)) 0;
@@ -366,6 +367,11 @@
366
367
  margin: 0;
367
368
  }
368
369
 
370
+ /* A word joiner keeps a footnote mark on the line with the word before it. */
371
+ .markdown-body .footnote-ref::before {
372
+ content: "\2060";
373
+ }
374
+
369
375
  /* An Obsidian embed (![[Other note]]) that can't be shown: a muted placeholder. */
370
376
  .markdown-body .markdown-embed {
371
377
  color: var(--md2pdf-muted);
@@ -376,3 +382,14 @@
376
382
  .markdown-body .page-break {
377
383
  break-after: page;
378
384
  }
385
+
386
+ /* Safari's PDFs copy a ligature as the wrong characters ("The" pastes as "!e", "ffi" as "ffi"), so it
387
+ prints without them. An element's own font-feature-settings or `font` shorthand undoes this; set
388
+ its features with font-variant-* instead. */
389
+ @media print {
390
+ @supports (font: -apple-system-body) {
391
+ .markdown-body {
392
+ font-feature-settings: "liga" 0, "clig" 0;
393
+ }
394
+ }
395
+ }
@@ -20,3 +20,12 @@ body {
20
20
  margin: 0;
21
21
  background: #fff;
22
22
  }
23
+
24
+ /* Nothing follows the document's last block, so Safari keeps no space below it: it starts a blank
25
+ page for that space when it runs past the end of a page. Only Safari, since Chrome's margin-trim
26
+ also drops the space above a block that a page break moves. */
27
+ @supports (font: -apple-system-body) {
28
+ .markdown-body {
29
+ margin-trim: block-end;
30
+ }
31
+ }
@@ -25,3 +25,12 @@ body {
25
25
  margin: 0;
26
26
  background: #fff;
27
27
  }
28
+
29
+ /* Nothing follows the document's last block, so Safari keeps no space below it: it starts a blank
30
+ page for that space when it runs past the end of a page. Only Safari, since Chrome's margin-trim
31
+ also drops the space above a block that a page break moves. */
32
+ @supports (font: -apple-system-body) {
33
+ .markdown-body {
34
+ margin-trim: block-end;
35
+ }
36
+ }
@@ -0,0 +1,101 @@
1
+ /* Cyberpunk: the print-only rules (page margins, running headers and page numbers). Load after
2
+ ../cyberpunk.css when printing; a page that only shows the document on screen leaves this out. */
3
+
4
+ :root {
5
+ /* The document's first heading, for the running header; set by the renderer or the page showing it. */
6
+ --document-title: "";
7
+ }
8
+
9
+ /* Margin boxes don't see the document's variables, so these repeat cyberpunk.css's label font and
10
+ its muted, teal and magenta colors. */
11
+ @page {
12
+ margin: 1in 0.75in 0.9in;
13
+ @top-left {
14
+ content: var(--document-title);
15
+ vertical-align: bottom;
16
+ margin-bottom: 22pt;
17
+ padding-bottom: 7pt;
18
+ border-bottom: 0.75pt solid #007a8a;
19
+ font-family: "md2pdf JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
20
+ font-size: 8.5pt;
21
+ letter-spacing: 0.16em;
22
+ text-transform: uppercase;
23
+ color: #5a6878;
24
+ }
25
+ /* An empty box carries the header rule across the page and stops browsers adding their own header. */
26
+ @top-center {
27
+ content: "";
28
+ margin-bottom: 22pt;
29
+ border-bottom: 0.75pt solid #007a8a;
30
+ }
31
+ @top-right {
32
+ content: "// Eyes only";
33
+ vertical-align: bottom;
34
+ margin-bottom: 22pt;
35
+ padding-bottom: 7pt;
36
+ border-bottom: 0.75pt solid #007a8a;
37
+ font-family: "md2pdf JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
38
+ font-size: 8.5pt;
39
+ letter-spacing: 0.16em;
40
+ text-transform: uppercase;
41
+ color: #d4106a;
42
+ }
43
+ @bottom-left {
44
+ content: "// End of page";
45
+ vertical-align: top;
46
+ margin-top: 20pt;
47
+ padding-top: 7pt;
48
+ border-top: 0.75pt solid #007a8a;
49
+ font-family: "md2pdf JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
50
+ font-size: 8.5pt;
51
+ letter-spacing: 0.16em;
52
+ text-transform: uppercase;
53
+ color: #5a6878;
54
+ }
55
+ @bottom-center {
56
+ content: "";
57
+ margin-top: 20pt;
58
+ border-top: 0.75pt solid #007a8a;
59
+ }
60
+ @bottom-right {
61
+ content: "PG " counter(page, decimal-leading-zero) " / " counter(pages, decimal-leading-zero);
62
+ vertical-align: top;
63
+ margin-top: 20pt;
64
+ padding-top: 7pt;
65
+ border-top: 0.75pt solid #007a8a;
66
+ font-family: "md2pdf JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
67
+ font-size: 8.5pt;
68
+ letter-spacing: 0.16em;
69
+ text-transform: uppercase;
70
+ color: #5a6878;
71
+ }
72
+ }
73
+ /* The title panel replaces the header on the first page. */
74
+ @page :first {
75
+ @top-left {
76
+ content: "";
77
+ border: 0;
78
+ }
79
+ @top-center {
80
+ border: 0;
81
+ }
82
+ @top-right {
83
+ content: "";
84
+ border: 0;
85
+ }
86
+ }
87
+
88
+ html,
89
+ body {
90
+ margin: 0;
91
+ background: #fff;
92
+ }
93
+
94
+ /* Nothing follows the document's last block, so Safari keeps no space below it: it starts a blank
95
+ page for that space when it runs past the end of a page. Only Safari, since Chrome's margin-trim
96
+ also drops the space above a block that a page break moves. */
97
+ @supports (font: -apple-system-body) {
98
+ .markdown-body {
99
+ margin-trim: block-end;
100
+ }
101
+ }