better code blocks

This commit is contained in:
Lina 2023-02-08 22:07:53 +00:00
parent 76b4e7727b
commit 4936d05adc
2 changed files with 32 additions and 2 deletions

View File

@ -2,7 +2,37 @@ $no-columns-breakpoint: 600px;
code {
font-family: $font-monospace, monospace;
font-weight: 400;
border-radius: 3px;
padding: 0 0.4em;
background: darken($ui-base-color, 8%);
}
pre {
background: darken($ui-base-color, 8%);
border-radius: 3px;
padding: 0.75em;
counter-reset: line;
overflow-x: scroll;
}
pre code {
counter-increment: line;
padding: 0;
white-space: pre;
}
pre code::before {
font-size: 0.8em;
color: darken($primary-text-color, 33%);
content: counter(line);
display: inline-block;
border-right: 1px solid darken($primary-text-color, 33%);
margin: -0.05em 0.7em -0.05em 0;
padding: 0.05em 0.5em 0.05em 0;
text-align: right;
width: 1.2em;
white-space: nowrap;
direction: rtl;
}
.form-container {

View File

@ -9,7 +9,7 @@ class AdvancedTextFormatter < TextFormatter
def block_code(code, _language)
<<~HTML
<pre><code>#{ERB::Util.h(code).gsub("\n", '<br/>')}</code></pre>
<pre><code>#{ERB::Util.h(code.rstrip).gsub("\n", '</code></br><code>')}</code></pre>
HTML
end