From c934532ea20bda740fb91f952c618810464e4992 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 26 Apr 2020 18:06:57 +0200 Subject: [PATCH] Loosened the restriction on the synopsis tag a bit --- nw/gui/tools/dochighlight.py | 12 ++++++++---- nw/project/index.py | 9 +++++++-- sample/sampleNovel/data_6/a2d6d5f4f401_main.nwd | 2 +- sample/sampleNovel/nwProject.nwx | 6 +++--- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/nw/gui/tools/dochighlight.py b/nw/gui/tools/dochighlight.py index 26f7fe61..297cdeea 100644 --- a/nw/gui/tools/dochighlight.py +++ b/nw/gui/tools/dochighlight.py @@ -267,11 +267,15 @@ class GuiDocHighlighter(QSyntaxHighlighter): self.setFormat(4, len(theText), self.hStyles["header4"]) elif theText.startswith("%"): # Comments - if theText.startswith("%synopsis:"): - self.setFormat(0, 10, self.hStyles["modifier"]) - self.setFormat(10, len(theText), self.hStyles["hidden"]) + toCheck = theText[1:].lstrip().lower() + tLen = len(theText) + cLen = len(toCheck) + cOff = tLen - cLen + if toCheck.startswith("synopsis:"): + self.setFormat(0, cOff+9, self.hStyles["modifier"]) + self.setFormat(cOff+9, tLen, self.hStyles["hidden"]) else: - self.setFormat(0, len(theText), self.hStyles["hidden"]) + self.setFormat(0, tLen, self.hStyles["hidden"]) else: # Text Paragraph for rX, xFmt in self.rxRules: diff --git a/nw/project/index.py b/nw/project/index.py index fe0495e8..b2e20455 100644 --- a/nw/project/index.py +++ b/nw/project/index.py @@ -308,9 +308,14 @@ class NWIndex(): self.indexNoteRef(tHandle, aLine, nLine, nTitle) self.indexTag(tHandle, aLine, nLine, itemClass) - elif aLine.startswith(r"%synopsis:"): + elif aLine.startswith(r"%"): if nTitle > 0: - self.indexSynopsis(tHandle, isNovel, aLine[10:].strip(), nTitle) + toCheck = aLine[1:].lstrip().lower() + tLen = len(aLine) + cLen = len(toCheck) + cOff = tLen - cLen + if toCheck.startswith("synopsis:"): + self.indexSynopsis(tHandle, isNovel, aLine[cOff+9:].strip(), nTitle) # Count words for remaining text after last heading if nTitle > 0: diff --git a/sample/sampleNovel/data_6/a2d6d5f4f401_main.nwd b/sample/sampleNovel/data_6/a2d6d5f4f401_main.nwd index c9e0b7a9..59cb746f 100644 --- a/sample/sampleNovel/data_6/a2d6d5f4f401_main.nwd +++ b/sample/sampleNovel/data_6/a2d6d5f4f401_main.nwd @@ -3,5 +3,5 @@ @pov: Jane @location: Earth -%synopsis: We can add a chapter file, but keep the scene files separate. In the chapter file we can set the meta data that applies to the whole chapter if we wish to. +% Synopsis: We can add a chapter file, but keep the scene files separate. In the chapter file we can set the meta data that applies to the whole chapter if we wish to. diff --git a/sample/sampleNovel/nwProject.nwx b/sample/sampleNovel/nwProject.nwx index 5b4c6835..f2b5d09e 100644 --- a/sample/sampleNovel/nwProject.nwx +++ b/sample/sampleNovel/nwProject.nwx @@ -1,5 +1,5 @@ - + Sample Project Sample Project @@ -71,7 +71,7 @@ 12 3 0 - 214 + 215 Making a Scene @@ -83,7 +83,7 @@ 1199 216 7 - 19 + 950 Another Scene