Improve single quote dialogue highlighting (#2300)
This commit is contained in:
@@ -505,7 +505,7 @@ class TextBlockData(QTextBlockUserData):
|
|||||||
text = f"{text[:s]}{pad}{text[e:]}"
|
text = f"{text[:s]}{pad}{text[e:]}"
|
||||||
self._metaData.append((s, e, res.group(0), "url"))
|
self._metaData.append((s, e, res.group(0), "url"))
|
||||||
|
|
||||||
self._text = text
|
self._text = text.replace("\u02bc", "'")
|
||||||
self._offset = offset
|
self._offset = offset
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class RegExPatterns:
|
|||||||
if CONFIG.dialogStyle in (1, 3):
|
if CONFIG.dialogStyle in (1, 3):
|
||||||
qO = CONFIG.fmtSQuoteOpen.strip()[:1]
|
qO = CONFIG.fmtSQuoteOpen.strip()[:1]
|
||||||
qC = CONFIG.fmtSQuoteClose.strip()[:1]
|
qC = CONFIG.fmtSQuoteClose.strip()[:1]
|
||||||
if qO == qC:
|
if qO == qC or qC in self.AMBIGUOUS:
|
||||||
rx.append(f"(?:\\B{qO}.+?{qC}\\B)")
|
rx.append(f"(?:\\B{qO}.+?{qC}\\B)")
|
||||||
else:
|
else:
|
||||||
rx.append(f"(?:{qO}[^{qO}]+{qC})")
|
rx.append(f"(?:{qO}[^{qO}]+{qC})")
|
||||||
@@ -102,7 +102,7 @@ class RegExPatterns:
|
|||||||
if CONFIG.dialogStyle in (2, 3):
|
if CONFIG.dialogStyle in (2, 3):
|
||||||
qO = CONFIG.fmtDQuoteOpen.strip()[:1]
|
qO = CONFIG.fmtDQuoteOpen.strip()[:1]
|
||||||
qC = CONFIG.fmtDQuoteClose.strip()[:1]
|
qC = CONFIG.fmtDQuoteClose.strip()[:1]
|
||||||
if qO == qC:
|
if qO == qC or qC in self.AMBIGUOUS:
|
||||||
rx.append(f"(?:\\B{qO}.+?{qC}\\B)")
|
rx.append(f"(?:\\B{qO}.+?{qC}\\B)")
|
||||||
else:
|
else:
|
||||||
rx.append(f"(?:{qO}[^{qO}]+{qC})")
|
rx.append(f"(?:{qO}[^{qO}]+{qC})")
|
||||||
|
|||||||
@@ -310,11 +310,11 @@ def testTextPatterns_DialogueStyle():
|
|||||||
assert allMatches(regEx, 'one "two" three') == []
|
assert allMatches(regEx, 'one "two" three') == []
|
||||||
|
|
||||||
# Check with no whitespace, single quote
|
# Check with no whitespace, single quote
|
||||||
assert allMatches(regEx, "one\u2018two\u2019three") == [
|
# The apostrophe ambiguity rule should kick in here
|
||||||
[("\u2018two\u2019", 3, 8)]
|
assert allMatches(regEx, "one\u2018two\u2019three") == []
|
||||||
]
|
assert allMatches(regEx, "one\u2018two\u2019 three") == []
|
||||||
assert allMatches(regEx, "one\u2018two\u2019 three") == [
|
assert allMatches(regEx, "one \u2018two\u02bc three\u2019 four") == [
|
||||||
[("\u2018two\u2019", 3, 8)]
|
[("\u2018two\u02bc three\u2019", 4, 16)],
|
||||||
]
|
]
|
||||||
|
|
||||||
# Check with no whitespace, double quote
|
# Check with no whitespace, double quote
|
||||||
|
|||||||
Reference in New Issue
Block a user