Skip to content

Commit 11db6d8

Browse files
authored
Markup: PDF generation (#600)
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 f8b590c commit 11db6d8

32 files changed

+1561
-433
lines changed

PUBLISHING.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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: 15<sup>th</sup> 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 `--printable`. 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+
cp -R images out &&
17+
ecmarkup --assets external --assets-dir out --printable spec.html out/index.html
18+
```
19+
20+
Then, from your spec's working directory, run [`prince`](https://www.princexml.com/) to generate your PDF.
21+
22+
```shell
23+
cd path/to/spec
24+
prince --script ./node_modules/ecmarkup/js/print.js out/index.html -o path/to/output.pdf
25+
```
26+
27+
This has been extensively tested with Prince 15. Earlier and later editions not guaranteed.

css/elements.css

+37-23
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
}
@@ -159,7 +161,7 @@ span.e-user-code::before {
159161
vertical-align: middle;
160162
text-transform: uppercase;
161163
font-family:
162-
IBM Plex Sans,
164+
'IBM Plex Sans',
163165
sans-serif;
164166
font-weight: 900;
165167
font-size: x-small;
@@ -184,8 +186,8 @@ span.e-user-code::before {
184186
code {
185187
font-weight: bold;
186188
font-family:
187-
Comic Code,
188-
IBM Plex Mono,
189+
'Comic Code',
190+
'IBM Plex Mono',
189191
monospace;
190192
white-space: pre;
191193
}
@@ -256,7 +258,7 @@ var.referenced6 {
256258

257259
emu-const {
258260
font-family:
259-
IBM Plex Sans,
261+
'IBM Plex Sans',
260262
sans-serif;
261263
font-variant: small-caps;
262264
text-transform: uppercase;
@@ -458,7 +460,7 @@ emu-rhs emu-nt {
458460
emu-t {
459461
display: inline-block;
460462
font-family:
461-
IBM Plex Mono,
463+
'IBM Plex Mono',
462464
monospace;
463465
font-weight: bold;
464466
white-space: nowrap;
@@ -495,7 +497,7 @@ emu-params,
495497
emu-opt {
496498
margin-right: 1ex;
497499
font-family:
498-
IBM Plex Mono,
500+
'IBM Plex Mono',
499501
monospace;
500502
}
501503

@@ -511,7 +513,7 @@ emu-opt {
511513
emu-gprose {
512514
font-size: 0.9em;
513515
font-family:
514-
IBM Plex Sans,
516+
'IBM Plex Sans',
515517
sans-serif;
516518
}
517519

@@ -780,6 +782,10 @@ emu-table td {
780782
background: #fff;
781783
}
782784

785+
td[colspan]:not([colspan="1"]), th[colspan]:not([colspan="1"]) {
786+
text-align: center;
787+
}
788+
783789
/* Note: the left content edges of table.lightweight-table >tbody >tr >td
784790
and div.display line up. */
785791
table.lightweight-table {
@@ -925,7 +931,7 @@ tr.del > td {
925931
height: 18px;
926932
font-size: 12px;
927933
margin: 0 5px 0 10px;
928-
font-family: IBM Plex Sans;
934+
font-family: 'IBM Plex Sans', sans-serif;
929935
}
930936
#menu-pins .unpin-all:hover {
931937
background: #ddd;
@@ -950,7 +956,7 @@ tr.del > td {
950956
align-self: center;
951957
}
952958

953-
#menu-pins-list > li:before,
959+
#menu-pins-list > li::before,
954960
#menu-pins-list > li > .unpin {
955961
flex-shrink: 0;
956962
flex-grow: 0;
@@ -960,7 +966,7 @@ tr.del > td {
960966
background: none;
961967
border: none;
962968
}
963-
#menu-pins-list > li:before,
969+
#menu-pins-list > li::before,
964970
#menu-pins-list > li > .unpin:hover {
965971
background: #ccc;
966972
}
@@ -974,7 +980,7 @@ tr.del > td {
974980
color: #bb1212;
975981
}
976982

977-
#menu-pins-list > li:before {
983+
#menu-pins-list > li::before {
978984
content: counter(pins-counter);
979985
counter-increment: pins-counter;
980986
font-size: 16px;
@@ -1152,7 +1158,7 @@ a.menu-pane-header-production {
11521158
overflow-y: auto;
11531159
}
11541160

1155-
li.menu-search-result-clause:before {
1161+
li.menu-search-result-clause::before {
11561162
content: 'clause';
11571163
width: 40px;
11581164
display: inline-block;
@@ -1161,7 +1167,7 @@ li.menu-search-result-clause:before {
11611167
color: #666;
11621168
font-size: 75%;
11631169
}
1164-
li.menu-search-result-op:before {
1170+
li.menu-search-result-op::before {
11651171
content: 'op';
11661172
width: 40px;
11671173
display: inline-block;
@@ -1171,7 +1177,7 @@ li.menu-search-result-op:before {
11711177
font-size: 75%;
11721178
}
11731179

1174-
li.menu-search-result-prod:before {
1180+
li.menu-search-result-prod::before {
11751181
content: 'prod';
11761182
width: 40px;
11771183
display: inline-block;
@@ -1181,7 +1187,7 @@ li.menu-search-result-prod:before {
11811187
font-size: 75%;
11821188
}
11831189

1184-
li.menu-search-result-term:before {
1190+
li.menu-search-result-term::before {
11851191
content: 'term';
11861192
width: 40px;
11871193
display: inline-block;
@@ -1211,10 +1217,10 @@ li.menu-search-result-term:before {
12111217
white-space: nowrap;
12121218
}
12131219

1214-
#menu-trace-list li .secnum:after {
1220+
#menu-trace-list li .secnum::after {
12151221
content: ' ';
12161222
}
1217-
#menu-trace-list li:before {
1223+
#menu-trace-list li::before {
12181224
content: counter(item) ' ';
12191225
background-color: #222;
12201226
counter-increment: item;
@@ -1301,8 +1307,8 @@ li.menu-search-result-term:before {
13011307
text-decoration: underline;
13021308
}
13031309

1304-
.toolbox:after,
1305-
.toolbox:before {
1310+
.toolbox::after,
1311+
.toolbox::before {
13061312
top: 100%;
13071313
left: 15px;
13081314
border: solid transparent;
@@ -1313,13 +1319,13 @@ li.menu-search-result-term:before {
13131319
pointer-events: none;
13141320
}
13151321

1316-
.toolbox:after {
1322+
.toolbox::after {
13171323
border-color: rgba(0, 0, 0, 0);
13181324
border-top-color: #ddd;
13191325
border-width: 10px;
13201326
margin-left: -10px;
13211327
}
1322-
.toolbox:before {
1328+
.toolbox::before {
13231329
border-color: rgba(204, 204, 204, 0);
13241330
border-top-color: #aaa;
13251331
border-width: 12px;
@@ -1358,7 +1364,7 @@ li.menu-search-result-term:before {
13581364
display: flex;
13591365
}
13601366

1361-
#references-pane-close:after {
1367+
#references-pane-close::after {
13621368
content: '\2716';
13631369
float: right;
13641370
cursor: pointer;
@@ -1373,10 +1379,18 @@ li.menu-search-result-term:before {
13731379
padding-right: 5px;
13741380
}
13751381

1382+
emu-normative-optional::before {
1383+
display: block;
1384+
color: #884400;
1385+
content: "NORMATIVE OPTIONAL";
1386+
}
1387+
1388+
emu-normative-optional,
13761389
[normative-optional],
13771390
[deprecated],
13781391
[legacy] {
13791392
border-left: 5px solid #ff6600;
1393+
display: block;
13801394
padding: 0.5em;
13811395
background: #ffeedd;
13821396
}

0 commit comments

Comments
 (0)