Repository navigation
Expand file tree
/
Copy pathcode-block.scss
More file actions
452 lines (374 loc) · 14.9 KB
/
Copy pathcode-block.scss
File metadata and controls
452 lines (374 loc) · 14.9 KB
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
/* Codeblock border styling */
.codeblock-customizer {
&.codeblock-customizer-style-codeblock-border-left {
.markdown-rendered .codeblock-customizer-header-container-specific[class*="codeblock-customizer-languageSpecific-"] {
border-top-left-radius: 0;
}
.codeblock-customizer-line[style*="--codeblock-bordercolor"] .codeblock-customizer-line-number-first {
border-top-left-radius: 0 !important;
}
.codeblock-customizer-line[style*="--codeblock-bordercolor"] .codeblock-customizer-line-number-last {
border-bottom-left-radius: 0 !important;
}
.markdown-source-view .HyperMD-codeblock[class*="codeblock-customizer-line"][class*="codeblock-customizer-language-"].hasLangBorderColor,
.markdown-source-view .codeblock-customizer-header-container[class*="codeblock-customizer-language-"].hasLangBorderColor,
.markdown-source-view .codeblock-customizer-header-container-specific[class*="codeblock-customizer-language-"].hasLangBorderColor,
.markdown-rendered pre.codeblock-customizer-pre[class*="codeblock-customizer-language-"].hasLangBorderColor,
.markdown-rendered .codeblock-customizer-pre-parent .codeblock-customizer-header-group-container[class*="codeblock-customizer-language-"].hasLangBorderColor {
border-left: 5px solid var(--codeblock-bordercolor);
}
}
&.codeblock-customizer-style-codeblock-border-right {
.markdown-rendered .codeblock-customizer-header-container-specific[class*="codeblock-customizer-languageSpecific-"] {
border-top-right-radius: 0;
}
.codeblock-customizer-line[style*="--codeblock-bordercolor"] .codeblock-customizer-line-number-first {
border-top-right-radius: 0 !important;
}
.codeblock-customizer-line[style*="--codeblock-bordercolor"] .codeblock-customizer-line-number-last {
border-bottom-right-radius: 0 !important;
}
.markdown-source-view .HyperMD-codeblock[class*="codeblock-customizer-line"][class*="codeblock-customizer-language-"].hasLangBorderColor,
.markdown-source-view .codeblock-customizer-header-container[class*="codeblock-customizer-language-"].hasLangBorderColor,
.markdown-source-view .codeblock-customizer-header-container-specific[class*="codeblock-customizer-language-"].hasLangBorderColor,
.markdown-rendered pre.codeblock-customizer-pre[class*="codeblock-customizer-language-"].hasLangBorderColor,
.markdown-rendered .codeblock-customizer-pre-parent .codeblock-customizer-header-group-container[class*="codeblock-customizer-language-"].hasLangBorderColor {
border-right: 5px solid var(--codeblock-bordercolor);
}
}
}
.markdown-rendered pre.codeblock-customizer-pre.displayedInGroup {
border-top-left-radius: 0 !important;
border-top-right-radius: 0 !important;
}
/* Pre element styling */
.codeblock-customizer-pre.codeblock-customizer-codeblock-collapsed code {
display: none !important;
}
.markdown-rendered pre.codeblock-customizer-pre {
// originalVal: 16px, disable it, so the lines are fully highlighted
min-height: auto;
padding: 0;
border-radius: 0 0 var(--border-radius) var(--border-radius);
// padding-top and bottom must be set at the pre code element
// originalVal: 16px, disable it, so the lines are fully highlighted
margin-top: 16px;
// originalVal: none, set it to 16px, so the header gets the marginTop, which was removed from the first line of the codeblock
code {
display: grid;
padding: var(--code-padding) 0 var(--code-padding) 0;
border-radius: 0;
background: none !important;
overflow-y: hidden;
}
}
/* expand - reading mode */
.is-readable-line-width .codeblock-customizer-pre-parent.codeblock-customizer-expand {
// some themes (e.g. Minimal) size blocks via these vars(--line-width, --max-width, --content-margin) and margin-inline: var(--content-margin) !important
--line-width: var(--cbc-expand-width, 100%);
--max-width: none;
--content-margin: var(--cbc-expand-margin, 0) 0;
width: var(--cbc-expand-width, 100%);
max-width: unset;
margin-left: var(--cbc-expand-margin, 0);
}
/* expand - editing mode */
.is-readable-line-width .cm-editor:has(.cm-line.codeblock-customizer-expand) {
// Blue Topaz targets .cm-contentContainer instead of .cm-sizer so it is also needed
.cm-sizer,
.cm-contentContainer,
.cm-content {
max-width: unset !important;
}
.cm-content > *:not(.codeblock-customizer-expand) {
max-width: var(--file-line-width) !important;
margin-inline: auto !important;
}
// some themes (e.g. Minimal) size lines via these vars(--line-width, --max-width, --content-margin) and margin-inline: var(--content-margin) !important
// these themes also drop the horizontal file margins. keep the default gutter
.cm-content > .codeblock-customizer-expand {
--line-width: calc(100% - 2 * var(--file-margins-x, 0px));
--max-width: none;
--content-margin: auto;
}
}
/* Prevent Line Wraps */
.HyperMD-codeblock:has(> .cm-widgetBuffer):not(.codeblock-customizer-nowrap) {
white-space: nowrap;
}
.HyperMD-codeblock:has(> .cm-widgetBuffer):not(.codeblock-customizer-nowrap)>.cm-hmd-codeblock {
white-space: break-spaces;
}
/* Border radius styling */
.codeblock-customizer .markdown-source-view {
[class*="codeblock-customizer-line"] {
&.HyperMD-codeblock-begin {
border-top-left-radius: 0;
border-top-right-radius: 0;
}
&.HyperMD-codeblock-end {
border-bottom-left-radius: var(--border-radius);
border-bottom-right-radius: var(--border-radius);
.codeblock-customizer-line-number,
.codeblock-customizer-line-number-specific {
border-bottom-left-radius: var(--border-radius);
}
}
.codeblock-customizer-prompt-cmd-output {
position: absolute;
z-index: 10;
bottom: 0;
display: flex;
overflow: hidden;
width: 100%;
flex-wrap: nowrap;
align-items: center;
}
&.has-prompt-output {
position: relative;
padding-bottom: 1.5em;
}
&.codeblock-customizer-expand {
max-width: unset;
margin-inline: 0;
}
&.codeblock-customizer-nowrap {
padding-left: 0 !important;
overflow-wrap: normal !important;
overflow-x: auto;
overscroll-behavior-x: contain;
/* ::-webkit-scrollbar is ignored when scrollbar-color/width is set (Obsidian sets it on body) */
scrollbar-width: none;
white-space: pre !important;
word-wrap: normal;
&.has-prompt-output {
padding-bottom: 0;
}
.cbc-line-num {
position: sticky;
left: 0;
margin-right: var(--line-number-gutter-padding);
box-shadow: 0 1px 0 0 var(--gutter-background-color, var(--codeblock-customizer-gutter-background-color));
}
&.HyperMD-codeblock-begin {
overflow: clip visible;
text-indent: var(--cbc-fence-scroll, 0);
.cbc-line-num {
position: relative;
left: calc(-1 * var(--cbc-fence-scroll, 0px));
}
}
.codeblock-customizer-prompt-cmd-output {
position: static !important;
display: flex !important;
overflow: visible;
width: auto !important;
min-width: max(100%, var(--cbc-min-scroll-width, 0px)) !important;
flex-wrap: nowrap;
float: left !important;
&::before {
position: sticky;
left: 0;
display: inline-block;
min-width: var(--line-number-gutter-width, 0);
height: 100%;
min-height: 1.5em;
margin-right: var(--line-number-gutter-padding);
background-color: var(--gutter-background-color, var(--codeblock-customizer-gutter-background-color));
box-shadow: 0 1px 0 0 var(--gutter-background-color, var(--codeblock-customizer-gutter-background-color));
color: transparent;
content: '\a0';
}
}
&::-webkit-scrollbar {
display: none;
height: 0;
}
&::after {
display: block;
width: var(--cbc-min-scroll-width, 0);
height: 0;
content: '';
}
&:has(.cbc-line-num)::after {
width: calc(var(--cbc-min-scroll-width, 0px) + var(--line-number-gutter-width, 0px) + var(--line-number-gutter-padding, 0px));
}
// Hidden line and separator widgets in unwrapped mode
.codeblock-customizer-hidden-line-container,
.codeblock-customizer-line-separator {
overflow: visible;
width: max(100%, var(--cbc-min-scroll-width, 0px));
}
&:has(.cbc-line-num) {
.codeblock-customizer-hidden-line-container,
.codeblock-customizer-line-separator {
width: max(100%, calc(var(--cbc-min-scroll-width, 0px) + var(--line-number-gutter-width, 0px) + var(--line-number-gutter-padding, 0px)));
}
}
.codeblock-customizer-hidden-line-gutter,
.codeblock-customizer-hidden-line-gutter-specific,
.codeblock-customizer-line-separator-gutter {
position: sticky;
z-index: 2;
left: 0;
}
}
}
}
body:not(.codeblock-customizer-show-langicons-always, .codeblock-customizer-show-langnames-always) .markdown-source-view .codeblock-customizer-header-container+.HyperMD-codeblock-begin,
body:not(.codeblock-customizer-show-langnames-always) .markdown-source-view .codeblock-customizer-header-container:not(.has-icon)+.HyperMD-codeblock-begin,
body .markdown-source-view .codeblock-customizer-header-container:not(.has-icon)+.HyperMD-codeblock-begin {
border-top-left-radius: var(--border-radius);
border-top-right-radius: var(--border-radius);
.codeblock-customizer-line-number,
.codeblock-customizer-line-number-specific {
border-top-left-radius: var(--border-radius);
}
}
.codeblock-customizer-header-collapse-command .markdown-source-view .codeblock-customizer-header-container+.HyperMD-codeblock-begin {
border-top-left-radius: 0 !important;
border-top-right-radius: 0 !important;
.codeblock-customizer-line-number,
.codeblock-customizer-line-number-specific {
border-top-left-radius: 0 !important;
}
}
body:not(.codeblock-customizer-show-langicons-always, .codeblock-customizer-show-langnames-always) .codeblock-customizer-header-container+.codeblock-customizer-pre,
body:not(.codeblock-customizer-show-langnames-always) .codeblock-customizer-header-container:not(.has-icon)+.codeblock-customizer-pre,
body .codeblock-customizer-header-container:not(.has-icon)+.codeblock-customizer-pre {
border-top-left-radius: var(--border-radius);
border-top-right-radius: var(--border-radius);
}
.codeblock-customizer-header-collapse-command .codeblock-customizer-header-container+.codeblock-customizer-pre {
border-top-left-radius: 0 !important;
border-top-right-radius: 0 !important;
}
body.codeblock-customizer .markdown-source-view :not(pre.codeblock-customizer-pre)>.codeblock-customizer-header-container-specific+[class*="codeblock-customizer-line"].HyperMD-codeblock-begin {
border-top: none !important;
border-top-left-radius: 0 !important;
border-top-right-radius: 0 !important;
}
/* code wrapping */
.markdown-rendered .codeblock-customizer-pre>code {
overflow-wrap: anywhere;
white-space: var(--wrap-code) !important;
}
/* fence line styling */
.codeblock-customizer-fence-collapsed {
overflow: visible;
height: 8px;
min-height: 8px;
color: transparent !important;
}
/* .markdown-source-view {
.codeblock-customizer-fence-collapsed+.cm-line .codeblock-customizer-button-container {
top: 1px;
}
}
.codeblock-customizer-header-container-specific+.cm-line.codeblock-customizer-fence-collapsed+.cm-line .codeblock-customizer-button-container,
.codeblock-customizer-header-collapse-command .codeblock-customizer-header-container+.cm-line.codeblock-customizer-fence-collapsed+.cm-line .codeblock-customizer-button-container {
display: none;
} */
.codeblock-customizer pre.codeblock-customizer-pre {
min-height: unset;
padding: 0 !important;
border-radius: var(--border-radius) !important;
}
/* remove the gap between header and code */
.markdown-rendered .codeblock-customizer-pre.displayedInGroup {
margin-top: 0 !important;
}
/* hide buttons for grouped code blocks, as they are always displayed in the header */
.markdown-rendered pre.codeblock-customizer-pre.displayedInGroup .codeblock-customizer-button-container {
display: none;
}
/* hide buttons */
.markdown-rendered .codeblock-customizer-header-group-container .codeblock-customizer-button-container.hidden {
display: none;
}
/* output parameter */
.markdown-rendered pre.codeblock-customizer-pre.is-output {
margin-top: 0 !important;
}
/* previous codeblock */
.codeblock-customizer-pre-parent:has(+ .codeblock-customizer-pre-parent > .is-output)>pre {
margin-bottom: 0 !important;
}
/* grouped blocks */
.codeblock-customizer-pre-parent:has(pre.displayedInGroup):has(~ .codeblock-customizer-pre-parent > .is-output)>pre {
margin-bottom: 0 !important;
}
/* hidden lines */
.markdown-rendered div.codeblock-customizer-line-wrapper.hidden-line-hidden,
.markdown-rendered div.codeblock-customizer-line-wrapper.has-prompt.hidden-line-hidden {
display: none;
}
.markdown-rendered .codeblock-customizer-line-wrapper.unhidden-range .codeblock-customizer-hidden-line-container {
display: none;
}
.codeblock-customizer-line-wrapper.dummy-wrapper {
height: calc(var(--line-height-normal) * 1em);
}
.codeblock-customizer-line-wrapper.dummy-wrapper.unhidden-range {
height: 0;
}
// line numbers disabled
.codeblock-customizer:not(.codeblock-customizer-show-line-numbers) {
.markdown-source-view [class*="codeblock-customizer-line"].codeblock-customizer-nowrap {
padding-left: var(--line-number-gutter-padding) !important;
.codeblock-customizer-prompt-cmd-output::before {
display: none;
}
&:has(.cbc-line-num) {
padding-left: 0 !important;
.codeblock-customizer-prompt-cmd-output::before {
display: inline-block;
}
}
}
}
/* hide scrollbar when code block is collapsed/semi-collapsed */
.codeblock-customizer-scrollbar:not(.HyperMD-codeblock + .codeblock-customizer-scrollbar) {
display: none;
}
/* codeblock scrollbar */
.codeblock-customizer-scrollbar-spacer {
display: inline-block;
height: 1px;
visibility: hidden;
}
.codeblock-customizer-scrollbar {
overflow: auto hidden;
height: 12px;
background-color: var(--codeblock-background-color, var(--codeblock-customizer-codeblock-background-color));
cursor: default;
overscroll-behavior-x: contain;
&::-webkit-scrollbar {
display: block;
height: 8px;
&-thumb {
border-radius: 4px;
background: var(--scrollbar-thumb-bg, rgb(128 128 128 / 40%));
}
&-track {
background: transparent;
}
}
}
.codeblock-customizer-print-avoid-break {
break-inside: avoid;
}
.codeblock-customizer-grouped-block-hidden {
display: none !important;
}
.codeblock-customizer-snapshot-offscreen {
position: absolute;
top: -9999px;
left: -9999px;
.codeblock-customizer-nowrap {
overflow-x: hidden !important;
}
}
.codeblock-customizer-snapshot-restore-tab-padding {
padding-right: var(--header-spacing) !important;
}