From: Vladimír Vondruš
Date: Fri, 29 Mar 2019 09:57:02 +0000 (+0100)
Subject: m.htmlsanity: style footnotes with our CSS classes.
X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=3aa73761c15195032e0f9d2e6e0be9f721cb903e;p=blog.git
m.htmlsanity: style footnotes with our CSS classes.
---
diff --git a/pelican-plugins/m/htmlsanity.py b/pelican-plugins/m/htmlsanity.py
index 86af90a7..df73ebc5 100644
--- a/pelican-plugins/m/htmlsanity.py
+++ b/pelican-plugins/m/htmlsanity.py
@@ -443,6 +443,44 @@ class SaneHtmlTranslator(HTMLTranslator):
def depart_line(self, node):
self.body.append('
\n')
+ # Footnote list. Replacing the classes with just .m-footnote.
+ def visit_footnote(self, node):
+ if not self.in_footnote_list:
+ self.body.append('\n')
+ self.in_footnote_list = False
+
+ # Footnote reference
+ def visit_footnote_reference(self, node):
+ href = '#' + node['refid']
+ self.body.append(self.starttag(node, 'a', '', CLASS='m-footnote', href=href))
+
+ def depart_footnote_reference(self, node):
+ self.body.append('')
+
+ # Footnote and citation labels
+ def visit_label(self, node):
+ self.body.append(self.starttag(node.parent, 'dt', ''))
+
+ def depart_label(self, node):
+ if self.settings.footnote_backlinks:
+ backrefs = node.parent['backrefs']
+ if len(backrefs) == 1:
+ self.body.append('')
+ self.body.append('.\n ')
+
def visit_line_block(self, node):
self.body.append(self.starttag(node, 'p'))
diff --git a/pelican-plugins/m/test/htmlsanity_content/page.html b/pelican-plugins/m/test/htmlsanity_content/page.html
index 3c132206..3a7dc574 100644
--- a/pelican-plugins/m/test/htmlsanity_content/page.html
+++ b/pelican-plugins/m/test/htmlsanity_content/page.html
@@ -26,8 +26,8 @@
+
diff --git a/pelican-plugins/m/test/htmlsanity_content/page.rst b/pelican-plugins/m/test/htmlsanity_content/page.rst
index e0fd5b2f..156d8f96 100644
--- a/pelican-plugins/m/test/htmlsanity_content/page.rst
+++ b/pelican-plugins/m/test/htmlsanity_content/page.rst
@@ -48,9 +48,10 @@ Section title
An *emphasised text*, **strong text** and a ``literal``. Link to
`Google `_, `the heading below <#a-heading>`_ or just an
URL as-is: https://mcss.mosra.cz/. `E-mail `_. A footnote
-reference: [1]_
+reference on a single thing [1]_ and more things [1]_ [2]_
.. [1] A footnote description
+.. [2] Second thing description
`Section title with link`_
--------------------------