From f5d03ed1cf5e98581f10f1e7922ed77a5e6ffd76 Mon Sep 17 00:00:00 2001 From: jaseg Date: Sat, 26 Jul 2025 16:03:33 +0200 Subject: Add code listing CSS hack article --- hack/rst2html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'hack/rst2html') 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('') -- cgit