@threepenny/md2pdf 2.7.0 → 2.8.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 (44) hide show
  1. package/README.md +22 -8
  2. package/bin/md2pdf.js +60 -16
  3. package/lib/address-links.js +38 -0
  4. package/lib/attributions.js +69 -0
  5. package/lib/fit.js +50 -9
  6. package/lib/italic-lines.js +27 -0
  7. package/lib/render.js +6 -0
  8. package/lib/styles.js +2 -0
  9. package/package.json +1 -1
  10. package/styles/academic.css +14 -0
  11. package/styles/classic.css +15 -0
  12. package/styles/fiendish.css +671 -0
  13. package/styles/fonts/andika/Andika-Bold.woff2 +0 -0
  14. package/styles/fonts/andika/Andika-BoldItalic.woff2 +0 -0
  15. package/styles/fonts/andika/Andika-Italic.woff2 +0 -0
  16. package/styles/fonts/andika/Andika-Regular.woff2 +0 -0
  17. package/styles/fonts/andika/OFL.txt +94 -93
  18. package/styles/fonts/bodoni-moda/OFL.txt +93 -0
  19. package/styles/fonts/bodoni-moda/bodoni-moda-latin-900-normal.woff2 +0 -0
  20. package/styles/fonts/cinzel/OFL.txt +93 -0
  21. package/styles/fonts/cinzel/cinzel-latin-400-normal.woff2 +0 -0
  22. package/styles/fonts/cinzel/cinzel-latin-700-normal.woff2 +0 -0
  23. package/styles/fonts/courier-prime/OFL.txt +93 -0
  24. package/styles/fonts/courier-prime/courier-prime-latin-400-italic.woff2 +0 -0
  25. package/styles/fonts/courier-prime/courier-prime-latin-400-normal.woff2 +0 -0
  26. package/styles/fonts/courier-prime/courier-prime-latin-700-normal.woff2 +0 -0
  27. package/styles/fonts/libre-caslon-text/OFL.txt +93 -0
  28. package/styles/fonts/libre-caslon-text/libre-caslon-text-latin-400-italic.woff2 +0 -0
  29. package/styles/fonts/libre-caslon-text/libre-caslon-text-latin-400-normal.woff2 +0 -0
  30. package/styles/fonts/libre-caslon-text/libre-caslon-text-latin-700-normal.woff2 +0 -0
  31. package/styles/fonts/old-standard-tt/OFL.txt +93 -0
  32. package/styles/fonts/old-standard-tt/old-standard-tt-latin-400-italic.woff2 +0 -0
  33. package/styles/fonts/old-standard-tt/old-standard-tt-latin-400-normal.woff2 +0 -0
  34. package/styles/fonts/old-standard-tt/old-standard-tt-latin-700-normal.woff2 +0 -0
  35. package/styles/gothic.css +15 -0
  36. package/styles/newspaper.css +899 -0
  37. package/styles/print/fiendish.css +92 -0
  38. package/styles/print/newspaper.css +95 -0
  39. package/styles/sandwake.css +14 -0
  40. package/styles/worksheet.css +10 -8
  41. package/styles/fonts/andika/andika-latin-400-italic.woff2 +0 -0
  42. package/styles/fonts/andika/andika-latin-400-normal.woff2 +0 -0
  43. package/styles/fonts/andika/andika-latin-700-italic.woff2 +0 -0
  44. package/styles/fonts/andika/andika-latin-700-normal.woff2 +0 -0
