@threepenny/md2pdf 2.4.0 → 2.6.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.
@@ -0,0 +1,32 @@
1
+ // markdown-it's typographic replacements without (c), (r) and (tm), which it turns into ©, ® and ™ wherever
2
+ // they stand: the last of "(a) (b) (c)", "Rule 12(c)", "f(r)". Its one option, typographer, covers them
3
+ // together with the dashes, the ellipsis and ±, so this is its `replacements` rule (15.0.2) with the rest.
4
+
5
+ const RARE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/;
6
+
7
+ export default function typography(md) {
8
+ md.core.ruler.at('replacements', (state) => {
9
+ if (!state.md.options.typographer) return;
10
+ for (const block of state.tokens) {
11
+ if (block.type !== 'inline' || !RARE.test(block.content)) continue;
12
+ let insideAutolink = 0;
13
+ for (let i = block.children.length - 1; i >= 0; i--) {
14
+ const token = block.children[i];
15
+ if (token.type === 'text' && !insideAutolink && RARE.test(token.content)) {
16
+ token.content = token.content
17
+ .replace(/\+-/g, '±')
18
+ // .., ..., ....... -> …, but ?..... and !..... -> ?.. and !..
19
+ .replace(/\.{2,}/g, '…')
20
+ .replace(/([?!])…/g, '$1..')
21
+ .replace(/([?!]){4,}/g, '$1$1$1')
22
+ .replace(/,{2,}/g, ',')
23
+ .replace(/(^|[^-])---(?=[^-]|$)/gm, '$1—')
24
+ .replace(/(^|\s)--(?=\s|$)/gm, '$1–')
25
+ .replace(/(^|[^-\s])--(?=[^-\s]|$)/gm, '$1–');
26
+ }
27
+ if (token.type === 'link_open' && token.info === 'auto') insideAutolink--;
28
+ if (token.type === 'link_close' && token.info === 'auto') insideAutolink++;
29
+ }
30
+ }
31
+ });
32
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threepenny/md2pdf",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "description": "Markdown to beautifully styled PDF: the renderer and macOS CLI behind md2pdf.me",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -33,6 +33,7 @@
33
33
  "demo": "echo 'Open http://localhost:3900/demo/' && python3 -m http.server 3900 --bind 127.0.0.1"
34
34
  },
35
35
  "dependencies": {
36
+ "entities": "^8.0.0",
36
37
  "github-markdown-css": "5.9.0",
37
38
  "highlight.js": "^11.12.0",
38
39
  "katex": "^0.19.1",
package/styles/github.css CHANGED
@@ -12,7 +12,7 @@
12
12
  --md2pdf-leading: 1;
13
13
  --md2pdf-space: 1;
14
14
  /* Colors: --md2pdf-background the document's background; --md2pdf-text body text; --md2pdf-muted
15
- quotes, footnotes and secondary text; --md2pdf-accent links. */
15
+ quotes, footnotes and secondary text; --md2pdf-accent links and focus rings. */
16
16
  --md2pdf-background: #fff;
17
17
  --md2pdf-text: #1f2328;
18
18
  --md2pdf-muted: #59636e;
@@ -24,6 +24,14 @@
24
24
  --md2pdf-code-font: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;
25
25
  }
26
26
 
27
+ /* github-markdown-light.css draws focus rings, and <kbd>'s border and shadow, in these colors but
28
+ leaves them to github-markdown.css to define. Undefined, the ring turns off the browser's own, and
29
+ <kbd> loses its border and shadow. --borderColor-muted is github-markdown.css's light value (5.9.0). */
30
+ :where(.markdown-body) {
31
+ --borderColor-accent-emphasis: var(--md2pdf-accent);
32
+ --borderColor-muted: #d1d9e0b3;
33
+ }
34
+
27
35
  /* highlight.js's GitHub theme, limited to the document. From highlight.js 11.12.0.
28
36
  On .hljs itself, :where() keeps each selector's specificity what it is in the theme, so the rules
29
37
  below still override it. The token rules take .markdown-body's specificity, to outrank a theme on
@@ -189,11 +197,13 @@
189
197
  }
190
198
 
191
199
  /* github-markdown-css sets footnotes and keys in px, so they're restated as their share of the text
192
- size, the same at 11pt. */
200
+ size, the same at 11pt. A key's padding stays github-markdown-css's 0.25rem (3pt here) but shrinks
201
+ with smaller text, or the key, border included, makes its line taller. */
193
202
  .markdown-body .footnotes {
194
203
  font-size: calc(9 / 11 * var(--md2pdf-font-size));
195
204
  }
