Skip to content

Commit 1b8a4f3

Browse files
committed
Markup: PDF generation
Tried to keep the css together but it doesn't feel super logically grouped so I wound up rearranging everything. Sorry future git-blamer. Units of measurements are all over the place, here's what defines them: - mm for page-related units - pt for text-related units - em for horizontal units - ex for vertical units Highly specific rules come from a loyalty to the Ecma specification template first, previous years' standards second. There should be no changes that impact screen rendering; changes to the primary stylesheet come from inline styles that existed in both ECMA-262 and ECMA-402. - Remove print css from Spec file - Remove styles from inline assets test - Add publishing instructions - Small tweaks to allow ecmarkup to generate print-friendly PDFs beyond just 262 & 402 - Use font-face to make sure all the characters are rendered as we wish, including 0 with slash, double-stroke F, and infinity - Dynamically generate PDF covers based on frontmatter (TODO: Ecma-endorsed proposal cover?) - Make sure year is being properly inserted into footers
1 parent 1a619b2 commit 1b8a4f3

File tree

9 files changed

+1650
-295
lines changed

9 files changed

+1650
-295
lines changed

PUBLISHING.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Generating a PDF from ecmarkup
2+
3+
In order to produce a PDF, the front matter `title`, `shortname`, `version`, and `date` are **mandatory**. If generating a final annual edition, date should reflect the date of the Ecma GA which will ratify the Standard. For example:
4+
5+
```
6+
title: ECMAScript® 2024 Language Specification
7+
shortname: ECMA-262
8+
version: 15th Edition
9+
date: 2024-06-25
10+
```
11+
12+
To generate markup for use in PDF conversion, make sure to include the options `--assets`, `--assets-dir`, and `--old-toc`. If you have images and styles to include, make sure to move them into your assets directory before running `ecmarkup`. For example:
13+
14+
```shell
15+
mkdir -p out &&
16+
mv images out &&
17+
mv print.css out &&
18+
ecmarkup --assets external --assets-dir out --old-toc spec.html out/index.html
19+
```
20+
21+
Then, from your spec's working directory, run [`prince`](https://www.princexml.com/) to generate your PDF.
22+
23+
```shell
24+
cd path/to/spec
25+
prince --script ./node_modules/ecmarkup/js/print.js out/index.html -o path/to/output.pdf
26+
```
27+
28+
This has been extensively tested with Prince 15. Earlier and later editions not guaranteed.

css/elements.css

