@@ -832,7 +832,7 @@ class Tokenizer(ABC):
|
|||||||
sAlign |= self.A_IND_R
|
sAlign |= self.A_IND_R
|
||||||
|
|
||||||
# Process formats
|
# Process formats
|
||||||
tLine, tFmt = self._extractFormats(aLine)
|
tLine, tFmt = self._extractFormats(aLine, hDialog=self._isNovel)
|
||||||
tokens.append((
|
tokens.append((
|
||||||
self.T_TEXT, nHead, tLine, tFmt, sAlign
|
self.T_TEXT, nHead, tLine, tFmt, sAlign
|
||||||
))
|
))
|
||||||
@@ -1098,8 +1098,13 @@ class Tokenizer(ABC):
|
|||||||
# Internal Functions
|
# Internal Functions
|
||||||
##
|
##
|
||||||
|
|
||||||
def _extractFormats(self, text: str, skip: int = 0) -> tuple[str, T_Formats]:
|
def _extractFormats(
|
||||||
"""Extract format markers from a text paragraph."""
|
self, text: str, skip: int = 0, hDialog: bool = False
|
||||||
|
) -> tuple[str, T_Formats]:
|
||||||
|
"""Extract format markers from a text paragraph. In order to
|
||||||
|
also process dialogue highlighting, the hDialog flag must be set
|
||||||
|
to True. See issues #2011 and #2013.
|
||||||
|
"""
|
||||||
temp: list[tuple[int, int, int, str]] = []
|
temp: list[tuple[int, int, int, str]] = []
|
||||||
|
|
||||||
# Match Markdown
|
# Match Markdown
|
||||||
@@ -1137,7 +1142,7 @@ class Tokenizer(ABC):
|
|||||||
))
|
))
|
||||||
|
|
||||||
# Match Dialogue
|
# Match Dialogue
|
||||||
if self._rxDialogue:
|
if self._rxDialogue and hDialog:
|
||||||
for regEx, fmtB, fmtE in self._rxDialogue:
|
for regEx, fmtB, fmtE in self._rxDialogue:
|
||||||
rxItt = regEx.globalMatch(text, 0)
|
rxItt = regEx.globalMatch(text, 0)
|
||||||
while rxItt.hasNext():
|
while rxItt.hasNext():
|
||||||
|
|||||||
@@ -1100,6 +1100,7 @@ def testCoreToken_Dialogue(mockGUI):
|
|||||||
project = NWProject()
|
project = NWProject()
|
||||||
tokens = BareTokenizer(project)
|
tokens = BareTokenizer(project)
|
||||||
tokens.setDialogueHighlight(True)
|
tokens.setDialogueHighlight(True)
|
||||||
|
tokens._isNovel = True
|
||||||
|
|
||||||
# Single quotes
|
# Single quotes
|
||||||
tokens._text = "Text with \u2018dialogue one,\u2019 and \u2018dialogue two.\u2019\n"
|
tokens._text = "Text with \u2018dialogue one,\u2019 and \u2018dialogue two.\u2019\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user