196
205
  .markdown-body kbd {
206
+ padding: min(0.25rem, calc(3 / 11 * var(--md2pdf-font-size)));
197
207
  font-size: calc(8.25 / 11 * var(--md2pdf-font-size));
198
208
  line-height: calc(7.5 / 11 * var(--md2pdf-font-size));
199
209
  }
@@ -21,6 +21,30 @@ body {
21
21
  background: #fff;
22
22
  }
23
23
 
24
+ /* A PDF can't be clicked, so a collapsed section prints open, its summary kept with what follows. After it
25
+ comes a paragraph's space, or its last block's if that is more. A section that ends a quote, callout,
26
+ table cell, or the last item of a list inside one of those or another list, gives up that space, and so
27
+ do the sections and last block inside it, up to three sections deep, so none shows inside; at the end of
28
+ a nested list, the next item is then an item's space away, as after text. */
29
+ .markdown-body details {
30
+ margin-bottom: calc(0.6em * var(--md2pdf-space));
31
+ }
32
+ .markdown-body :is(blockquote, .markdown-alert, td, th, :is(blockquote, .markdown-alert, td, th, li) :is(ul, ol) > li:last-child) > details:last-child,
33
+ .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,
34
+ .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,
35
+ .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 {
36
+ margin-bottom: 0;
37
+ }
38
+ .markdown-body details::details-content {
39
+ content-visibility: visible;
40
+ }
41
+ .markdown-body details:not([open]) > summary {
42
+ list-style-type: disclosure-open;
43
+ }
44
+ .markdown-body details > summary {
45
+ break-after: avoid;
46
+ }
47
+
24
48
  /* Nothing follows the document's last block, so Safari keeps no space below it: it starts a blank
25
49
  page for that space when it runs past the end of a page. Only Safari, since Chrome's margin-trim
26
50
  also drops the space above a block that a page break moves. */
@@ -26,6 +26,30 @@ body {
26
26
  background: #fff;
27
27
  }
28
28
 
29
+ /* A PDF can't be clicked, so a collapsed section prints open, its summary kept with what follows. After it
30
+ comes a paragraph's space, or its last block's if that is more. A section that ends a quote, callout,
31
+ table cell, or the last item of a list inside one of those or another list, gives up that space, and so
32
+ do the sections and last block inside it, up to three sections deep, so none shows inside; at the end of
33
+ a nested list, the next item is then an item's space away, as after text. */
34
+ .markdown-body details {
35
+ margin-bottom: calc(0.75em * var(--md2pdf-space));
36
+ }
37
+ .markdown-body :is(blockquote, .markdown-alert, td, th, :is(blockquote, .markdown-alert, td, th, li) :is(ul, ol) > li:last-child) > details:last-child,
38
+ .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,
39
+ .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,
40
+ .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 {
41
+ margin-bottom: 0;
42
+ }
43
+ .markdown-body details::details-content {
44
+ content-visibility: visible;
45
+ }
46
+ .markdown-body details:not([open]) > summary {
47
+ list-style-type: disclosure-open;
48
+ }
49
+ .markdown-body details > summary {
50
+ break-after: avoid;
51
+ }
52
+
29
53
  /* Nothing follows the document's last block, so Safari keeps no space below it: it starts a blank
30
54
  page for that space when it runs past the end of a page. Only Safari, since Chrome's margin-trim
31
55
  also drops the space above a block that a page break moves. */
@@ -91,6 +91,30 @@ body {
91
91
  background: #fff;
92
92
  }
93
93
 
