From c7533c165f52ebb56cd0fa767526ff669e3bb6f2 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sat, 30 May 2020 11:43:08 +0200 Subject: [PATCH] Fixed a bug in the tokenizer for root folder headings --- nw/core/tokenizer.py | 62 +++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/nw/core/tokenizer.py b/nw/core/tokenizer.py index 1dc573ca..70599d59 100644 --- a/nw/core/tokenizer.py +++ b/nw/core/tokenizer.py @@ -217,7 +217,7 @@ class Tokenizer(): theTitle = "Notes: %s" % theItem.itemName self.theTokens = [] self.theTokens.append(( - self.T_TITLE, theTitle, None, self.A_PBB | self.A_CENTRE + self.T_TITLE, 0, theTitle, None, self.A_PBB | self.A_CENTRE )) self.theMarkdown = "# %s\n\n" % theTitle @@ -320,8 +320,10 @@ class Tokenizer(): # Tag lines starting with specific characters if len(aLine.strip()) == 0: self.theTokens.append(( - self.T_EMPTY, nLine, - "", None, + self.T_EMPTY, + nLine, + "", + None, self.A_NONE )) tmpMarkdown.append("\n") @@ -330,16 +332,20 @@ class Tokenizer(): cLine = aLine[1:].strip() if cLine.lower().startswith("synopsis:"): self.theTokens.append(( - self.T_SYNOPSIS, nLine, - cLine[9:].strip(), None, + self.T_SYNOPSIS, + nLine, + cLine[9:].strip(), + None, self.A_NONE )) if self.doSynopsis: tmpMarkdown.append("%s\n" % aLine) else: self.theTokens.append(( - self.T_COMMENT, nLine, - aLine[1:].strip(), None, + self.T_COMMENT, + nLine, + aLine[1:].strip(), + None, self.A_NONE )) if self.doComments: @@ -347,8 +353,10 @@ class Tokenizer(): elif aLine[0] == "@": self.theTokens.append(( - self.T_KEYWORD, nLine, - aLine[1:].strip(), None, + self.T_KEYWORD, + nLine, + aLine[1:].strip(), + None, self.A_NONE )) if self.doKeywords: @@ -356,32 +364,40 @@ class Tokenizer(): elif aLine[:2] == "# ": self.theTokens.append(( - self.T_HEAD1, nLine, - aLine[2:].strip(), None, + self.T_HEAD1, + nLine, + aLine[2:].strip(), + None, self.A_NONE )) tmpMarkdown.append("%s\n" % aLine) elif aLine[:3] == "## ": self.theTokens.append(( - self.T_HEAD2, nLine, - aLine[3:].strip(), None, + self.T_HEAD2, + nLine, + aLine[3:].strip(), + None, self.A_NONE )) tmpMarkdown.append("%s\n" % aLine) elif aLine[:4] == "### ": self.theTokens.append(( - self.T_HEAD3, nLine, - aLine[4:].strip(), None, + self.T_HEAD3, + nLine, + aLine[4:].strip(), + None, self.A_NONE )) tmpMarkdown.append("%s\n" % aLine) elif aLine[:5] == "#### ": self.theTokens.append(( - self.T_HEAD4, nLine, - aLine[5:].strip(), None, + self.T_HEAD4, + nLine, + aLine[5:].strip(), + None, self.A_NONE )) tmpMarkdown.append("%s\n" % aLine) @@ -407,16 +423,20 @@ class Tokenizer(): # sorted by position fmtPos = sorted(fmtPos, key=itemgetter(0)) self.theTokens.append(( - self.T_TEXT, nLine, - aLine, fmtPos, + self.T_TEXT, + nLine, + aLine, + fmtPos, self.A_NONE )) tmpMarkdown.append("%s\n" % aLine) # Always add an empty line at the end self.theTokens.append(( - self.T_EMPTY, nLine, - "", None, + self.T_EMPTY, + nLine, + "", + None, self.A_NONE )) tmpMarkdown.append("\n")