summaryrefslogtreecommitdiff
path: root/hack/rst2html
diff options
context:
space:
mode:
Diffstat (limited to 'hack/rst2html')
-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">')