summaryrefslogtreecommitdiff
path: root/hack
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2025-07-26 16:03:33 +0200
committerjaseg <git@jaseg.de>2025-07-26 16:03:33 +0200
commitf5d03ed1cf5e98581f10f1e7922ed77a5e6ffd76 (patch)
tree8a355165711d3e23c4e826233578c92c77facba8 /hack
parent338de75fb45b861510e99a8271724fd00f2b023e (diff)
downloadblog-f5d03ed1cf5e98581f10f1e7922ed77a5e6ffd76.tar.gz
blog-f5d03ed1cf5e98581f10f1e7922ed77a5e6ffd76.tar.bz2
blog-f5d03ed1cf5e98581f10f1e7922ed77a5e6ffd76.zip
Add code listing CSS hack article
Diffstat (limited to 'hack')
-rwxr-xr-xhack/rst2html5
1 files changed, 4 insertions, 1 deletions
diff --git a/hack/rst2html b/hack/rst2html
index e3a390d..f9c9146 100755
--- a/hack/rst2html
+++ b/hack/rst2html
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-# https://gist.github.com/mastbaum/2655700
+# Based on https://gist.github.com/mastbaum/2655700 for the basic plugin scaffolding
import sys
import re
@@ -17,6 +17,9 @@ class UnfuckedHTMLTranslator(HTMLTranslator):
self.in_literal_block = False
def visit_literal_block(self, node):
+ # Insert an empty "lineno" span before each line. We insert the line numbers using pure CSS in a ::before
+ # pseudo-element. This has the added advantage that the line numbers don't get included in text selection.
+ # These line number spans are also used to show line continuation markers when a line is wrapped.
self.in_literal_block = True
self.body.append(self.starttag(node, 'pre', CLASS='literal-block'))
self.body.append('<span class="lineno"></span><span class="line">')