Add some comments and add text indent to HTML

This commit is contained in:
Veronica Berglyd Olsen
2024-05-27 21:08:09 +02:00
parent aa02c0f15d
commit 770cccda49
3 changed files with 23 additions and 5 deletions
+16
View File
@@ -852,6 +852,9 @@ class Tokenizer(ABC):
nToken = tokens[n+1] # Look ahead
if not self._indentFirst and cToken[0] in self.L_SKIP_INDENT:
# Unless the indentFirst flag is set, we set up the next
# paragraph to not be indented if we see a block of a
# specific type
pIndent = False
if cToken[0] == self.T_EMPTY:
@@ -872,16 +875,27 @@ class Tokenizer(ABC):
elif cToken[0] == self.T_TEXT:
# Combine lines from the same paragraph
pLines.append(cToken)
if nToken[0] != self.T_TEXT:
# Next token is not text, so we add the buffer to tokens
nLines = len(pLines)
cStyle = pLines[0][4]
if self._firstIndent and pIndent and not cStyle & self.M_ALIGNED:
# If paragraph indentation is enabled, not temporarily
# turned off, and the block is not aligned, we add the
# text indentation flag
cStyle |= self.A_IND_T
if nLines == 1:
# The paragraph contains a single line, so we just
# save that directly to the token list
self._tokens.append((
self.T_TEXT, pLines[0][1], pLines[0][2], pLines[0][3], cStyle
))
elif nLines > 1:
# The paragraph contains multiple lines, so we need to
# join them according to the line break policy, and
# recompute all the formatting markers
tTxt = ""
tFmt: T_Formats = []
for aToken in pLines:
@@ -891,6 +905,8 @@ class Tokenizer(ABC):
self._tokens.append((
self.T_TEXT, pLines[0][1], tTxt[:-1], tFmt, cStyle
))
# Reset buffer and make sure text indent is on for next pass
pLines = []
pIndent = True