@@ -0,0 +1,92 @@
1
+ /* Fiendish: the print-only rules (page margins, running headers and page numbers). Load after
2
+ ../fiendish.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
+ /* From the second page on, the instrument's title runs across the top over a rule; every page has a
10
+ place for the Borrower's initials and its number. Margin boxes don't see the document's variables,
11
+ so these repeat fiendish.css's fonts and colors. */
12
+ @page {
13
+ margin: 1in 1.1in 0.95in;
14
+ @top-center {
15
+ content: var(--document-title);
16
+ vertical-align: bottom;
17
+ margin-bottom: 24pt;
18
+ padding-bottom: 5pt;
19
+ border-bottom: 0.75pt solid #141210;
20
+ font-family: "md2pdf Cinzel", Trajan, Optima, Georgia, serif;
21
+ font-size: 8.5pt;
22
+ font-weight: 700;
23
+ letter-spacing: 0.2em;
24
+ color: #141210;
25
+ }
26
+ @bottom-left {
27
+ content: "Initial here\00a0\00a0________";
28
+ vertical-align: top;
29
+ margin-top: 18pt;
30
+ font-family: "md2pdf Libre Caslon Text", "Big Caslon", Georgia, serif;
31
+ font-size: 9pt;
32
+ font-style: italic;
33
+ color: #5c5650;
34
+ }
35
+ @bottom-right {
36
+ content: "Page " counter(page) " of " counter(pages);
37
+ vertical-align: top;
38
+ margin-top: 18pt;
39
+ font-family: "md2pdf Cinzel", Trajan, Optima, Georgia, serif;
40
+ /* Bold, the weight the headings already load: a browser's print dialog loads only the faces the
41
+ document uses, so a weight used nowhere else falls back here. */
42
+ font-weight: 700;
43
+ font-size: 8pt;
44
+ letter-spacing: 0.14em;
45
+ color: #b8210f;
46
+ }
47
+ }
48
+ @page :first {
49
+ @top-center {
50
+ content: "";
51
+ border: 0;
52
+ }
53
+ }
54
+
55
+ html,
56
+ body {
57
+ margin: 0;
58
+ background: #fff;
59
+ }
60
+
61
+ /* A PDF can't be clicked, so a collapsed section prints open, its summary kept with what follows. After it
62
+ comes a paragraph's space, or its last block's if that is more. A section that ends a quote, callout,
63
+ table cell, or the last item of a list inside one of those or another list, gives up that space, and so
64
+ do the sections and last block inside it, up to three sections deep, so none shows inside; at the end of
65
+ a nested list, the next item is then an item's space away, as after text. */
66
+ .markdown-body details {
67
+ margin-bottom: calc(9 * var(--fiendish-pt) * var(--md2pdf-space));
68
+ }
69
+ .markdown-body :is(blockquote, .markdown-alert, td, th, :is(blockquote, .markdown-alert, td, th, li) :is(ul, ol) > li:last-child) > details:last-child,
70
+ .markdown-body :is(blockquote, .markdown-alert, td, th, :is(blockquote, .markdown-alert, td, th, li) :is(ul, ol) > li:last-child) > details:last-child > :last-child,
71
+ .markdown-body :is(blockquote, .markdown-alert, td, th, :is(blockquote, .markdown-alert, td, th, li) :is(ul, ol) > li:last-child) > details:last-child > details:last-child > :last-child,
72
+ .markdown-body :is(blockquote, .markdown-alert, td, th, :is(blockquote, .markdown-alert, td, th, li) :is(ul, ol) > li:last-child) > details:last-child > details:last-child > details:last-child > :last-child {
73
+ margin-bottom: 0;
74
+ }
75
+ .markdown-body details::details-content {
76
+ content-visibility: visible;
77
+ }
78
+ .markdown-body details:not([open]) > summary {
79
+ list-style-type: disclosure-open;
80
+ }
81
+ .markdown-body details > summary {
82
+ break-after: avoid;
83
+ }
84
+
85
+ /* Nothing follows the document's last block, so Safari keeps no space below it: it starts a blank
86
+ page for that space when it runs past the end of a page. Only Safari, since Chrome's margin-trim
87
+ also drops the space above a block that a page break moves. */
88
+ @supports (font: -apple-system-body) {
89
+ .markdown-body {
90
+ margin-trim: block-end;
91
+ }
92
+ }
@@ -0,0 +1,95 @@
1
+ /* Newspaper: the print-only rules (page margins, running headers and page numbers). Load after
2
+ ../newspaper.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
+ /* From the second page on, the page number and the paper's name run across the top over a rule. The
10
+ front page has the nameplate instead. Margin boxes don't see the document's variables, so these
11
+ repeat newspaper.css's body font and ink. */
12
+ @page {
13
+ margin: 1in 0.75in 0.8in;
14
+ @top-left {
15
+ content: counter(page);
16
+ vertical-align: bottom;
17
+ margin-bottom: 16pt;
18
+ padding-bottom: 4.5pt;
19
+ border-bottom: 0.75pt solid #1a1a18;
20
+ font-family: "md2pdf Old Standard TT", "Century Schoolbook", Georgia, serif;
21
+ font-size: 9pt;
22
+ font-weight: 700;
23
+ color: #1a1a18;
24
+ }
25
+ @top-center {
26
+ content: var(--document-title);
27
+ vertical-align: bottom;
28
+ margin-bottom: 16pt;
29
+ padding-bottom: 4.5pt;
30
+ border-bottom: 0.75pt solid #1a1a18;
31
+ font-family: "md2pdf Old Standard TT", "Century Schoolbook", Georgia, serif;
32
+ font-size: 8.25pt;
33
+ font-weight: 700;
34
+ letter-spacing: 0.14em;
35
+ text-transform: uppercase;
36
+ color: #1a1a18;
37
+ }
38
+ @top-right {
39
+ content: "";
40
+ margin-bottom: 16pt;
41
+ border-bottom: 0.75pt solid #1a1a18;
42
+ }
43
+ }
44
+ @page :first {
45
+ @top-left {
46
+ content: "";
47
+ border: 0;
48
+ }
49
+ @top-center {
50
+ content: "";
51
+ border: 0;
52
+ }
53
+ @top-right {
54
+ border: 0;
55
+ }
56
+ }
57
+
58
+ html,
59
+ body {
60
+ margin: 0;
61
+ background: #fff;
62
+ }
63
+
64
+ /* A PDF can't be clicked, so a collapsed section prints open, its summary kept with what follows. After it
65
+ comes a paragraph's space, or its last block's if that is more. A section that ends a quote, callout,
66
+ table cell, or the last item of a list inside one of those or another list, gives up that space, and so
67
+ do the sections and last block inside it, up to three sections deep, so none shows inside; at the end of
68
+ a nested list, the next item is then an item's space away, as after text. */
69
+ .markdown-body details {
70
+ margin-bottom: calc(8 / 14 * var(--md2pdf-font-size) * var(--md2pdf-space));
71
+ }
72
+ .markdown-body :is(blockquote, .markdown-alert, td, th, :is(blockquote, .markdown-alert, td, th, li) :is(ul, ol) > li:last-child) > details:last-child,
73
+ .markdown-body :is(blockquote, .markdown-alert, td, th, :is(blockquote, .markdown-alert, td, th, li) :is(ul, ol) > li:last-child) > details:last-child > :last-child,
74
+ .markdown-body :is(blockquote, .markdown-alert, td, th, :is(blockquote, .markdown-alert, td, th, li) :is(ul, ol) > li:last-child) > details:last-child > details:last-child > :last-child,
75
+ .markdown-body :is(blockquote, .markdown-alert, td, th, :is(blockquote, .markdown-alert, td, th, li) :is(ul, ol) > li:last-child) > details:last-child > details:last-child > details:last-child > :last-child {
76
+ margin-bottom: 0;
77
+ }
78
+ .markdown-body details::details-content {
79
+ content-visibility: visible;
80
+ }
81
+ .markdown-body details:not([open]) > summary {
82
+ list-style-type: disclosure-open;
83
+ }
84
+ .markdown-body details > summary {
85
+ break-after: avoid;
86
+ }
87
+
88
+ /* Nothing follows the document's last block, so Safari keeps no space below it: it starts a blank
89
+ page for that space when it runs past the end of a page. Only Safari, since Chrome's margin-trim
90
+ also drops the space above a block that a page break moves. */
91
+ @supports (font: -apple-system-body) {
92
+ .markdown-body {
93
+ margin-trim: block-end;
94
+ }
95
+ }
@@ -97,6 +97,8 @@
97
97
  counter-reset: md2pdf-book md2pdf-section;
