@@ -551,3 +551,157 @@ main > .rule {
551
551
z-index : 1000 ;
552
552
padding : 1rem ;
553
553
}
554
+
555
+ /* The box that contains the grammar. */
556
+ .grammar-container {
557
+ font-family : var (--mono-font );
558
+ /* Enable absolute positioning for the target chevron. */
559
+ position : relative;
560
+ background-color : var (--quote-bg );
561
+ border-block-start : .1em solid var (--quote-border );
562
+ border-block-end : .1em solid var (--quote-border );
563
+ margin-top : 4px ;
564
+ margin-bottom : 4px ;
565
+ padding : 0 20px ;
566
+ }
567
+
568
+ /* English words inside the grammar. */
569
+ .grammar-text {
570
+ font-family : "Open Sans" , sans-serif;
571
+ }
572
+
573
+ /* Places a box around literals to differentiate from other grammar punctuation like | and ( . */
574
+ .grammar-literal {
575
+ font-family : var (--mono-font );
576
+ border-radius : 4px ;
577
+ border : solid 1px var (--theme-popup-border );
578
+ font-weight : bold;
579
+ font-size : var (--code-font-size );
580
+ padding : 1px 4px ;
581
+ color : var (--inline-code-color );
582
+ }
583
+
584
+ .light .grammar-literal {
585
+ background-color : # fafafa
586
+ }
587
+ .rust .grammar-literal {
588
+ background-color : # dedede
589
+ }
590
+ .coal .grammar-literal {
591
+ background-color : # 1d1f21 ;
592
+ }
593
+ .navy .grammar-literal {
594
+ background-color : # 1d1f21 ;
595
+ }
596
+ .ayu .grammar-literal {
597
+ background-color : # 191f26
598
+ }
599
+
600
+ .grammar-production : target , .railroad-production : target {
601
+ scroll-margin-top : 50vh ;
602
+ }
603
+
604
+ .railroad-production {
605
+ /* Enables absolute positioning of the target chevron. */
606
+ position : relative;
607
+ }
608
+
609
+ /* Adds an indicator to the targeted production name. */
610
+ .grammar-production : target ::before , .railroad-production : target ::before {
611
+ content : "»" ;
612
+ position : absolute;
613
+ left : 3px ;
614
+ font-size : 2rem ;
615
+ font-weight : bolder;
616
+ /* For some reason, the vertical alignment is slightly off center. This helps
617
+ with that alignment. It was too difficult to try to fix that via
618
+ absolute positioning. */
619
+ line-height : 1 ;
620
+ }
621
+
622
+ /* Overrides the positioning of the chevron from the rule above. */
623
+ .railroad-production : target ::before {
624
+ left : -20px ;
625
+ top : 8px ;
626
+ }
627
+
628
+ /* The toggle button. */
629
+ .grammar-toggle {
630
+ width : 120px ;
631
+ padding : 5px 0px ;
632
+ border-radius : 5px ;
633
+ cursor : pointer;
634
+ }
635
+
636
+ /* This is used to toggle the hidden status of the railroad diagrams. */
637
+ .grammar-hidden {
638
+ display : none;
639
+ }
640
+
641
+ : root {
642
+ --railroad-background-color : hsl (30 , 20% , 95% );
643
+ --railroad-background-image : linear-gradient (to right, rgba (30 , 30 , 30 , .05 ) 1px , transparent 1px ),
644
+ linear-gradient (to bottom, rgba (30 , 30 , 30 , .05 ) 1px , transparent 1px );
645
+ --railroad-path-stroke : black;
646
+ --railroad-rect-stroke : black;
647
+ --railroad-rect-fill : hsl (-290 , 70% , 90% );
648
+ }
649
+
650
+ .coal , .navy , .ayu {
651
+ --railroad-background-color : hsl (230 , 10% , 20% );
652
+ --railroad-background-image : linear-gradient (to right, rgba (150 , 150 , 150 , .05 ) 1px , transparent 1px ),
653
+ linear-gradient (to bottom, rgba (150 , 150 , 150 , .05 ) 1px , transparent 1px );
654
+ --railroad-path-stroke : hsl (200 , 10% , 60% );
655
+ --railroad-text-fill : hsl (230 , 30% , 80% );
656
+ --railroad-rect-stroke : hsl (200 , 10% , 50% );
657
+ --railroad-rect-fill : hsl (230 , 20% , 20% );
658
+ }
659
+
660
+ svg .railroad {
661
+ background-color : var (--railroad-background-color );
662
+ background-size : 15px 15px ;
663
+ background-image : var (--railroad-background-image );
664
+ }
665
+
666
+ svg .railroad rect .railroad_canvas {
667
+ stroke-width : 0px ;
668
+ fill : none;
669
+ }
670
+
671
+ svg .railroad path {
672
+ stroke-width : 3px ;
673
+ stroke : var (--railroad-path-stroke );
674
+ fill : none;
675
+ }
676
+
677
+ svg .railroad .debug {
678
+ stroke-width : 1px ;
679
+ stroke : red;
680
+ }
681
+
682
+ svg .railroad text {
683
+ font : 14px monospace;
684
+ text-anchor : middle;
685
+ fill : var (--railroad-text-fill );
686
+ }
687
+
688
+ svg .railroad .nonterminal text {
689
+ font-weight : bold;
690
+ }
691
+
692
+ svg .railroad text .comment {
693
+ font : italic 12px monospace;
694
+ }
695
+
696
+ svg .railroad rect {
697
+ stroke-width : 3px ;
698
+ stroke : var (--railroad-rect-stroke );
699
+ fill : var (--railroad-rect-fill );
700
+ }
701
+
702
+ svg .railroad g .labeledbox > rect {
703
+ stroke-width : 1px ;
704
+ stroke : grey;
705
+ stroke-dasharray : 5px ;
706
+ fill : rgba (90 , 90 , 150 , .1 );
707
+ }
0 commit comments