-
Notifications
You must be signed in to change notification settings - Fork 531
/
Copy pathreference.css
711 lines (638 loc) · 18.1 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
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
/* 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;
}
/*
Admonitions are defined with blockquotes:
> [!WARNING]
> This is bad!
See mdbook-spec/src/lib.rs.
*/
.alert blockquote {
/* Add some padding to make the vertical bar a little taller than the text.*/
padding: 8px 0px 8px 20px;
/* Add a solid color bar on the left side. */
border-inline-start-style: solid;
border-inline-start-width: 4px;
/* Disable the background color from mdbook for a cleaner look. */
background-color: inherit;
/* Disable border blocks from mdbook. */
border-block-start: none;
border-block-end: none;
/* Reduce margin from mdbook, it uses a lot of space. */
margin: 10px 0;
}
.alert-title {
/* Slightly increase the weight for more emphasis. */
font-weight: 600;
/* Vertically center the icon with the text. */
display: flex;
align-items: center;
/* Remove default large margins for a more compact display.
Important to override .alert p rule. */
margin: 0 0 8px 0 !important;
}
.alert blockquote > :nth-child(2) {
/* Default margins of content just below the label add too much space. */
margin-top: 0;
}
.alert blockquote > :last-child {
/* Default margins of content add too much space. */
margin-bottom: 0;
}
.alert-title svg {
fill: currentColor;
/* Add some space between the icon and the text. */
margin-right: 8px;
}
.light .alert {
--alert-note-color: #0969da;
--alert-warning-color: #9a6700;
--alert-edition-color: #1a7f37;
}
.ayu .alert {
--alert-note-color: #74b9ff;
--alert-warning-color: #f0b72f;
--alert-edition-color: #2bd853;
}
.rust .alert {
--alert-note-color: #023b95;
--alert-warning-color: #603700;
--alert-edition-color: #008200;
}
.coal .alert,
.navy .alert {
--alert-note-color: #4493f8;
--alert-warning-color: #d29922;
--alert-edition-color: #3fb950;
}
.alert-note blockquote {
border-inline-start-color: var(--alert-note-color);
}
.alert-warning blockquote {
border-inline-start-color: var(--alert-warning-color);
}
.alert-edition blockquote {
border-inline-start-color: var(--alert-edition-color);
}
.alert-note .alert-title {
color: var(--alert-note-color);
}
.alert-warning .alert-title {
color: var(--alert-warning-color);
}
.alert-edition .alert-title {
color: var(--alert-edition-color);
}
/* Puts a rounded rectangle around the edition date. */
.alert-title-edition {
padding: 0px 5px;
margin-right: 1rem;
border: 2px solid var(--alert-edition-color);
border-radius: 15px;
font-weight: bold;
color: var(--alert-edition-color);
}
/* <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(36px, 1fr)
/* The main text body */
[text] auto
/* Right margin */
[margin] minmax(36px, 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;
}
hr {
/* For some reason, grid is shrinking this to a point. */
width: 100%;
}
/* Too much space with the grid.
*/
.footnote-definition {
margin-top: 0;
}
.footnote-definition li:first-child > *:first-child {
margin-top: 0;
}
/* 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> */
:root {
/* 1.6 is body font-size */
--h2-margin-top: calc(1.5rem * 1.6 * 2.5 - 16px);
--h3-margin-top: calc(1.17rem * 1.6 * 2.5 - 16px);
--h4-margin-top: calc(1.00rem * 1.6 * 2 - 16px);
--h5-margin-top: calc(0.83rem * 1.6 * 2 - 16px);
--h6-margin-top: calc(0.67rem * 1.6 * 2 - 16px);
}
main > h2 {
margin-top: var(--h2-margin-top);
margin-bottom: calc(0.83em - 16px);
}
main > h3 {
margin-top: var(--h3-margin-top);
margin-bottom: calc(1em - 16px);
}
main > h4 {
margin-top: var(--h4-margin-top);
margin-bottom: calc(1.33em - 16px);
}
main > h5 {
margin-top: var(--h5-margin-top);
margin-bottom: calc(1.67em - 16px);
}
main > h6 {
margin-top: var(--h6-margin-top);
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;
}
/* Test links */
.test-link {
float: right;
padding-right: 10px;
}
.rule .popup-container > a {
float: right;
text-align: right;
}
/* 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 .rule-link::before {
display: inline-block;
content: "»";
padding-right: 5px;
}
/* Dodge » from headings */
/* Note: Some rules have a .tests-popup in the way, so that's why this selects
either with or without. */
.rule:has(+ h1:target, + .tests-popup + h1:target),
.rule:has(+ h2:target, + .tests-popup + h2:target),
.rule:has(+ h3:target, + .tests-popup + h3:target),
.rule:has(+ h4:target, + .tests-popup + h4:target),
.rule:has(+ h5:target, + .tests-popup + h5:target),
.rule:has(+ h6:target, + .tests-popup + h6:target) {
padding-right: 24px;
}
/* This positioning is to push the popup down over the header's top margin.
Ideally I would like the popup to show *below* the header, but I have no idea how to do that.
*/
.tests-popup:has(+ h2) {
position: relative;
top: calc(var(--h2-margin-top) + 10px);
}
.tests-popup:has(+ h3) {
position: relative;
top: calc(var(--h3-margin-top) + 10px);
}
.tests-popup:has(+ h4) {
position: relative;
top: calc(var(--h4-margin-top) + 10px);
}
.tests-popup:has(+ h5) {
position: relative;
top: calc(var(--h5-margin-top) + 10px);
}
.tests-popup:has(+ h6) {
position: relative;
top: calc(var(--h6-margin-top) + 10px);
}
/* 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.rule-link span,
.test-link > a span {
display: none;
}
main > .rule > a.rule-link::before {
content: "[*]";
}
.test-link > a::before {
content: "[T]";
}
}
/* Align rules to various siblings */
.rule:has(+ p, + .tests-popup + p),
.rule:has(+ ul, + .tests-popup + ul) {
margin-top: calc((1em - var(--font-size)) / var(--font-size-mult) / 2);
}
.rule:has(+ h1, + .tests-popup + h1) {
align-self: center;
}
.rule:has(+ h2, + .tests-popup + 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, + .tests-popup + 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, + .tests-popup + 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, + .tests-popup + 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, + .tests-popup + 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;
}
/* The box that contains the grammar. */
.grammar-container {
font-family: var(--mono-font);
/* Enable absolute positioning for the target chevron. */
position: relative;
background-color: var(--quote-bg);
border-block-start: .1em solid var(--quote-border);
border-block-end: .1em solid var(--quote-border);
margin-top: 4px;
margin-bottom: 4px;
padding: 0 20px;
}
/* English words inside the grammar. */
.grammar-text {
font-family: "Open Sans", sans-serif;
}
/* Places a box around literals to differentiate from other grammar punctuation like | and ( . */
.grammar-literal {
font-family: var(--mono-font);
border-radius: 4px;
border: solid 1px var(--theme-popup-border);
font-weight: bold;
font-size: var(--code-font-size);
padding: 1px 4px;
color: var(--inline-code-color);
}
.light .grammar-literal {
background-color: #fafafa
}
.rust .grammar-literal {
background-color: #dedede
}
.coal .grammar-literal {
background-color: #1d1f21;
}
.navy .grammar-literal {
background-color: #1d1f21;
}
.ayu .grammar-literal {
background-color: #191f26
}
.grammar-production:target, .railroad-production:target {
scroll-margin-top: 50vh;
}
.railroad-production {
/* Enables absolute positioning of the target chevron. */
position: relative;
}
/* Adds an indicator to the targeted production name. */
.grammar-production:target::before, .railroad-production:target::before {
content: "»";
position: absolute;
left: 3px;
font-size: 2rem;
font-weight: bolder;
/* For some reason, the vertical alignment is slightly off center. This helps
with that alignment. It was too difficult to try to fix that via
absolute positioning. */
line-height: 1;
}
/* Overrides the positioning of the chevron from the rule above. */
.railroad-production:target::before {
left: -20px;
top: 8px;
}
/* The toggle button. */
.grammar-toggle-railroad {
width: 120px;
padding: 5px 0px;
border-radius: 5px;
cursor: pointer;
}
/* This is used to toggle the hidden status of the railroad diagrams. */
.grammar-hidden {
display: none;
}
:root {
--railroad-background-color: hsl(30, 20%, 95%);
--railroad-background-image: linear-gradient(to right, rgba(30, 30, 30, .05) 1px, transparent 1px),
linear-gradient(to bottom, rgba(30, 30, 30, .05) 1px, transparent 1px);
--railroad-path-stroke: black;
--railroad-rect-stroke: black;
--railroad-rect-fill: hsl(-290, 70%, 90%);
}
.coal, .navy, .ayu {
--railroad-background-color: hsl(230, 10%, 20%);
--railroad-background-image: linear-gradient(to right, rgba(150, 150, 150, .05) 1px, transparent 1px),
linear-gradient(to bottom, rgba(150, 150, 150, .05) 1px, transparent 1px);
--railroad-path-stroke: hsl(200, 10%, 60%);
--railroad-text-fill: hsl(230, 30%, 80%);
--railroad-rect-stroke: hsl(200, 10%, 50%);
--railroad-rect-fill: hsl(230, 20%, 20%);
}
svg.railroad {
background-color: var(--railroad-background-color);
background-size: 15px 15px;
background-image: var(--railroad-background-image);
}
svg.railroad rect.railroad_canvas {
stroke-width: 0px;
fill: none;
}
svg.railroad path {
stroke-width: 3px;
stroke: var(--railroad-path-stroke);
fill: none;
}
svg.railroad .debug {
stroke-width: 1px;
stroke: red;
}
svg.railroad text {
font: 14px monospace;
text-anchor: middle;
fill: var(--railroad-text-fill);
}
svg.railroad .nonterminal text {
font-weight: bold;
}
svg.railroad text.comment {
font: italic 12px monospace;
}
svg.railroad rect {
stroke-width: 3px;
stroke: var(--railroad-rect-stroke);
fill: var(--railroad-rect-fill);
}
svg.railroad g.labeledbox>rect {
stroke-width: 1px;
stroke: grey;
stroke-dasharray: 5px;
fill: rgba(90, 90, 150, .1);
}
svg.railroad g.exceptbox > rect {
fill:rgba(245, 160, 125, .1);
}