98
98
  /* A long web address wraps at the margin instead of making Chrome shrink the page to fit it. */
99
99
  overflow-wrap: break-word;
100
+ /* Whether a long address may break anywhere, set beside each text-align: only in justified text. */
101
+ --md2pdf-address-break: normal;
100
102
  font-kerning: normal;
101
103
  -webkit-print-color-adjust: exact;
102
104
  print-color-adjust: exact;
@@ -105,6 +107,7 @@
105
107
  .markdown-body p,
106
108
  .markdown-body li {
107
109
  text-align: justify;
110
+ --md2pdf-address-break: break-all;
108
111
  hyphens: auto;
109
112
  orphans: 3;
110
113
  widows: 3;
@@ -241,10 +244,16 @@
241
244
  .markdown-body a {
242
245
  color: #1d4a86;
243
246
  text-decoration: none;
247
+ hyphens: manual;
244
248
  }
245
249
  .markdown-body a.header-anchor {
246
250
  display: none;
247
251
  }
252
+ /* A long address in justified text may break anywhere, without a hyphen, so it starts on the line where it
253
+ falls rather than dropping whole and leaving wide gaps in the line before (#150). */
254
+ .markdown-body a.markdown-address {
255
+ word-break: var(--md2pdf-address-break);
256
+ }
248
257
 
249
258
  /* Lists */
250
259
 
@@ -298,6 +307,7 @@
298
307
  }
