3
3
4
4
// {% raw %}
5
5
6
- code {
7
- padding : 0.2em 0.15em ;
8
- font-weight : 400 ;
9
- background-color : $code-background-color ;
10
- border : $border $border-color ;
11
- border-radius : $border-radius ;
6
+ // This instruction applies to all queues not within 'pre', avoiding 'code' generated by the highlight.
7
+ :not (pre ) {
8
+ & > code {
9
+ padding : 0.2em 0.15em ;
10
+ font-weight : 400 ;
11
+ background-color : $code-background-color ;
12
+ border : $border $border-color ;
13
+ border-radius : $border-radius ;
14
+ }
12
15
}
13
16
14
17
// Avoid appearance of dark border around visited code links in Safari
@@ -47,18 +50,77 @@ a:visited code {
47
50
// Kramdown line_numbers = true: fences have a wider gutter than with Liquid?
48
51
49
52
// ```[LANG]...```
53
+
54
+ // the code may appear with 3 different types:
55
+ // container \ case: default case, code with line number, code with html rendering
56
+ // top level: div.highlighter-rouge, div.listingblock > div.content, figure.highlight
57
+ // second level: div.highlight, .table-wrapper, pre
58
+ // third level: pre.highlight, td.code, absent
59
+ // last level: code, pre, code (optionality)
60
+ // highlighter level: span, span, span
61
+ // the spacing are only in the second level for case 1, 3 and in the thirt level for case 2
62
+
63
+ // select top level container
50
64
div .highlighter-rouge ,
51
- div .listingblock > div .content {
52
- padding : $sp-3 ;
65
+ div .listingblock > div .content ,
66
+ figure .highlight {
53
67
margin-top : 0 ;
54
68
margin-bottom : $sp-3 ;
55
- overflow-x : auto ;
56
69
background-color : $code-background-color ;
57
70
border-radius : $border-radius ;
58
71
box-shadow : none ;
59
72
-webkit-overflow-scrolling : touch ;
73
+ position : relative ;
74
+ padding : 0 ;
75
+
76
+ // copy button (or other button)
77
+ // the button appear only when there is a hover on the code or focus on button
78
+ > button {
79
+ width : $sp-3 ;
80
+ opacity : 0 ;
81
+ position : absolute ;
82
+ top : 0 ;
83
+ right : 0 ;
84
+ border : $sp-3 solid $code-background-color ;
85
+ background-color : $code-background-color ;
86
+ color : $body-text-color ;
87
+ box-sizing : content-box ;
88
+
89
+ svg {
90
+ fill : $body-text-color ;
91
+ }
92
+
93
+ & :active {
94
+ text-decoration : none ;
95
+ outline : none ;
96
+ opacity : 1 ;
97
+ }
98
+
99
+ & :focus {
100
+ opacity : 1 ;
101
+ }
102
+ }
103
+
104
+ // the button can be seen by doing a simple hover in the code, there is no need to go over the location of the button
105
+ & :hover {
106
+ > button {
107
+ cursor : copy ;
108
+ opacity : 1 ;
109
+ }
110
+ }
111
+ }
112
+
113
+ // setting the spacing and scrollbar on the second level for the first case
114
+ // remove all space on the second and thirt level
115
+ div .highlighter-rouge ,
116
+ div .listingblock {
117
+ div .highlight {
118
+ overflow-x : auto ;
119
+ padding : $sp-3 ;
120
+ margin : 0 ;
121
+ border : 0 ;
122
+ }
60
123
61
- div .highlight ,
62
124
pre .highlight ,
63
125
code {
64
126
padding : 0 ;
@@ -69,26 +131,24 @@ div.listingblock > div.content {
69
131
70
132
// {% highlight LANG %}...{% endhighlight %},
71
133
// {% highlight LANG linenos %}...{% endhighlight %}:
72
- figure .highlight {
73
- padding : $sp-3 ;
74
- margin-top : 0 ;
75
- margin-bottom : $sp-3 ;
76
- overflow-x : auto ;
77
- background-color : $code-background-color ;
78
- border-radius : $border-radius ;
79
- box-shadow : none ;
80
- -webkit-overflow-scrolling : touch ;
81
134
135
+ // setting the spacing and scrollbar on the second level for the thirt case
136
+ // the css rule are apply only to the last code enviroment
137
+ // setting the scroolbar
138
+ figure .highlight {
82
139
pre ,
83
- code {
84
- padding : 0 ;
140
+ :not (pre ) > code {
141
+ overflow-x : auto ;
142
+ padding : $sp-3 ;
85
143
margin : 0 ;
86
144
border : 0 ;
87
145
}
88
146
}
89
147
90
148
// ```[LANG]...```, kramdown line_numbers = true,
91
149
// {% highlight LANG linenos %}...{% endhighlight %}:
150
+
151
+ // setting the spacing and scrollbar on the thirt level for the second case
92
152
.highlight .table-wrapper {
93
153
padding : 0 ;
94
154
margin : 0 ;
@@ -108,6 +168,7 @@ figure.highlight {
108
168
td .gl {
109
169
width : 1em ;
110
170
padding-right : $sp-3 ;
171
+ padding-left : $sp-3 ;
111
172
}
112
173
113
174
pre {
@@ -116,10 +177,7 @@ figure.highlight {
116
177
}
117
178
}
118
179
119
- //
120
- // Code examples (rendered)
121
- //
122
-
180
+ // Code examples: html render of a code
123
181
.code-example ,
124
182
.listingblock > .title {
125
183
padding : $sp-3 ;
0 commit comments