Add text alignment tags

This commit is contained in:
Veronica Berglyd Olsen
2021-06-09 22:08:31 +02:00
parent 904ba9b1ca
commit 7d067f807d
4 changed files with 54 additions and 12 deletions
+26 -1
View File
@@ -436,6 +436,31 @@ class Tokenizer():
# Skip all body text
continue
# Check Alignment
tagLeft = False
tagRight = False
if aLine.startswith(">>"):
tagRight = True
aLine = aLine[2:].lstrip()
elif aLine.startswith(">>"):
tagRight = True
aLine = aLine[8:].lstrip()
if aLine.endswith("<<"):
tagLeft = True
aLine = aLine[:-2].rstrip()
elif aLine.endswith("&lt;&lt;"):
tagLeft = True
aLine = aLine[:-8].rstrip()
textAlign = self.A_NONE
if tagLeft and tagRight:
textAlign = self.A_CENTRE
elif tagLeft:
textAlign = self.A_LEFT
elif tagRight:
textAlign = self.A_RIGHT
# Otherwise we use RegEx to find formatting tags within a line of text
fmtPos = []
for theRX, theKeys in rxFormats:
@@ -452,7 +477,7 @@ class Tokenizer():
# sorted by position
fmtPos = sorted(fmtPos, key=itemgetter(0))
self.theTokens.append((
self.T_TEXT, nLine, aLine, fmtPos, self.A_NONE
self.T_TEXT, nLine, aLine, fmtPos, textAlign
))
if self.keepMarkdown:
tmpMarkdown.append("%s\n" % aLine)
+7
View File
@@ -198,6 +198,13 @@ class GuiDocHighlighter(QSyntaxHighlighter):
}
))
# Alignment Tags
self.hRules.append((
r"(^>{1,2}|<{1,2}$)", {
1 : self.hStyles["hidden"],
}
))
# Auto-Replace Tags
self.hRules.append((
r"<(\S+?)>", {