From 7d867a68a026094e842529a41dbcc812181b0da9 Mon Sep 17 00:00:00 2001 From: Alexis Fourmaux Date: Sat, 17 May 2025 01:56:34 +0200 Subject: [PATCH] fix: code when adding linenos --- content/articles/example.md | 2 +- sass/parts/_code.scss | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/content/articles/example.md b/content/articles/example.md index 0dcfda6..ed93666 100644 --- a/content/articles/example.md +++ b/content/articles/example.md @@ -28,7 +28,7 @@ Oechalidum[^second] limus posse. [^second]: Footnote text. -```c# +```c#,linenos,name=example.cs using System.IO.Compression; #pragma warning disable 414, 3021 diff --git a/sass/parts/_code.scss b/sass/parts/_code.scss index 0249570..a965df2 100644 --- a/sass/parts/_code.scss +++ b/sass/parts/_code.scss @@ -1,4 +1,5 @@ pre { + position: relative; font-family: var(--mono-font); padding: 1.25rem; border-radius: var(--standard-border-radius); @@ -6,11 +7,45 @@ pre { border-color: var(--overlay0); border-width: 0.15rem; line-height: initial; - overflow-x: scroll; + overflow: hidden; + overflow-x: auto; &>code { background-color: initial; border: initial; + padding: 0; + } + + &[data-linenos] { + padding: 1.25rem 0; + } + + table { + width: 100%; + border-collapse: collapse; + margin: 0; + + th, + td, + tr { + border: none; + padding: 0 + } + + td:nth-of-type(1) { + text-align: center; + vertical-align: top; + user-select: none; + color: var(--overlay1); + } + + tr:nth-child(even) td { + background-color: inherit; + } + } + + mark { + display: block; } }