From: Vladimír Vondruš Date: Thu, 2 Nov 2017 17:51:47 +0000 (+0100) Subject: m.htmlsanity: better consistency for collapsed

s in additional fields. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=0f1036e8a6df0235dc424f5f02be027b56331478;p=blog.git 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. --- 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)