Make a few improvements to regex and remove debug output
This commit is contained in:
@@ -1137,15 +1137,10 @@ class Tokenizer(ABC):
|
|||||||
# Match Dialogue
|
# Match Dialogue
|
||||||
if self._rxDialogue:
|
if self._rxDialogue:
|
||||||
for regEx, fmtB, fmtE in self._rxDialogue:
|
for regEx, fmtB, fmtE in self._rxDialogue:
|
||||||
rxItt = regEx.globalMatch(text, 0)
|
if (rxMatch := regEx.match(text, 0)).hasMatch():
|
||||||
rxMatch = regEx.match(text, 0)
|
|
||||||
if rxMatch.hasMatch():
|
|
||||||
temp.append((rxMatch.capturedStart(0), 0, fmtB, ""))
|
temp.append((rxMatch.capturedStart(0), 0, fmtB, ""))
|
||||||
temp.append((rxMatch.capturedEnd(0), 0, fmtE, ""))
|
temp.append((rxMatch.capturedEnd(0), 0, fmtE, ""))
|
||||||
|
|
||||||
print(text)
|
|
||||||
print(temp)
|
|
||||||
|
|
||||||
# Post-process text and format
|
# Post-process text and format
|
||||||
result = text
|
result = text
|
||||||
formats = []
|
formats = []
|
||||||
|
|||||||
@@ -2030,6 +2030,9 @@ class GuiDocEditor(QPlainTextEdit):
|
|||||||
cursor.movePosition(QtMoveLeft, QtKeepAnchor, nDelete)
|
cursor.movePosition(QtMoveLeft, QtKeepAnchor, nDelete)
|
||||||
cursor.insertText(tInsert)
|
cursor.insertText(tInsert)
|
||||||
|
|
||||||
|
# Re-highlight, since the auto-replace sometimes interferes with it
|
||||||
|
self._qDocument.syntaxHighlighter.rehighlightBlock(cursor.block())
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class RegExPatterns:
|
|||||||
def narratorBreak(self) -> QRegularExpression:
|
def narratorBreak(self) -> QRegularExpression:
|
||||||
"""Dialogue narrator break rule based on user settings."""
|
"""Dialogue narrator break rule based on user settings."""
|
||||||
sym = QRegularExpression.escape(CONFIG.narratorBreak)
|
sym = QRegularExpression.escape(CONFIG.narratorBreak)
|
||||||
rxRule = QRegularExpression(f"{sym}\\b.*?\\b{sym}")
|
rxRule = QRegularExpression(f"\\B{sym}\\S.*?\\S{sym}\\B")
|
||||||
rxRule.setPatternOptions(QRegExUnicode)
|
rxRule.setPatternOptions(QRegExUnicode)
|
||||||
return rxRule
|
return rxRule
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user