Added a cssStyles flag that is needed to add styles at all to generated HTML

This commit is contained in:
Veronica K. B. Olsen
2020-06-01 22:37:10 +02:00
parent 87a4b26a62
commit 322a114ce5
+12 -2
View File
@@ -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 = {
"<" : "&lt;",
@@ -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;}")