From 0f1036e8a6df0235dc424f5f02be027b56331478 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 2 Nov 2017 18:51:47 +0100 Subject: [PATCH] m.htmlsanity: better consistency for collapsed

s in additional fields. Previously (and that's also how stock Pelican behaves) article summaries and other FORMATTED_FIELDS had

collapsing disabled completely. That made some inconsistencies in the HTML markup (i.e., a m.css note in article summary would look slightly differently compared to a note in article content because of the additional

). Now

s are collapsed for FORMATTED_FIELDS as well and the HTML writer has an additional exception that it *does not* remove

s from nodes that are directly inside field bodies. --- pelican-plugins/m/htmlsanity.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pelican-plugins/m/htmlsanity.py b/pelican-plugins/m/htmlsanity.py index 24dc5fb6..65d920d5 100644 --- a/pelican-plugins/m/htmlsanity.py +++ b/pelican-plugins/m/htmlsanity.py @@ -409,8 +409,10 @@ class SaneHtmlTranslator(HTMLTranslator): Determine if the

tags around paragraph ``node`` can be omitted. """ if (isinstance(node.parent, nodes.document) or - isinstance(node.parent, nodes.compound)): - # Never compact paragraphs in document or compound. + isinstance(node.parent, nodes.compound) or + isinstance(node.parent, nodes.field_body)): + # Never compact paragraphs in document, compound or directly in + # field bodies (such as article summary or page footer) return False for key, value in node.attlist(): if (node.is_not_default(key) and @@ -504,7 +506,6 @@ class _SaneFieldBodyTranslator(SaneHtmlTranslator): def __init__(self, document): SaneHtmlTranslator.__init__(self, document) - self.compact_p = None def astext(self): return ''.join(self.body) -- 2.30.2