Skip to content

Commit 17d9c1d

Browse files
committed
inline the print css
1 parent fe558e2 commit 17d9c1d

File tree

4 files changed

+145
-104
lines changed

4 files changed

+145
-104
lines changed

PUBLISHING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ version: 15th Edition
99
date: 2024-06-25
1010
```
1111

12-
Use the package script `build-for-pdf`. Importantly, you want to make sure your image directory and print.css file wind up in the same output directory as your markup, i.e. your `ecmarkup` command should include the options `--assets external`, `--assets-dir out`, and `--old-toc`.
12+
Use the package script `build-for-pdf`. Importantly, you want to make sure your image directory files wind up in the same output directory as your markup. Your `ecmarkup` command should include the options `--assets external`, `--assets-dir out`, and `--printable`.
1313

1414
Then, run `prince` to generate your PDF.
1515

1616
```shell
1717
prince --script ./node_modules/ecmarkup/js/print.js out/index.html -o path/to/output.pdf
1818
```
1919

20-
Spend 5-10 minutes double-checking the PDF for egregious layout issues. That means quickly skimming all 800+ pages looking for whitespace or content split in a confusing manner. Tinker with `print.css` only as needed. Compare cover & table of contents to previous years.
20+
Spend 5-10 minutes double-checking the PDF for egregious layout issues. That means quickly skimming all 800+ pages looking for whitespace or content split in a confusing manner. Tinker with print-only styles only as needed. Compare cover & table of contents to previous years.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"prebuild-only": "npm run clean && mkdir out && cp -R img out",
1010
"build-only": "ecmarkup --verbose spec.html --multipage out",
1111
"build": "npm run build-head",
12-
"build-for-pdf": "npm run prebuild-only && cp print.css out && ecmarkup --verbose spec.html out/index.html --assets external --assets-dir out --old-toc --lint-spec --strict",
12+
"build-for-pdf": "npm run prebuild-only && ecmarkup --verbose spec.html out/index.html --assets external --assets-dir out --old-toc --lint-spec --strict",
1313
"pdf": "npm run build-for-pdf && prince --script ./node_modules/ecmarkup/js/print.js out/index.html -o out/ECMA-262.pdf",
1414
"prebuild-snapshot": "npm run clean",
1515
"build-snapshot": "npm run build-head && node scripts/insert_snapshot_warning.js",

print.css

Lines changed: 0 additions & 100 deletions
This file was deleted.

spec.html

Lines changed: 142 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,150 @@
88
width: 100%;
99
font-size: 80%;
1010
}
11+
12+
#metadata-block {
13+
margin: 4em 0;
14+
padding: 10px;
15+
border: 1px solid #ee8421;
16+
}
17+
#metadata-block h1 {
18+
font-size: 1.5em;
19+
margin-top: 0;
20+
}
21+
#metadata-block > ul {
22+
list-style-type: none;
23+
margin: 0; padding: 0;
24+
}
25+
26+
#ecma-logo {
27+
width: 500px;
28+
}
29+
30+
.corner-cell {
31+
position: relative;
32+
height: 2lh;
33+
}
34+
.corner-cell .slash {
35+
position: absolute;
36+
top: 0;
37+
left: 0;
38+
width: 100%;
39+
height: 100%;
40+
background: linear-gradient(to bottom left, transparent calc(50% - 1px), gray, transparent calc(50% + 1px));
41+
}
42+
.corner-cell > .column {
43+
position: absolute;
44+
bottom: 0.4em;
45+
left: 1em;
46+
}
47+
.corner-cell > .row {
48+
position: absolute;
49+
top: 0.4em;
50+
right: 1em;
51+
}
1152
</style>
12-
<link rel="stylesheet" href="./print.css" media="print">
1353
<style media="print">
54+
/**
55+
* ECMA-262-specific hacks. Shouldn't require a ton of maintenance; audit if
56+
* visual inspection results in unexpected page breaks.
57+
*/
58+
/* 2.2 Examples of legacy/normative-optional are small enough to be aggressive against breaks */
59+
#sec-conformance [example],
60+
61+
/* 8.3.3 avoid breaking in small alg lists */
62+
#sec-static-semantics-containsundefinedcontinuetarget li,
63+
64+
/* 16.2.1.5.4 many tables */
65+
#table-module-graph-cycle-async-fields-1 table,
66+
#table-module-graph-cycle-async-fields-9 table {
67+
break-inside: avoid-page;
68+
}
69+
70+
/* 12.10.1 long note can break wherever it wants */
71+
#sec-rules-of-automatic-semicolon-insertion > emu-note {
72+
break-before: initial;
73+
break-inside: initial;
74+
}
75+
76+
/* 12.10.2, 12.10.3, 12.10.3.2 Sections start with an <em> not inside a <p> */
77+
#sec-examples-of-automatic-semicolon-insertion > em,
78+
#sec-interesting-cases-of-automatic-semicolon-insertion > em,
79+
#sec-asi-cases-with-no-lineterminator-here > em {
80+
display: block;
81+
margin-top: 1.25ex;
82+
}
83+
84+
/* 15.1.2 bad spacing between intro and first emu-grammar */
85+
#sec-static-semantics-containsexpression > emu-grammar:first-of-type {
86+
margin-top: 2ex;
87+
}
88+
89+
/* 15.3 A very long term combined with inline-block, nowrap, and justified text resulting in weird punctuation */
90+
#sec-arrow-function-definitions > p > emu-grammar {
91+
text-align: left;
92+
}
93+
94+
/* 16.2.1.5.4 squish margins on graphics so table 46 fits on one page */
95+
#sec-example-cyclic-module-record-graphs figure:has(> img),
96+
#sec-example-cyclic-module-record-graphs figure > img {
97+
margin: 0;
98+
}
99+
#sec-example-cyclic-module-record-graphs figure:has(> img) > figcaption {
100+
margin-bottom: 1ex;
101+
}
102+
#sec-example-cyclic-module-record-graphs emu-figure:has(> figure > img) + p {
103+
margin-top: 1ex;
104+
}
105+
106+
/* 16.2.1.5.4 table 51 & 54 are too narrow for caption */
107+
#table-module-graph-cycle-async-fields-6 table {
108+
width: 110mm;
109+
}
110+
#table-module-graph-cycle-async-fields-9 table {
111+
width: 135mm;
112+
}
113+
114+
/* 20.1.3.7 legacy title */
115+
#sec-object\.prototype\.__proto__ > .attributes-tag {
116+
break-before: avoid-page;
117+
break-after: avoid-page;
118+
}
119+
120+
/* 21.4.1.22 Table 61 middle column is too narrow */
121+
#table-time-zone-identifier-record-fields > figure > table th:nth-of-type(2) {
122+
width: 15%;
123+
}
124+
125+
/* 21.4.4.41.2 These tables are way too narrow for their captions */
126+
#sec-todatestring-day-names table,
127+
#sec-todatestring-month-names table {
128+
width: 100mm;
129+
}
130+
131+
/* 27.2.6 squeeze to make more room for figure-2.svg */
132+
#table-internal-slots-of-promise-instances > figure {
133+
margin-bottom: 0;
134+
}
135+
136+
/* 27.3 fit generator objects relationships diagram */
137+
#sec-generatorfunction-objects,
138+
#sec-generatorfunction-objects h1 {
139+
margin-top: 1.5ex;
140+
}
141+
142+
/* 27.3 `figure-2.svg` is just a tiny bit too big to fit on the page, results in weird white space */
143+
#figure-2 figure {
144+
margin: 1ex 0;
145+
}
146+
#figure-2 > figure > img {
147+
width: 97%;
148+
}
149+
150+
/* 29.11 extremely long note */
151+
#sec-shared-memory-guidelines > emu-note {
152+
break-inside: auto;
153+
}
154+
14155
.unicode-property-table {
15156
table-layout: initial;
16157
width: auto;

0 commit comments

Comments
 (0)