299
308
  .markdown-body blockquote p {
300
309
  text-align: left;
310
+ --md2pdf-address-break: normal;
301
311
  }
302
312
 
303
313
  /* Callouts (GitHub alerts and Obsidian callouts): an outlined box with a colored edge, its title a
@@ -336,6 +346,7 @@
336
346
  text-transform: uppercase;
337
347
  color: var(--md2pdf-callout);
338
348
  text-align: left;
349
+ --md2pdf-address-break: normal;
339
350
  hyphens: manual;
340
351
  }
341
352
  .markdown-body .markdown-alert-title .octicon {
@@ -354,6 +365,7 @@
354
365
  .markdown-body code,
355
366
  .markdown-body kbd {
356
367
  font-family: var(--md2pdf-code-font);
368
+ hyphens: manual;
357
369
  font-size: 0.8em;
358
370
  }
359
371
  .markdown-body :not(pre) > code {
@@ -458,6 +470,8 @@
458
470
  .markdown-body td {
459
471
  padding: 0.4em 0.9em 0.4em 0;
460
472
  text-align: left;
473
+ --md2pdf-address-break: normal;
474
+ hyphens: manual;
461
475
  }
462
476
  .markdown-body td {
463
477
  border-top: 0.5pt solid var(--md2pdf-rule);
@@ -30,33 +30,35 @@
30
30
  --md2pdf-code-font: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
31
31
  }
32
32
 
33
- /* Andika (SIL International) and Fredoka, both under the SIL Open Font License; the licences are in
34
- fonts/andika/OFL.txt and fonts/fredoka/OFL.txt. Their latin subsets cover English and Western
35
- European languages (Basic Latin and Latin-1, plus œ and €); other letters, such as Polish, Czech or
36
- Turkish ones, come from the fallbacks. */
33
+ /* Andika (SIL Global) and Fredoka, both under the SIL Open Font License; the licences are in
34
+ fonts/andika/OFL.txt and fonts/fredoka/OFL.txt. Andika's licence reserves its name, so its files are
35
+ SIL's own, unchanged: subsetting them would mean renaming them. They cover Latin and Cyrillic, but
36
+ of Greek only the letters IPA and maths use; other Greek letters come from the fallbacks. Fredoka's
37
+ latin subset covers English and Western European languages (Basic Latin and Latin-1, plus œ and €);
38
+ other letters, such as Polish, Czech or Turkish ones, come from the fallbacks. */
37
39
  @font-face {
38
40
  font-family: "md2pdf Andika";
39
41
  font-weight: 400;
40
42
  font-style: normal;
41
- src: url("fonts/andika/andika-latin-400-normal.woff2") format("woff2");
43
+ src: url("fonts/andika/Andika-Regular.woff2") format("woff2");
42
44
  }
43
45
  @font-face {
44
46
  font-family: "md2pdf Andika";
45
47
  font-weight: 400;
46
48
  font-style: italic;
47
- src: url("fonts/andika/andika-latin-400-italic.woff2") format("woff2");
49
+ src: url("fonts/andika/Andika-Italic.woff2") format("woff2");
48
50
  }
49
51
  @font-face {
50
52
  font-family: "md2pdf Andika";
51
53
  font-weight: 700;
52
54
  font-style: normal;
53
- src: url("fonts/andika/andika-latin-700-normal.woff2") format("woff2");
55
+ src: url("fonts/andika/Andika-Bold.woff2") format("woff2");
54
56
  }
55
57
  @font-face {
56
58
  font-family: "md2pdf Andika";
57
59
  font-weight: 700;
58
60
  font-style: italic;
59
- src: url("fonts/andika/andika-latin-700-italic.woff2") format("woff2");
61
+ src: url("fonts/andika/Andika-BoldItalic.woff2") format("woff2");
60
62
  }
61
63
  @font-face {
62
64
  font-family: "md2pdf Fredoka";