From 322a114ce53dbdc6f6d24b0ee76d399c338043a4 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Mon, 1 Jun 2020 22:37:10 +0200 Subject: [PATCH] Added a cssStyles flag that is needed to add styles at all to generated HTML --- nw/core/tohtml.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/nw/core/tohtml.py b/nw/core/tohtml.py index cb2a4baf..c451daaf 100644 --- a/nw/core/tohtml.py +++ b/nw/core/tohtml.py @@ -43,6 +43,7 @@ class ToHtml(Tokenizer): def __init__(self, theProject, theParent): Tokenizer.__init__(self, theProject, theParent) self.genMode = self.M_EXPORT + self.cssStyles = True self.repDict = { "<" : "<", @@ -78,6 +79,13 @@ class ToHtml(Tokenizer): self._buildRegEx() return + def setStyles(self, cssStyles): + """Enable/disable CSS styling. Some elements may still have + class tags. + """ + self.cssStyles = cssStyles + return + ## # Class Methods ## @@ -147,7 +155,7 @@ class ToHtml(Tokenizer): # Styles aStyle = [] - if tStyle is not None: + if tStyle is not None and self.cssStyles: if tStyle & self.A_LEFT: aStyle.append("text-align: left;") if tStyle & self.A_RIGHT: @@ -183,7 +191,7 @@ class ToHtml(Tokenizer): if tType == self.T_EMPTY: if parStyle is None: parStyle = "" - if hasHardBreak: + if hasHardBreak and self.cssStyles: parClass = " class='break'" else: parClass = "" @@ -250,6 +258,8 @@ class ToHtml(Tokenizer): """Generate a stylesheet appropriate for the current settings. """ theStyles = [] + if not self.cssStyles: + return theStyles if self.doJustify: theStyles.append(r"p {text-align: justify;}")