Updated tokenizer, and added html converter as a subclass

This commit is contained in:
Veronica K. B. Olsen
2019-05-07 18:47:55 +02:00
parent e0936b5f33
commit 83169d9075
3 changed files with 74 additions and 3 deletions
+7 -2
View File
@@ -13,8 +13,8 @@
import logging
import nw
from operator import itemgetter
from PyQt5.QtCore import QRegularExpression
from nw.project.document import NWDoc
logger = logging.getLogger(__name__)
@@ -38,6 +38,7 @@ class Tokenizer():
self.theHandle = None
self.theItem = None
self.theTokens = None
self.theResult = None
return
@@ -107,9 +108,13 @@ class Tokenizer():
xPos = rxMatch.capturedStart(n)
xLen = rxMatch.capturedLength(n)
fmtPos.append([xPos,xLen,theKeys[n]])
# Save the line as is, but append the array of formatting locations
# Save the line as is, but append the array of formatting locations sorted by position
fmtPos = sorted(fmtPos,key=itemgetter(0))
self.theTokens.append(("text",aLine,fmtPos))
# Always add an empty line at the end
self.theTokens.append(("empty","",None))
# print(self.theTokens)
return