94
+ /* A PDF can't be clicked, so a collapsed section prints open, its summary kept with what follows. After it
95
+ comes a paragraph's space, or its last block's if that is more. A section that ends a quote, callout,
96
+ table cell, or the last item of a list inside one of those or another list, gives up that space, and so
97
+ do the sections and last block inside it, up to three sections deep, so none shows inside; at the end of
98
+ a nested list, the next item is then an item's space away, as after text. */
99
+ .markdown-body details {
100
+ margin-bottom: calc(0.8em * var(--md2pdf-space));
101
+ }
102
+ .markdown-body :is(blockquote, .markdown-alert, td, th, :is(blockquote, .markdown-alert, td, th, li) :is(ul, ol) > li:last-child) > details:last-child,
103
+ .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,
104
+ .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,
105
+ .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 {
106
+ margin-bottom: 0;
107
+ }
108
+ .markdown-body details::details-content {
109
+ content-visibility: visible;
110
+ }
111
+ .markdown-body details:not([open]) > summary {
112
+ list-style-type: disclosure-open;
113
+ }
114
+ .markdown-body details > summary {
115
+ break-after: avoid;
116
+ }
117
+
94
118
  /* Nothing follows the document's last block, so Safari keeps no space below it: it starts a blank
95
119
  page for that space when it runs past the end of a page. Only Safari, since Chrome's margin-trim
96
120
  also drops the space above a block that a page break moves. */
@@ -68,6 +68,30 @@ body {
68
68
  background: #fff;
69
69
  }
70
70
 
71
+ /* A PDF can't be clicked, so a collapsed section prints open, its summary kept with what follows. After it
72
+ comes a paragraph's space, or its last block's if that is more. A section that ends a quote, callout,
73
+ table cell, or the last item of a list inside one of those or another list, gives up that space, and so
74
+ do the sections and last block inside it, up to three sections deep, so none shows inside; at the end of
75
+ a nested list, the next item is then an item's space away, as after text. */
76
+ .markdown-body details {
77
+ margin-bottom: calc(0.75em * var(--md2pdf-space));
78
+ }
79
+ .markdown-body :is(blockquote, .markdown-alert, td, th, :is(blockquote, .markdown-alert, td, th, li) :is(ul, ol) > li:last-child) > details:last-child,
80
+ .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,
81
+ .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,
82
+ .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 {
83
+ margin-bottom: 0;
84
+ }
85
+ .markdown-body details::details-content {
86
+ content-visibility: visible;
87
+ }
88
+ .markdown-body details:not([open]) > summary {
89
+ list-style-type: disclosure-open;
90
+ }
91
+ .markdown-body details > summary {
92
+ break-after: avoid;
93
+ }
94
+
71
95
  /* Nothing follows the document's last block, so Safari keeps no space below it: it starts a blank
72
96
  page for that space when it runs past the end of a page. Only Safari, since Chrome's margin-trim
73
97
  also drops the space above a block that a page break moves. */
@@ -19,6 +19,26 @@ body {
19
19
  background: #fff;
20
20
  }
21
21
 
