diff options
author | jaseg <git@jaseg.de> | 2023-12-30 16:38:02 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2023-12-30 16:38:02 +0100 |
commit | 458a5fdfc598517b9fbddd02d3e1ae7cc70ceb9d (patch) | |
tree | 0ba3319ddb214bc65dd402de13939cb9ca283574 /hack | |
parent | 9ee28abd5041ebbbc8acd39ddc84ca37e7255076 (diff) | |
parent | 58d54c5debedca8c91b28026f520b226ac8682f6 (diff) | |
download | blog-deploy.tar.gz blog-deploy.tar.bz2 blog-deploy.zip |
deploy.py auto-commitdeploy
Diffstat (limited to 'hack')
-rwxr-xr-x | hack/rst2html | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/hack/rst2html b/hack/rst2html deleted file mode 100755 index e3a390d..0000000 --- a/hack/rst2html +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python3 -# https://gist.github.com/mastbaum/2655700 - -import sys -import re - -import docutils.core -from docutils.transforms import Transform -from docutils.nodes import TextElement, Inline, Text -from docutils.parsers.rst import Directive, directives -from docutils.writers.html4css1 import Writer, HTMLTranslator - - -class UnfuckedHTMLTranslator(HTMLTranslator): - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.in_literal_block = False - - def visit_literal_block(self, node): - 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">') - - def depart_literal_block(self, node): - self.in_literal_block = False - self.body.append('\n</span></pre>\n') - - def visit_Text(self, node): - if self.in_literal_block: - for match in re.finditer('([^\n]*)(\n|$)', node.astext()): - text, end = match.groups() - - if text: - super().visit_Text(Text(text)) - - if end == '\n': - if isinstance(node.parent, Inline): - self.depart_inline(node.parent) - self.body.append(f'</span>\n<span class="lineno"></span><span class="line">') - if isinstance(node.parent, Inline): - self.visit_inline(node.parent) - - else: - super().visit_Text(node) - - -html_writer = Writer() -html_writer.translator_class = UnfuckedHTMLTranslator -docutils.core.publish_cmdline(writer=html_writer) - |