From 7816bf5b8741539531ed75f564ff911234281b19 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 5 Jul 2020 16:56:06 +0200 Subject: [PATCH] Connected the Roman numbers function to the build tool --- nw/core/tokenizer.py | 6 +++++- nw/gui/build.py | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/nw/core/tokenizer.py b/nw/core/tokenizer.py index eba1ab65..cddce253 100644 --- a/nw/core/tokenizer.py +++ b/nw/core/tokenizer.py @@ -33,7 +33,7 @@ from operator import itemgetter from PyQt5.QtCore import QRegularExpression from nw.core.document import NWDoc -from nw.core.tools import numberToWord +from nw.core.tools import numberToWord, numberToRoman from nw.constants import nwItemLayout, nwItemType, nwRegEx logger = logging.getLogger(__name__) @@ -690,6 +690,10 @@ class Tokenizer(): theTitle = theTitle.replace(r"%sca%", str(self.numAbsScene)) if r"%chw%" in theTitle: theTitle = theTitle.replace(r"%chw%", numberToWord(self.numChapter,"en")) + if r"%chi%" in theTitle: + theTitle = theTitle.replace(r"%chi%", numberToRoman(self.numChapter, True)) + if r"%chI%" in theTitle: + theTitle = theTitle.replace(r"%chI%", numberToRoman(self.numChapter, False)) return theTitle # END Class Tokenizer diff --git a/nw/gui/build.py b/nw/gui/build.py index dab7360e..7220639b 100644 --- a/nw/gui/build.py +++ b/nw/gui/build.py @@ -46,7 +46,7 @@ from PyQt5.QtWidgets import ( from nw.common import fuzzyTime from nw.gui.custom import QSwitch -from nw.core import ToHtml +from nw.core import ToHtml, numberToRoman from nw.constants import ( nwAlert, nwFiles, nwItemType, nwItemLayout, nwItemClass ) @@ -105,6 +105,8 @@ class GuiBuildNovel(QDialog): r"%title% for the title as set in the document
" r"%ch% for chapter number (1, 2, 3)
" r"%chw% for chapter number as a word (one, two)
" + r"%chI% for chapter number in upper case Roman
" + r"%chi% for chapter number in lower case Roman
" r"%sc% for scene number within chapter
" r"%sca% for scene number within novel" )