summaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorAlexis Hovorka <[email protected]>2022-10-27 00:08:15 -0600
committerAlexis Hovorka <[email protected]>2022-10-27 00:08:15 -0600
commitc0c2a30ff1e9043f75ed49654ce24e43fd7e5b5c (patch)
tree24c9d767c5e0074292f54db5a321efc929efcbb7 /static
parentbb8fff96eec395e0f2861bb06c31f737b1a1382b (diff)
[fix] Fix line numbering on blank lines in code blocks
Diffstat (limited to 'static')
-rw-r--r--static/main.js2
-rw-r--r--static/style.css4
2 files changed, 5 insertions, 1 deletions
diff --git a/static/main.js b/static/main.js
index 317bd18..0858183 100644
--- a/static/main.js
+++ b/static/main.js
@@ -15,7 +15,7 @@ document.addEventListener("DOMContentLoaded", () => {
// Add line numbers to code blocks
[...d[q]("pre.hljs code")].forEach(e => e.innerHTML =
- e.innerHTML.split("\n").map((l,i,a) => l &&
+ e.innerHTML.split("\n").slice(0,-1).map((l,i,a) =>
`<div class="code-line" data-line-number="${
(i+1).toString().padStart(Math.ceil(Math.log10(a.length)), 0)
}">${l}</div>`).join("\n"));
diff --git a/static/style.css b/static/style.css
index 8d0c1a2..6495fe5 100644
--- a/static/style.css
+++ b/static/style.css
@@ -328,6 +328,10 @@ pre:hover .code-line::before {
color: #fff8;
}
+pre .code-line::after {
+ content: "\200B";
+}
+
pre {
margin: 1em -100%; /* old browsers fallback */
margin: 1rem calc(50% - 50vw);