Lines changed: 62 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ body {
100100
font-size: 18px;
101101
line-height: 1.5;
102102
font-family:
103-
IBM Plex Serif,
103+
'IBM Plex Serif',
104104
serif;
105105
font-variant-numeric: slashed-zero;
106106
padding: 0;
@@ -119,6 +119,8 @@ body {
119119
padding-bottom: 1em;
120120
}
121121

122+
h1.shortname { display: none; }
123+
122124
body.oldtoc {
123125
margin: 0 auto;
124126
}
@@ -158,7 +160,7 @@ span.e-user-code::before {
158160
vertical-align: middle;
159161
text-transform: uppercase;
160162
font-family:
161-
IBM Plex Sans,
163+
'IBM Plex Sans',
162164
sans-serif;
163165
font-weight: 900;
164166
font-size: x-small;
@@ -183,8 +185,8 @@ span.e-user-code::before {
183185
code {
184186
font-weight: bold;
185187
font-family:
186-
Comic Code,
187-
IBM Plex Mono,
188+
'Comic Code',
189+
'IBM Plex Mono',
188190
monospace;
189191
white-space: pre;
190192
}
@@ -251,7 +253,7 @@ var.referenced6 {
251253

252254
emu-const {
253255
font-family:
254-
IBM Plex Sans,
256+
'IBM Plex Sans',
255257
sans-serif;
256258
font-variant: small-caps;
257259
text-transform: uppercase;
@@ -453,7 +455,7 @@ emu-rhs emu-nt {
453455
emu-t {
454456
display: inline-block;
455457
font-family:
456-
IBM Plex Mono,
458+
'IBM Plex Mono',
457459
monospace;
458460
font-weight: bold;
459461
white-space: nowrap;
@@ -490,7 +492,7 @@ emu-params,
490492
emu-opt {
491493
margin-right: 1ex;
492494
font-family:
493-
IBM Plex Mono,
495+
'IBM Plex Mono',
494496
monospace;
495497
}
496498

@@ -506,7 +508,7 @@ emu-opt {
506508
emu-gprose {
507509
font-size: 0.9em;
508510
font-family:
509-
IBM Plex Sans,
511+
'IBM Plex Sans',
510512
sans-serif;
511513
}
512514

@@ -775,6 +777,10 @@ emu-table td {
775777
background: #fff;
776778
}
777779

780+
th[colspan], td[colspan] {
781+
text-align: center;
782+
}
783+
778784
/* Note: the left content edges of table.lightweight-table >tbody >tr >td
779785
and div.display line up. */
780786
table.lightweight-table {
@@ -920,7 +926,7 @@ tr.del > td {
920926
height: 18px;
921927
font-size: 12px;
922928
margin: 0 5px 0 10px;
923-
font-family: IBM Plex Sans;
929+
font-family: 'IBM Plex Sans', sans-serif;
924930
}
925931
#menu-pins .unpin-all:hover {
926932
background: #ddd;
@@ -945,7 +951,7 @@ tr.del > td {
945951
align-self: center;
946952
}
947953

948-
#menu-pins-list > li:before,
954+
#menu-pins-list > li::before,
949955
#menu-pins-list > li > .unpin {
950956
flex-shrink: 0;
951957
flex-grow: 0;
@@ -955,7 +961,7 @@ tr.del > td {
955961
background: none;
956962
border: none;
957963
}
958-
#menu-pins-list > li:before,
964+
#menu-pins-list > li::before,
959965
#menu-pins-list > li > .unpin:hover {
960966
background: #ccc;
961967
}
@@ -969,7 +975,7 @@ tr.del > td {
969975
color: #bb1212;
970976
}
971977

972-
#menu-pins-list > li:before {
978+
#menu-pins-list > li::before {
973979
content: counter(pins-counter);
974980
counter-increment: pins-counter;
975981
font-size: 16px;
@@ -1147,7 +1153,7 @@ a.menu-pane-header-production {
11471153
overflow-y: auto;
11481154
}
11491155

1150-
li.menu-search-result-clause:before {
1156+
li.menu-search-result-clause::before {
11511157
content: 'clause';
11521158
width: 40px;
11531159
display: inline-block;
@@ -1156,7 +1162,7 @@ li.menu-search-result-clause:before {
11561162
color: #666;
11571163
font-size: 75%;
11581164
}
1159-
li.menu-search-result-op:before {
1165+
li.menu-search-result-op::before {
11601166
content: 'op';
11611167
width: 40px;
11621168
display: inline-block;
@@ -1166,7 +1172,7 @@ li.menu-search-result-op:before {
11661172
font-size: 75%;
11671173
}
11681174

1169-
li.menu-search-result-prod:before {
1175+
li.menu-search-result-prod::before {
11701176
content: 'prod';
11711177
width: 40px;
11721178
display: inline-block;
@@ -1176,7 +1182,7 @@ li.menu-search-result-prod:before {
11761182
font-size: 75%;
11771183
}
11781184

1179-
li.menu-search-result-term:before {
1185+
li.menu-search-result-term::before {
11801186
content: 'term';
11811187
width: 40px;
11821188
display: inline-block;
@@ -1206,10 +1212,10 @@ li.menu-search-result-term:before {
12061212
white-space: nowrap;
12071213
}
12081214

1209-
#menu-trace-list li .secnum:after {
1215+
#menu-trace-list li .secnum::after {
12101216
content: ' ';
12111217
}
1212-
#menu-trace-list li:before {
1218+
#menu-trace-list li::before {
12131219
content: counter(item) ' ';
12141220
background-color: #222;
12151221
counter-increment: item;
@@ -1296,8 +1302,8 @@ li.menu-search-result-term:before {
12961302
text-decoration: underline;
12971303
}
12981304

1299-
.toolbox:after,
1300-
.toolbox:before {
1305+
.toolbox::after,
1306+
.toolbox::before {
13011307
top: 100%;
13021308
left: 15px;
13031309
border: solid transparent;
@@ -1308,13 +1314,13 @@ li.menu-search-result-term:before {
13081314
pointer-events: none;
13091315
}
13101316

1311-
.toolbox:after {
1317+
.toolbox::after {
13121318
border-color: rgba(0, 0, 0, 0);
13131319
border-top-color: #ddd;
13141320
border-width: 10px;
13151321
margin-left: -10px;
13161322
}
1317-
.toolbox:before {
1323+
.toolbox::before {
13181324
border-color: rgba(204, 204, 204, 0);
13191325
border-top-color: #aaa;
13201326
border-width: 12px;
@@ -1353,7 +1359,7 @@ li.menu-search-result-term:before {
13531359
display: flex;
13541360
}
13551361

1356-
#references-pane-close:after {
1362+
#references-pane-close::after {
13571363
content: '\2716';
13581364
float: right;
13591365
cursor: pointer;
@@ -1368,10 +1374,18 @@ li.menu-search-result-term:before {
13681374
padding-right: 5px;
13691375
}
13701376

1377+
emu-normative-optional::before {
1378+
display: block;
1379+
color: #884400;
1380+
content: "NORMATIVE OPTIONAL";
1381+
}
1382+
1383+
emu-normative-optional,
13711384
[normative-optional],
13721385
[deprecated],
13731386
[legacy] {
13741387
border-left: 5px solid #ff6600;
1388+
display: block;
13751389
padding: 0.5em;
13761390
background: #ffeedd;
13771391
}
@@ -1425,3 +1439,28 @@ li.menu-search-result-term:before {
14251439
background-color: #eee;
14261440
box-shadow: inset 0 -1px 0 #ccc;
14271441
}
1442+
1443+
#metadata-block {
1444+
margin: 4em 0;
1445+
padding: 10px;
1446+
border: 1px solid #ee8421;
1447+
}
1448+
1449+
#metadata-block h1 {
1450+
font-size: 1.5em;
1451+
margin-top: 0;
1452+
}
1453+
#metadata-block > ul {
1454+
list-style-type: none;
1455+
margin: 0; padding: 0;
1456+
}
1457+
1458+
#ecma-logo {
1459+
width: 500px;
1460+
}
1461+
1462+
.unicode-property-table {
1463+
table-layout: fixed;
1464+
width: 100%;
1465+
font-size: 80%;
1466+
}

0 commit comments

Comments
 (0)