From 5f033a98bfeb662eb53418c6e557754a6d9e9976 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 23 Aug 2020 20:55:30 +0200 Subject: [PATCH 1/3] Remove the alternative double apostrophe again --- nw/constants/constants.py | 2 -- nw/constants/enum.py | 1 - nw/core/tohtml.py | 1 - nw/gui/doceditor.py | 2 -- nw/gui/mainmenu.py | 11 ++--------- nw/guimain.py | 1 - 6 files changed, 2 insertions(+), 16 deletions(-) diff --git a/nw/constants/constants.py b/nw/constants/constants.py index e810dabf..3bfc9125 100644 --- a/nw/constants/constants.py +++ b/nw/constants/constants.py @@ -234,7 +234,6 @@ class nwUnicode: U_EMDASH = "\u2014" # Long dash U_HELLIP = "\u2026" # Ellipsis U_MAPOSS = "\u02bc" # Modifier letter single apostrophe - U_MAPOSD = "\u02ee" # Modifier letter double apostrophe ## Spaces and Lines U_NBSP = "\u00a0" # Non-breaking space @@ -286,7 +285,6 @@ class nwUnicode: H_EMDASH = "—" H_HELLIP = "…" H_MAPOSS = "ʼ" - H_MAPOSD = "ˮ" ## Spaces H_NBSP = " " diff --git a/nw/constants/enum.py b/nw/constants/enum.py index 81200a63..d7c3bde2 100644 --- a/nw/constants/enum.py +++ b/nw/constants/enum.py @@ -113,7 +113,6 @@ class nwDocInsert(Enum): QUOTE_LD = 10 QUOTE_RD = 11 MODAPOS_S = 12 - MODAPOS_D = 13 # END Enum nwDocInsert diff --git a/nw/core/tohtml.py b/nw/core/tohtml.py index 6053082a..cb8cfa1a 100644 --- a/nw/core/tohtml.py +++ b/nw/core/tohtml.py @@ -55,7 +55,6 @@ class ToHtml(Tokenizer): nwUnicode.U_THNSP : nwUnicode.H_THNSP, nwUnicode.U_THNBSP : nwUnicode.H_THNBSP, nwUnicode.U_MAPOSS : nwUnicode.H_RSQUO, - nwUnicode.U_MAPOSD : nwUnicode.H_RDQUO, } self.revDict = {} self.reReplace = [] diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index dc25b909..ca860561 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -614,8 +614,6 @@ class GuiDocEditor(QTextEdit): theText = nwUnicode.U_HELLIP elif theInsert == nwDocInsert.MODAPOS_S: theText = nwUnicode.U_MAPOSS - elif theInsert == nwDocInsert.MODAPOS_D: - theText = nwUnicode.U_MAPOSD elif theInsert == nwDocInsert.QUOTE_LS: theText = self.typSQOpen elif theInsert == nwDocInsert.QUOTE_RS: diff --git a/nw/gui/mainmenu.py b/nw/gui/mainmenu.py index 949a8c77..b904ffd9 100644 --- a/nw/gui/mainmenu.py +++ b/nw/gui/mainmenu.py @@ -554,20 +554,13 @@ class GuiMainMenu(QMenuBar): # Insert > Separator self.insertMenu.addSeparator() - # Insert > Alt. Single Apostrophe - self.aInsMSApos = QAction("Alt. Single Apostrophe", self) + # Insert > Alternative Apostrophe + self.aInsMSApos = QAction("Alternative Apostrophe", self) self.aInsMSApos.setStatusTip("Insert unicode modifier letter single apostrophe") self.aInsMSApos.setShortcut("Ctrl+K, '") self.aInsMSApos.triggered.connect(lambda: self._docInsert(nwDocInsert.MODAPOS_S)) self.insertMenu.addAction(self.aInsMSApos) - # Insert > Alt. Double Apostrophe - self.aInsMDApos = QAction("Alt. Double Apostrophe", self) - self.aInsMDApos.setStatusTip("Insert unicode modifier letter double apostrophe") - self.aInsMDApos.setShortcut("Ctrl+K, \"") - self.aInsMDApos.triggered.connect(lambda: self._docInsert(nwDocInsert.MODAPOS_D)) - self.insertMenu.addAction(self.aInsMDApos) - # Insert > Separator self.insertMenu.addSeparator() diff --git a/nw/guimain.py b/nw/guimain.py index 48ea5c73..66bcc7cb 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -1040,7 +1040,6 @@ class GuiMain(QMainWindow): self.addAction(self.mainMenu.aInsQuoteLD) self.addAction(self.mainMenu.aInsQuoteRD) self.addAction(self.mainMenu.aInsMSApos) - self.addAction(self.mainMenu.aInsMDApos) self.addAction(self.mainMenu.aInsHardBreak) self.addAction(self.mainMenu.aInsNBSpace) self.addAction(self.mainMenu.aInsThinSpace) From f1f7697df2e15655d4f2526fcc5107fdecd599c0 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 23 Aug 2020 20:55:54 +0200 Subject: [PATCH 2/3] Clean up docs and test --- docs/source/int_interface.rst | 3 +-- docs/source/int_typography.rst | 24 +++++++++--------------- tests/test_gui.py | 4 ---- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/docs/source/int_interface.rst b/docs/source/int_interface.rst index 9191a5d8..3c4b772a 100644 --- a/docs/source/int_interface.rst +++ b/docs/source/int_interface.rst @@ -415,8 +415,7 @@ combination for the inserted character or punctuation. ":kbd:`Ctrl`:kbd:`K`, :kbd:`2`", "Insert a right single quote." ":kbd:`Ctrl`:kbd:`K`, :kbd:`3`", "Insert a left double quote." ":kbd:`Ctrl`:kbd:`K`, :kbd:`4`", "Insert a right double quote." - ":kbd:`Ctrl`:kbd:`K`, :kbd:`'`", "Insert a modifier single apostrophe." - ":kbd:`Ctrl`:kbd:`K`, :kbd:`""`", "Insert a modifier double apostrophe." + ":kbd:`Ctrl`:kbd:`K`, :kbd:`'`", "Insert a modifier apostrophe." ":kbd:`Ctrl`:kbd:`K`, :kbd:`Return`", "Insert a hard line break." ":kbd:`Ctrl`:kbd:`K`, :kbd:`Space`", "Insert a non-breaking space." ":kbd:`Ctrl`:kbd:`K`, :kbd:`Shift`:kbd:`Space`", "Insert a thin space." diff --git a/docs/source/int_typography.rst b/docs/source/int_typography.rst index debddb50..1903ba15 100644 --- a/docs/source/int_typography.rst +++ b/docs/source/int_typography.rst @@ -52,26 +52,20 @@ Modifier Letter Apostrophes --------------------------- The auto-replace feature will consider any right-facing single straight quote as a quote symbol, -even if it's intended as an apostrophe. This also includes the syntax highlighter, which may decide -to use an apostrophe as the closing symbol of a single quoted string. +even if it's intended as an apostrophe. This also includes the syntax highlighter, which may assume +the first following apostrophe is the closing symbol of a single quoted region of text. -Alternative apostrophes, both single and double, are available. They are special Unicode characters -that are not categorised as punctuation, but modifiers. They are usually renderred the same way as -right single and double quotation marks, but not always, depending on the font. - -There is a Wikipedia article for both the single_ and double_ version of this symbol, explaining -what they're for. - -You can use these symbols if you want, and especially if you have an apostrophe within a single -quoted piece of text. +To get around this, an alternative apostrophe is available. It is a special Unicode character that +is not categorised as punctuation, but as a modifier. It is usually renderred the same way as right +single quotation marks, but not always, depending on the font. There is a Wikipedia article for the +`Modifier letter apostrophe`_ with more details. .. note:: On export with the :guilabel:`Build Novel Project` tool, these apostrophes will be replaced - automatically with the corresponding right hand quote symbols. In that respect, it doesn't matter - if you mix them. + automatically with the corresponding right hand quote symbols as is generally recommended. + Therefore it doesn't really matter if you only use them to correct highlighting. -.. _single: https://en.wikipedia.org/wiki/Modifier_letter_apostrophe -.. _double: https://en.wikipedia.org/wiki/Modifier_letter_double_apostrophe +.. _Modifier letter apostrophe: https://en.wikipedia.org/wiki/Modifier_letter_apostrophe Special Space Symbols diff --git a/tests/test_gui.py b/tests/test_gui.py index 318c9f1a..22f82c61 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -1053,10 +1053,6 @@ def testInsertMenu(qtbot, nwTempGUI, nwFuncTemp, nwTemp): assert nwGUI.docEditor.getText() == nwUnicode.U_MAPOSS nwGUI.docEditor.clear() - nwGUI.mainMenu.aInsMDApos.activate(QAction.Trigger) - assert nwGUI.docEditor.getText() == nwUnicode.U_MAPOSD - nwGUI.docEditor.clear() - nwGUI.mainMenu.aInsHardBreak.activate(QAction.Trigger) assert nwGUI.docEditor.getText() == " \n" nwGUI.docEditor.clear() From 9567e3dc4a68351bc7ecd3f9876520d979093d9c Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 23 Aug 2020 20:56:15 +0200 Subject: [PATCH 3/3] Improve regex matches for quote strings --- nw/gui/dochighlight.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nw/gui/dochighlight.py b/nw/gui/dochighlight.py index 23902db1..a374c9a6 100644 --- a/nw/gui/dochighlight.py +++ b/nw/gui/dochighlight.py @@ -143,17 +143,17 @@ class GuiDocHighlighter(QSyntaxHighlighter): # Quoted Strings if self.mainConf.highlightQuotes: self.hRules.append(( - "{:s}(.+?){:s}".format('"', '"'), { + "\\B{:s}(.*?){:s}\\B".format('"', '"'), { 0 : self.hStyles["dialogue1"], } )) self.hRules.append(( - "{:s}(.+?){:s}".format(*self.mainConf.fmtDoubleQuotes), { + "\\B{:s}(.*?){:s}\\B".format(*self.mainConf.fmtDoubleQuotes), { 0 : self.hStyles["dialogue2"], } )) self.hRules.append(( - "{:s}(.+?){:s}".format(*self.mainConf.fmtSingleQuotes), { + "\\B{:s}(.*?){:s}\\B".format(*self.mainConf.fmtSingleQuotes), { 0 : self.hStyles["dialogue3"], } ))