Added more characters as valid word separators to the highlighter regex

This commit is contained in:
Veronica K. B. Olsen
2019-11-16 12:31:49 +01:00
parent 82aa1ad0a9
commit 2ab7828179
4 changed files with 19 additions and 11 deletions
+8 -2
View File
@@ -18,6 +18,8 @@ from PyQt5.QtGui import (
QColor, QTextCharFormat, QFont, QSyntaxHighlighter, QBrush
)
from nw.constants import nwUnicode
logger = logging.getLogger(__name__)
class GuiDocHighlighter(QSyntaxHighlighter):
@@ -150,7 +152,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
# Non-breaking Space
self.hRules.append((
"[\u00a0]+", {
"[%s]+" % nwUnicode.U_NBSP, {
0 : self.hStyles["nobreak"],
}
))
@@ -209,7 +211,11 @@ class GuiDocHighlighter(QSyntaxHighlighter):
self.rxRules.append((hReg, regRules))
# Build a QRegExp for spell checker
self.spellRx = QRegularExpression(r"\b[^\s]+\b")
# Include additional characters that the highlighter should
# consider to be word separators
wordSep = "_+"
wordSep += nwUnicode.U_EMDASH
self.spellRx = QRegularExpression("\\b[^\\s%s]+\\b" % wordSep)
self.spellRx.setPatternOptions(QRegularExpression.UseUnicodePropertiesOption)
return True
@@ -12,6 +12,8 @@ In addition, the editor supports automatic formatting of “quotes”, both doub
If you have the need for it, you can also add text that can be automatically replaced by other text when you generate a preview or export the project. Now, lets auto-replace this A with <A>, and this C with <C>. While <E> is just <E>. Press Ctrl+R to see what this looks like in the view pane.
The editor also supports non breaking spaces, and the spell checker accepts long dashes—like this—as valid word separators.
#### Some Section Here
If you need to split a scene file up into further pieces, you can do so with the level four heading, like above. This is referred to as a section.
+8 -8
View File
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="0.4.0" fileVersion="1.0" timeStamp="2019-11-07 22:03:42">
<novelWriterXML appVersion="0.4.1" fileVersion="1.0" timeStamp="2019-11-16 12:31:19">
<project>
<name>Sample Project</name>
<title>Sample Project</title>
@@ -9,9 +9,9 @@
</project>
<settings>
<spellCheck>True</spellCheck>
<lastEdited>96b68994dfa3d</lastEdited>
<lastEdited>636b6aa9b697b</lastEdited>
<lastViewed>b3e74dbc1f584</lastViewed>
<lastWordCount>855</lastWordCount>
<lastWordCount>875</lastWordCount>
<autoReplace>
<A>B</A>
<B>E</B>
@@ -79,10 +79,10 @@
<status>1st Draft</status>
<expanded>False</expanded>
<layout>SCENE</layout>
<charCount>1076</charCount>
<wordCount>196</wordCount>
<paraCount>6</paraCount>
<cursorPos>59</cursorPos>
<charCount>1199</charCount>
<wordCount>216</wordCount>
<paraCount>7</paraCount>
<cursorPos>949</cursorPos>
</item>
<item handle="bc0cbd2a407f3" order="2" parent="e7ded148d6e4a">
<name>Another Scene</name>
@@ -118,7 +118,7 @@
<charCount>1692</charCount>
<wordCount>313</wordCount>
<paraCount>6</paraCount>
<cursorPos>216</cursorPos>
<cursorPos>530</cursorPos>
</item>
<item handle="88706ddc78b1b" order="5" parent="e7ded148d6e4a">
<name>Chapter Two</name>
+1 -1
View File
@@ -13,4 +13,4 @@ print("")
profMainWindows = pstats.Stats(path.join(profDir,"testMainWindows.prof"))
profMainWindows.sort_stats("cumtime")
profMainWindows.print_stats("nw",50)
profMainWindows.print_stats("nw/")