-
Notifications
You must be signed in to change notification settings - Fork 513
/
Copy pathreference.css
455 lines (404 loc) · 11.3 KB
/
reference.css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
/* Custom CSS for the Rust Specification. */
/*
.parenthetical class used to keep e.g. "less-than symbol (<)" from wrapping
the end parenthesis onto its own line. Use in a span between the last word and
the parenthetical. So for this example, you'd use
```less-than <span class="parenthetical">symbol (`<`)</span>```
*/
.parenthetical {
white-space: nowrap;
}
/*
Warnings are defined using admonitions in blockquotes:
> [!WARNING]
> This is bad!
*/
main .warning blockquote {
padding: 0px;
}
main .warning blockquote p {
padding: 0px 20px;
margin: 10px 0;
}
main .warning blockquote p:first-child::before {
content: "⚠️ ";
}
.light main .warning blockquote,
.rust main .warning blockquote {
border: 2px solid red;
background: #ffcece;
}
.rust main .warning blockquote {
/* overrides previous declaration */
border-color: #961717;
}
.coal main .warning blockquote,
.navy main .warning blockquote,
.ayu main .warning blockquote {
background: #542626;
}
/* Make the links higher contrast on dark themes */
.coal main .warning blockquote p a,
.navy main .warning blockquote p a,
.ayu main .warning blockquote p a {
color: #80d0d0;
}
/* <kbd> tags can be used to highlight specific character elements. */
kbd {
border: 1px solid #999;
display: inline-block;
border-radius: 3px;
padding: 0 0.6ex;
background: #eee;
box-shadow: inset -1px -1px 0 #999;
vertical-align: baseline;
color: #000;
height: 1.55em;
font-style: normal;
font-weight: bold;
font-family: inherit;
font-size: revert;
line-height: revert;
}
kbd.optional {
border-style: dashed;
background: #fff;
}
var.optional {
border-style: dashed;
}
/* <var> tags can be used for non-terminals. */
var {
border: 1px solid #9c9;
box-shadow: inset -1px -1px 0 #9c9;
font-style: normal;
display: inline-block;
vertical-align: baseline;
border-radius: 7px;
padding: 0 4px;
background: #dfd;
margin: 2px;
}
var.type {
box-shadow: inset -1px -1px 0 #c99;
border-color: #c99;
background: #fdd;
}
/* <span class="repeat"> can be used for a grammar production that repeats zero or more times. */
span.repeat {
position: relative;
border: 1px dashed #393;
border-radius: 10px;
display: inline-block;
padding: 6px;
margin-left: 0.5ex;
margin-top: 1em;
margin-bottom: 0.5ex;
min-width: 3.8em;
text-align: center;
}
span.repeat::before {
content: "zero or more";
white-space: nowrap;
display: block;
text-align: center;
font-size: 0.75em;
position: absolute;
left: 0;
right: 0;
top: -1.4em;
color: #393;
}
var > span {
display: inline-block;
border-right: 1px dotted green;
padding-right: 0.5ex;
margin-right: 0.5ex;
font-style: italic;
}
/* <span class="version"> can be used to highlight a specific version of Rust. */
span.version {
float: right;
margin-left: 1em;
margin-bottom: 1em;
background: #f7c0eb;
padding: 0.2ex 0.5ex;
border-radius: 5px;
display: block;
box-shadow: inset -1px -1px 0 #a06894;
font-size: 0.9em;
}
/* <dfn> tags are used to indicate a specific word or phrase is being defined. */
dfn {
font-style: italic;
text-decoration: underline;
}
.content main {
/* Provides space on the left for the rule call-outs. */
padding-left: 4em;
}
/* Rules are generated via r[foo.bar] syntax, processed by mdbook-spec. */
.rule {
--font-size-mult: 0.8;
--font-size: calc(1em * var(--font-size-mult));
font-size: var(--font-size);
}
/* included in the grid below as 20px */
.page, .content {
padding-left: 0;
padding-right: 0;
}
/* required to accomodate above, somehow... */
#menu-bar {
margin-left: 0;
}
main {
/* To nicely display rules (`[a.b.c]`) on a side of the main text body we
use grid layout. */
display: grid;
grid-template-columns:
/* Left margin / place for rules */
[rules] minmax(20px, 1fr)
/* The main text body */
[text] auto
/* Right margin */
[margin] minmax(20px, 1fr);
/* We do these by hand via the grid */
margin: 0;
padding: 0 !important;
max-width: none !important;
}
main > * {
/* By default grid items can't be smaller than their content.
That is, by default `min-width: auto`.
We want to be able to force code blocks to be scrollable,
so we need to overwrite `min-width`. */
min-width: 0;
max-width: var(--content-max-width);
/* All elements should be in the main text body... */
grid-column: text;
}
main > .rule {
/* ... except the rules, which must be in the left margin */
grid-column: rules;
}
/* Unset footnote margin,
see below for more information about margins */
/* FIXME: this doesn't work. `unset` can still break the margin of the next element,
and since mdbook applies the margin to `:not(.footnore-definition)`,
it can literally be anything, so there is no way to properly fix it,
without changing mdbook... */
:not(.footnote-definition) + .footnote-definition,
.footnote-definition + :not(.footnote-definition) {
margin-block-start: unset;
}
:not(.footnote-definition) + .footnote-definition {
margin-top: calc(2em - 16px);
}
.footnote-definition:has(+ :not(.footnote-definition)) {
margin-bottom: calc(2em - 16px);
}
/* This is quite dumb, ugh.
CSS doesn't allow margin colapsing between grid items and anything else
(src: <https://stackoverflow.com/a/37837971>), which means that the margins
of li's children are not collapsed with ul's margins, adding too much margins.
Ideally we'd add `<div>`s for each grid cell, so that margin collapsing happens
as-usual inside of them. But, we don't have that kind of control over mdbook. */
main > ul > li > *:first-child,
main > ul > li > pre:first-child > pre.playground {
margin-top: 0;
}
main > ul > li > *:last-child,
main > ul > li > pre:last-child > pre.playground {
margin-bottom: 0;
}
/* Similarly to the above, margin collapse doesn't happen between grid items,
so we have to replace it with grid gap. (p, pre, and ul had 16px vertical margins) */
main {
row-gap: 16px;
}
main > p,
main > pre,
main > pre > pre.playground,
main > ul {
margin-top: 0;
margin-bottom: 0;
}
/* Values for header margin-top and blockquote margin are taken from mdbook's general.css,
values for header margin-bottom are taken from <https://www.w3schools.com/cssref/css_default_values.php> */
main > h2 {
margin-top: calc(2.5em - 16px);
margin-bottom: calc(0.83em - 16px);
}
main > h3 {
margin-top: calc(2.5em - 16px);
margin-bottom: calc(1em - 16px);
}
main > h4 {
margin-top: calc(2em - 16px);
margin-bottom: calc(1.33em - 16px);
}
main > h5 {
margin-top: calc(2em - 16px);
margin-bottom: calc(1.67em - 16px);
}
main > h6 {
margin-top: calc(2em - 16px);
margin-bottom: calc(2.33em - 16px);
}
main > blockquote {
margin-top: calc(20px - 16px);
margin-bottom: calc(20px - 16px);
}
main > .rule {
max-width: unset;
justify-self: right;
width: 100%;
/* We use a container query to know the size of the "left margin",
so that we can hide rules is there is not enough space. */
container-type: inline-size;
container-name: rule;
}
.rule-link {
float: right;
text-align: right;
padding-right: 10px;
/* We add `<wbr>` ourselves and only want breaks there */
word-break: keep-all;
/* Remove the blue coloring of links on rules that mdbook normally sets. */
color: #999 !important;
}
/* When clicking a rule, it is added as a URL fragment and the browser will
navigate to it. This adds an indicator that the linked rule is the one that
is "current", just like normal headers are in mdbook.
*/
.rule:target a::before {
display: inline-block;
content: "»";
padding-right: 5px;
}
/* Dodge » from headings */
.rule:has(+ h1:target),
.rule:has(+ h2:target),
.rule:has(+ h3:target),
.rule:has(+ h4:target),
.rule:has(+ h5:target),
.rule:has(+ h6:target) {
padding-right: 24px;
}
/* Hide the rules if the width of the container is too small.
The cutoff point is chosen semi-arbitrary, it felt that
when `width < 14em`, there are too many breaks. */
@container rule (width < 14em) {
main > .rule a span {
display: none;
}
main > .rule a::before {
content: "[*]";
}
}
/* Align rules to various siblings */
.rule:has(+ p),
.rule:has(+ ul) {
margin-top: calc((1em - var(--font-size)) / var(--font-size-mult) / 2);
}
.rule:has(+ h1) {
align-self: center;
}
.rule:has(+ h2) {
/* multiplying by this turns h2's em into .rule's em*/
--h2-em-mult: calc(
(1 / var(--font-size-mult)) /* to main font size */
* 1.5 /* to h2 font size */
);
margin-top: calc(
/* h2 margin top */
2.5em * var(--h2-em-mult) - 16px
/* half of the font size difference */
+ (1em * var(--h2-em-mult) - 1em) / 2
)
}
.rule:has(+ h3) {
/* multiplying by this turns h3's em into .rule's em*/
--h3-em-mult: calc(
(1 / var(--font-size-mult)) /* to main font size */
* 1.17 /* to h3 font size */
);
margin-top: calc(
/* h3 margin top */
2.5em * var(--h3-em-mult) - 16px
/* half of the font size difference */
+ (1em * var(--h3-em-mult) - 1em) / 2
)
}
.rule:has(+ h4) {
/* multiplying by this turns h4's em into .rule's em*/
--h4-em-mult: calc(
(1 / var(--font-size-mult)) /* to main font size */
* 1 /* to h4 font size */
);
margin-top: calc(
/* h4 margin top */
2em * var(--h4-em-mult) - 16px
/* half of the font size difference */
+ (1em * var(--h4-em-mult) - 1em) / 2
)
}
.rule:has(+ h5) {
/* multiplying by this turns h5's em into .rule's em*/
--h5-em-mult: calc(
(1 / var(--font-size-mult)) /* to main font size */
* 0.83 /* to h5 font size */
);
margin-top: calc(
/* h5 margin top */
2em * var(--h5-em-mult) - 16px
/* half of the font size difference */
+ (1em * var(--h5-em-mult) - 1em) / 2
)
}
.rule:has(+ h6) {
/* multiplying by this turns h6's em into .rule's em*/
--h6-em-mult: calc(
(1 / var(--font-size-mult)) /* to main font size */
* 0.67 /* to h6 font size */
);
margin-top: calc(
/* h6 margin top */
2em * var(--h6-em-mult) - 16px
/* half of the font size difference */
+ (1em * var(--h6-em-mult) - 1em) / 2
)
}
/* Sets the color for [!HISTORY] blockquote admonitions. */
.history > blockquote {
background: #f7c0eb;
}
/* Provides a anchor container for positioning popups. */
.popup-container {
position: relative;
}
/* In the test summary page, a convenience class for toggling visibility. */
.popup-hidden {
display: none;
}
/* In the test summary page, the styling for the uncovered rule popup. */
.uncovered-rules-popup {
position: absolute;
left: -250px;
width: 400px;
background: var(--bg);
border-radius: 4px;
border: 1px solid;
z-index: 1000;
padding: 1rem;
}
/* The popup that shows when viewing tests for a specific rule. */
.tests-popup {
color: var(--fg);
background: var(--bg);
border-radius: 4px;
border: 1px solid;
z-index: 1000;
padding: 1rem;
}