22
+ /* A PDF can't be clicked, so a collapsed section prints open, its summary kept with what follows. A
23
+ section that ends a quote, callout, table cell, or the last item of a list inside one of those or another
24
+ list, gives up the space below it, and so do the sections and last block inside it, up to three sections
25
+ deep, so none shows inside. */
26
+ .markdown-body :is(blockquote, .markdown-alert, td, th, :is(blockquote, .markdown-alert, td, th, li) :is(ul, ol) > li:last-child) > details:last-child,
27
+ .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,
28
+ .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,
29
+ .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 {
30
+ margin-bottom: 0;
31
+ }
32
+ .markdown-body details::details-content {
33
+ content-visibility: visible;
34
+ }
35
+ .markdown-body details:not([open]) > summary {
36
+ list-style-type: disclosure-open;
37
+ }
38
+ .markdown-body details > summary {
39
+ break-after: avoid;
40
+ }
41
+
22
42
  .markdown-body {
23
43
  max-width: none;
24
44
  margin: 0;
@@ -28,6 +28,30 @@ body {
28
28
  background: #fff;
29
29
  }
30
30
 
31
+ /* A PDF can't be clicked, so a collapsed section prints open, its summary kept with what follows. After it
32
+ comes a paragraph's space, or its last block's if that is more. A section that ends a quote, callout,
33
+ table cell, or the last item of a list inside one of those or another list, gives up that space, and so
34
+ do the sections and last block inside it, up to three sections deep, so none shows inside; at the end of
35
+ a nested list, the next item is then an item's space away, as after text. */
36
+ .markdown-body details {
37
+ margin-bottom: calc(0.75em * var(--md2pdf-space));
38
+ }
39
+ .markdown-body :is(blockquote, .markdown-alert, td, th, :is(blockquote, .markdown-alert, td, th, li) :is(ul, ol) > li:last-child) > details:last-child,
40
+ .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,
41
+ .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,
42
+ .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 {
43
+ margin-bottom: 0;
44
+ }
45
+ .markdown-body details::details-content {
46
+ content-visibility: visible;
47
+ }
48
+ .markdown-body details:not([open]) > summary {
49
+ list-style-type: disclosure-open;
50
+ }
51
+ .markdown-body details > summary {
52
+ break-after: avoid;
53
+ }
54
+
31
55
  /* Nothing follows the document's last block, so Safari keeps no space below it: it starts a blank
32
56
  page for that space when it runs past the end of a page. Only Safari, since Chrome's margin-trim
33
57
  also drops the space above a block that a page break moves. */
@@ -29,6 +29,30 @@ body {
29
29
  background: #fff;
30
30
  }
31
31
 
32
+ /* A PDF can't be clicked, so a collapsed section prints open, its summary kept with what follows. After it
33
+ comes a paragraph's space, or its last block's if that is more. A section that ends a quote, callout,
34
+ table cell, or the last item of a list inside one of those or another list, gives up that space, and so
35
+ do the sections and last block inside it, up to three sections deep, so none shows inside; at the end of
36
+ a nested list, the next item is then an item's space away, as after text. */
37
+ .markdown-body details {
38
+ margin-bottom: calc(1em * var(--md2pdf-space));
39
+ }
40
+ .markdown-body :is(blockquote, .markdown-alert, td, th, :is(blockquote, .markdown-alert, td, th, li) :is(ul, ol) > li:last-child) > details:last-child,
41
+ .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,
42
+ .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,
43
+ .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 {
44
+ margin-bottom: 0;
45
+ }
46
+ .markdown-body details::details-content {
47
+ content-visibility: visible;
48
+ }
49
+ .markdown-body details:not([open]) > summary {
50
+ list-style-type: disclosure-open;
51
+ }
52
+ .markdown-body details > summary {
53
+ break-after: avoid;
54
+ }
55
+
32
56
  /* Nothing follows the document's last block, so Safari keeps no space below it: it starts a blank
33
57
  page for that space when it runs past the end of a page. Only Safari, since Chrome's margin-trim
34
58
  also drops the space above a block that a page break moves. */
@@ -59,6 +59,30 @@ body {
59
59
  background: #fff;
60
60
  }
61
61
 
62
+ /* A PDF can't be clicked, so a collapsed section prints open, its summary kept with what follows. After it
63
+ comes a paragraph's space, or its last block's if that is more. A section that ends a quote, callout,
64
+ table cell, or the last item of a list inside one of those or another list, gives up that space, and so
65
+ do the sections and last block inside it, up to three sections deep, so none shows inside; at the end of
66
+ a nested list, the next item is then an item's space away, as after text. */
67
+ .markdown-body details {
68
+ margin-bottom: calc(0.8em * var(--md2pdf-space));
69
+ }
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,
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 > :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 > :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 > details:last-child > details:last-child > :last-child {
74
+ margin-bottom: 0;
75
+ }
76
+ .markdown-body details::details-content {
77
+ content-visibility: visible;
78
+ }
79
+ .markdown-body details:not([open]) > summary {
80
+ list-style-type: disclosure-open;
81
+ }
82
+ .markdown-body details > summary {
83
+ break-after: avoid;
84
+ }
85
+
62
86
  /* Nothing follows the document's last block, so Safari keeps no space below it: it starts a blank
63
87
  page for that space when it runs past the end of a page. Only Safari, since Chrome's margin-trim
64
88
  also drops the space above a block that a page break moves. */
@@ -18,6 +18,30 @@ body {
18
18
  background: #fff;
19
19
  }
20
20
 
21
+ /* A PDF can't be clicked, so a collapsed section prints open, its summary kept with what follows. After it
22
+ comes a paragraph's space, or its last block's if that is more. A section that ends a quote, callout,
23
+ table cell, or the last item of a list inside one of those or another list, gives up that space, and so
24
+ do the sections and last block inside it, up to three sections deep, so none shows inside; at the end of
25
+ a nested list, the next item is then an item's space away, as after text. */
26
+ .markdown-body details {
27
+ margin-bottom: calc(0.45em * var(--md2pdf-space));
28
+ }
29
+ .markdown-body :is(blockquote, .markdown-alert, td, th, :is(blockquote, .markdown-alert, td, th, li) :is(ul, ol) > li:last-child) > details:last-child,
30
+ .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,
31
+ .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,
32
+ .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 {
33
+ margin-bottom: 0;
34
+ }
35
+ .markdown-body details::details-content {
36
+ content-visibility: visible;
37
+ }
38
+ .markdown-body details:not([open]) > summary {
39
+ list-style-type: disclosure-open;
40
+ }
41
+ .markdown-body details > summary {
42
+ break-after: avoid;
43
+ }
44
+
21
45
  /* Nothing follows the document's last block, so Safari keeps no space below it: it starts a blank
22
46
  page for that space when it runs past the end of a page. Only Safari, since Chrome's margin-trim
23
47
  also drops the space above a block that a page break moves. */
@@ -46,6 +46,30 @@ body {
46
46
  background: #fff;
47
47
  }
48
48
 
49
+ /* A PDF can't be clicked, so a collapsed section prints open, its summary kept with what follows. After it
50
+ comes a paragraph's space, or its last block's if that is more. A section that ends a quote, callout,
51
+ table cell, or the last item of a list inside one of those or another list, gives up that space, and so
52
+ do the sections and last block inside it, up to three sections deep, so none shows inside; at the end of
53
+ a nested list, the next item is then an item's space away, as after text. */
54
+ .markdown-body details {
55
+ margin-bottom: calc(0.75em * var(--md2pdf-space));
56
+ }
57
+ .markdown-body :is(blockquote, .markdown-alert, td, th, :is(blockquote, .markdown-alert, td, th, li) :is(ul, ol) > li:last-child) > details:last-child,
58
+ .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,
59
+ .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,
60
+ .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 {
61
+ margin-bottom: 0;
62
+ }
63
+ .markdown-body details::details-content {
64
+ content-visibility: visible;
65
+ }
66
+ .markdown-body details:not([open]) > summary {
67
+ list-style-type: disclosure-open;
68
+ }
69
+ .markdown-body details > summary {
70
+ break-after: avoid;
71
+ }
72
+
49
73
  /* Nothing follows the document's last block, so Safari keeps no space below it: it starts a blank
50
74
  page for that space when it runs past the end of a page. Only Safari, since Chrome's margin-trim
51
75
  also drops the space above a block that a page break moves. */
@@ -29,6 +29,30 @@ body {
29
29
  background: #fff;
30
30
  }
31
31
 
32
+ /* A PDF can't be clicked, so a collapsed section prints open, its summary kept with what follows. After it
33
+ comes a paragraph's space, or its last block's if that is more. A section that ends a quote, callout,
34
+ table cell, or the last item of a list inside one of those or another list, gives up that space, and so
35
+ do the sections and last block inside it, up to three sections deep, so none shows inside; at the end of
36
+ a nested list, the next item is then an item's space away, as after text. */
37
+ .markdown-body details {
38
+ margin-bottom: calc(0.9em * var(--md2pdf-space));
39
+ }
40
+ .markdown-body :is(blockquote, .markdown-alert, td, th, :is(blockquote, .markdown-alert, td, th, li) :is(ul, ol) > li:last-child) > details:last-child,
41
+ .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,
42
+ .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,
43
+ .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 {
44
+ margin-bottom: 0;
45
+ }
46
+ .markdown-body details::details-content {
47
+ content-visibility: visible;
48
+ }
49
+ .markdown-body details:not([open]) > summary {
50
+ list-style-type: disclosure-open;
51
+ }
52
+ .markdown-body details > summary {
53
+ break-after: avoid;
54
+ }
55
+
32
56
  /* Nothing follows the document's last block, so Safari keeps no space below it: it starts a blank
33
57
  page for that space when it runs past the end of a page. Only Safari, since Chrome's margin-trim
34
58
  also drops the space above a block that a page break moves. */