From d3eadbdcc12677e0bb0e59b419efc565955da844 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 11 Dec 2017 01:35:26 +0100 Subject: [PATCH] m.htmlsanity: remove more docutils cruft from the markup. --- pelican-plugins/m/htmlsanity.py | 58 +++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/pelican-plugins/m/htmlsanity.py b/pelican-plugins/m/htmlsanity.py index e2a3cddb..6419314a 100644 --- a/pelican-plugins/m/htmlsanity.py +++ b/pelican-plugins/m/htmlsanity.py @@ -371,6 +371,27 @@ class SaneHtmlTranslator(HTMLTranslator): ('colwidths-given' not in node.parent.parent['classes'])): return + # Verbatim copied, removing the 'head' class from + def visit_entry(self, node): + atts = {'class': []} + if node.parent.parent.parent.stubs[node.parent.column]: + # "stubs" list is an attribute of the tgroup element + atts['class'].append('stub') + if atts['class'] or isinstance(node.parent.parent, nodes.thead): + tagname = 'th' + atts['class'] = ' '.join(atts['class']) + else: + tagname = 'td' + del atts['class'] + node.parent.column += 1 + if 'morerows' in node: + atts['rowspan'] = node['morerows'] + 1 + if 'morecols' in node: + atts['colspan'] = node['morecols'] + 1 + node.parent.column += node['morecols'] + self.body.append(self.starttag(node, tagname, '', **atts)) + self.context.append('\n' % tagname.lower()) + # Don't put comments into the HTML output def visit_comment(self, node, sub=re.compile('-(?=-)').sub): @@ -512,6 +533,43 @@ class SaneHtmlTranslator(HTMLTranslator): self.html_title.extend(self.body) del self.body[:] + # \n') + + def visit_enumerated_list(self, node): + atts = {} + if 'start' in node: + atts['start'] = node['start'] + self.body.append(self.starttag(node, 'ol', **atts)) + + def depart_enumerated_list(self, node): + self.body.append('\n') + + def visit_definition_list(self, node): + classes = node.setdefault('classes', []) + self.body.append(self.starttag(node, 'dl')) + + def depart_definition_list(self, node): + self.body.append('\n') + + # no class="docutils" in
+ def visit_transition(self, node): + self.body.append(self.emptytag(node, 'hr')) + + def depart_transition(self, node): + pass + class _SaneFieldBodyTranslator(SaneHtmlTranslator): """ Copy of _FieldBodyTranslator with the only difference being inherited from -- 2.30.2