Tweak code CSS a bit to make it nicer

Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
Danila Fedorin 2024-02-02 21:05:26 -08:00
parent a613c68f01
commit 4a5dfac221
3 changed files with 25 additions and 5 deletions

View File

@ -55,6 +55,12 @@ pre code {
.lntd:last-child {
width: 100%;
}
// Insert padding to match the distance of the line number to its
// border.
.line {
padding-left: $code-lineno-spacing;
}
}
.lntr {
@ -63,16 +69,27 @@ pre code {
.lnt {
display: block;
padding: 0 1rem 0 1rem;
color: $code-lineno-color;
padding: 0 $code-lineno-spacing 0 $code-lineno-spacing;
@include var(color, code-lineno-color);
border-right: $standard-border;
// Even though only highlighted line table numbers get the 'star',
// insert a corresponding space on non-highlighted ones to keep
// spacing consistent.
&::before {
content: " ";
}
}
.hl {
display: block;
@include var(background-color, code-highlight-color);
.lnt::before {
content: "*";
.lnt {
border-left-color: $border-color;
&::before {
content: "*";
}
}
}
}

View File

@ -15,6 +15,7 @@
--target-background-color: #{$target-background-color-dark};
--code-color: #{$code-color-dark};
--code-lineno-color: white;
--code-keyword-color: #{$code-token-color-dark};
--code-type-color: #{$code-token-color-dark};
--code-highlight-color: #{$code-highlight-color-dark};

View File

@ -28,7 +28,8 @@ $code-token-color-dark: $primary-color;
$code-highlight-color: #fffd99;
$code-highlight-color-dark: #555538;
$code-border-color: darken($code-color, 10%);
$code-lineno-color: grey;
$code-lineno-color: black;
$code-lineno-spacing: 1rem;
$code-comment-color: grey;
$code-border: $standard-border-width solid $code-border-color;
@ -54,6 +55,7 @@ $css-vars: (
target-background-color: $target-background-color,
code-color: $code-color,
code-lineno-color: $code-lineno-color,
code-keyword-color: $code-token-color,
code-type-color: $code-token-color,
code-highlight-color: $code-highlight-color,