Merge pull request #430 from vkbo/drop_double_apos

Quote symbols and highlighting
This commit is contained in:
Veronica K. Berglyd Olsen
2020-08-23 21:07:59 +02:00
committed by GitHub
10 changed files with 15 additions and 40 deletions
+1 -2
View File
@@ -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:`2`", "Insert a right single quote."
":kbd:`Ctrl`:kbd:`K`, :kbd:`3`", "Insert a left double 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:`4`", "Insert a right double quote."
":kbd:`Ctrl`:kbd:`K`, :kbd:`'`", "Insert a modifier single apostrophe." ":kbd:`Ctrl`:kbd:`K`, :kbd:`'`", "Insert a modifier apostrophe."
":kbd:`Ctrl`:kbd:`K`, :kbd:`""`", "Insert a modifier double apostrophe."
":kbd:`Ctrl`:kbd:`K`, :kbd:`Return`", "Insert a hard line break." ":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:`Space`", "Insert a non-breaking space."
":kbd:`Ctrl`:kbd:`K`, :kbd:`Shift`:kbd:`Space`", "Insert a thin space." ":kbd:`Ctrl`:kbd:`K`, :kbd:`Shift`:kbd:`Space`", "Insert a thin space."
+9 -15
View File
@@ -52,26 +52,20 @@ Modifier Letter Apostrophes
--------------------------- ---------------------------
The auto-replace feature will consider any right-facing single straight quote as a quote symbol, 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 even if it's intended as an apostrophe. This also includes the syntax highlighter, which may assume
to use an apostrophe as the closing symbol of a single quoted string. 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 To get around this, an alternative apostrophe is available. It is a special Unicode character that
that are not categorised as punctuation, but modifiers. They are usually renderred the same way as is not categorised as punctuation, but as a modifier. It is usually renderred the same way as right
right single and double quotation marks, but not always, depending on the font. single quotation marks, but not always, depending on the font. There is a Wikipedia article for the
`Modifier letter apostrophe`_ with more details.
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.
.. note:: .. note::
On export with the :guilabel:`Build Novel Project` tool, these apostrophes will be replaced 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 automatically with the corresponding right hand quote symbols as is generally recommended.
if you mix them. Therefore it doesn't really matter if you only use them to correct highlighting.
.. _single: https://en.wikipedia.org/wiki/Modifier_letter_apostrophe .. _Modifier letter apostrophe: https://en.wikipedia.org/wiki/Modifier_letter_apostrophe
.. _double: https://en.wikipedia.org/wiki/Modifier_letter_double_apostrophe
Special Space Symbols Special Space Symbols
-2
View File
@@ -234,7 +234,6 @@ class nwUnicode:
U_EMDASH = "\u2014" # Long dash U_EMDASH = "\u2014" # Long dash
U_HELLIP = "\u2026" # Ellipsis U_HELLIP = "\u2026" # Ellipsis
U_MAPOSS = "\u02bc" # Modifier letter single apostrophe U_MAPOSS = "\u02bc" # Modifier letter single apostrophe
U_MAPOSD = "\u02ee" # Modifier letter double apostrophe
## Spaces and Lines ## Spaces and Lines
U_NBSP = "\u00a0" # Non-breaking space U_NBSP = "\u00a0" # Non-breaking space
@@ -286,7 +285,6 @@ class nwUnicode:
H_EMDASH = "—" H_EMDASH = "—"
H_HELLIP = "…" H_HELLIP = "…"
H_MAPOSS = "ʼ" H_MAPOSS = "ʼ"
H_MAPOSD = "ˮ"
## Spaces ## Spaces
H_NBSP = " " H_NBSP = " "
-1
View File
@@ -113,7 +113,6 @@ class nwDocInsert(Enum):
QUOTE_LD = 10 QUOTE_LD = 10
QUOTE_RD = 11 QUOTE_RD = 11
MODAPOS_S = 12 MODAPOS_S = 12
MODAPOS_D = 13
# END Enum nwDocInsert # END Enum nwDocInsert
-1
View File
@@ -55,7 +55,6 @@ class ToHtml(Tokenizer):
nwUnicode.U_THNSP : nwUnicode.H_THNSP, nwUnicode.U_THNSP : nwUnicode.H_THNSP,
nwUnicode.U_THNBSP : nwUnicode.H_THNBSP, nwUnicode.U_THNBSP : nwUnicode.H_THNBSP,
nwUnicode.U_MAPOSS : nwUnicode.H_RSQUO, nwUnicode.U_MAPOSS : nwUnicode.H_RSQUO,
nwUnicode.U_MAPOSD : nwUnicode.H_RDQUO,
} }
self.revDict = {} self.revDict = {}
self.reReplace = [] self.reReplace = []
-2
View File
@@ -614,8 +614,6 @@ class GuiDocEditor(QTextEdit):
theText = nwUnicode.U_HELLIP theText = nwUnicode.U_HELLIP
elif theInsert == nwDocInsert.MODAPOS_S: elif theInsert == nwDocInsert.MODAPOS_S:
theText = nwUnicode.U_MAPOSS theText = nwUnicode.U_MAPOSS
elif theInsert == nwDocInsert.MODAPOS_D:
theText = nwUnicode.U_MAPOSD
elif theInsert == nwDocInsert.QUOTE_LS: elif theInsert == nwDocInsert.QUOTE_LS:
theText = self.typSQOpen theText = self.typSQOpen
elif theInsert == nwDocInsert.QUOTE_RS: elif theInsert == nwDocInsert.QUOTE_RS:
+3 -3
View File
@@ -143,17 +143,17 @@ class GuiDocHighlighter(QSyntaxHighlighter):
# Quoted Strings # Quoted Strings
if self.mainConf.highlightQuotes: if self.mainConf.highlightQuotes:
self.hRules.append(( self.hRules.append((
"{:s}(.+?){:s}".format('"', '"'), { "\\B{:s}(.*?){:s}\\B".format('"', '"'), {
0 : self.hStyles["dialogue1"], 0 : self.hStyles["dialogue1"],
} }
)) ))
self.hRules.append(( self.hRules.append((
"{:s}(.+?){:s}".format(*self.mainConf.fmtDoubleQuotes), { "\\B{:s}(.*?){:s}\\B".format(*self.mainConf.fmtDoubleQuotes), {
0 : self.hStyles["dialogue2"], 0 : self.hStyles["dialogue2"],
} }
)) ))
self.hRules.append(( self.hRules.append((
"{:s}(.+?){:s}".format(*self.mainConf.fmtSingleQuotes), { "\\B{:s}(.*?){:s}\\B".format(*self.mainConf.fmtSingleQuotes), {
0 : self.hStyles["dialogue3"], 0 : self.hStyles["dialogue3"],
} }
)) ))
+2 -9
View File
@@ -554,20 +554,13 @@ class GuiMainMenu(QMenuBar):
# Insert > Separator # Insert > Separator
self.insertMenu.addSeparator() self.insertMenu.addSeparator()
# Insert > Alt. Single Apostrophe # Insert > Alternative Apostrophe
self.aInsMSApos = QAction("Alt. Single Apostrophe", self) self.aInsMSApos = QAction("Alternative Apostrophe", self)
self.aInsMSApos.setStatusTip("Insert unicode modifier letter single apostrophe") self.aInsMSApos.setStatusTip("Insert unicode modifier letter single apostrophe")
self.aInsMSApos.setShortcut("Ctrl+K, '") self.aInsMSApos.setShortcut("Ctrl+K, '")
self.aInsMSApos.triggered.connect(lambda: self._docInsert(nwDocInsert.MODAPOS_S)) self.aInsMSApos.triggered.connect(lambda: self._docInsert(nwDocInsert.MODAPOS_S))
self.insertMenu.addAction(self.aInsMSApos) 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 # Insert > Separator
self.insertMenu.addSeparator() self.insertMenu.addSeparator()
-1
View File
@@ -1040,7 +1040,6 @@ class GuiMain(QMainWindow):
self.addAction(self.mainMenu.aInsQuoteLD) self.addAction(self.mainMenu.aInsQuoteLD)
self.addAction(self.mainMenu.aInsQuoteRD) self.addAction(self.mainMenu.aInsQuoteRD)
self.addAction(self.mainMenu.aInsMSApos) self.addAction(self.mainMenu.aInsMSApos)
self.addAction(self.mainMenu.aInsMDApos)
self.addAction(self.mainMenu.aInsHardBreak) self.addAction(self.mainMenu.aInsHardBreak)
self.addAction(self.mainMenu.aInsNBSpace) self.addAction(self.mainMenu.aInsNBSpace)
self.addAction(self.mainMenu.aInsThinSpace) self.addAction(self.mainMenu.aInsThinSpace)
-4
View File
@@ -1053,10 +1053,6 @@ def testInsertMenu(qtbot, nwTempGUI, nwFuncTemp, nwTemp):
assert nwGUI.docEditor.getText() == nwUnicode.U_MAPOSS assert nwGUI.docEditor.getText() == nwUnicode.U_MAPOSS
nwGUI.docEditor.clear() 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) nwGUI.mainMenu.aInsHardBreak.activate(QAction.Trigger)
assert nwGUI.docEditor.getText() == " \n" assert nwGUI.docEditor.getText() == " \n"
nwGUI.docEditor.clear() nwGUI.docEditor.clear()