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:`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."
+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,
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
-2
View File
@@ -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 = " "
-1
View File
@@ -113,7 +113,6 @@ class nwDocInsert(Enum):
QUOTE_LD = 10
QUOTE_RD = 11
MODAPOS_S = 12
MODAPOS_D = 13
# END Enum nwDocInsert
-1
View File
@@ -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 = []
-2
View File
@@ -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:
+3 -3
View File
@@ -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"],
}
))
+2 -9
View File
@@ -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()
-1
View File
@@ -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)
-4
View File
@@ -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()