Separate single and double quoted dialogue
This commit is contained in:
@@ -86,26 +86,26 @@ class RegExPatterns:
|
|||||||
def dialogStyle(self) -> re.Pattern | None:
|
def dialogStyle(self) -> re.Pattern | None:
|
||||||
"""Dialogue detection rule based on user settings."""
|
"""Dialogue detection rule based on user settings."""
|
||||||
if CONFIG.dialogStyle > 0:
|
if CONFIG.dialogStyle > 0:
|
||||||
symO = ""
|
end = "|$" if CONFIG.allowOpenDial else ""
|
||||||
symC = ""
|
rx = []
|
||||||
if CONFIG.dialogStyle in (1, 3):
|
if CONFIG.dialogStyle in (1, 3):
|
||||||
symO += CONFIG.fmtSQuoteOpen.strip()[:1]
|
qO = CONFIG.fmtSQuoteOpen.strip()[:1]
|
||||||
symC += CONFIG.fmtSQuoteClose.strip()[:1]
|
qC = CONFIG.fmtSQuoteClose.strip()[:1]
|
||||||
|
rx.append(f"(\\B{qO}.*?(?:{qC}\\B{end}))")
|
||||||
if CONFIG.dialogStyle in (2, 3):
|
if CONFIG.dialogStyle in (2, 3):
|
||||||
symO += CONFIG.fmtDQuoteOpen.strip()[:1]
|
qO = CONFIG.fmtDQuoteOpen.strip()[:1]
|
||||||
symC += CONFIG.fmtDQuoteClose.strip()[:1]
|
qC = CONFIG.fmtDQuoteClose.strip()[:1]
|
||||||
|
rx.append(f"(\\B{qO}.*?(?:{qC}\\B{end}))")
|
||||||
rxEnd = "|$" if CONFIG.allowOpenDial else ""
|
return re.compile("|".join(rx), re.UNICODE)
|
||||||
return re.compile(f"\\B[{symO}].*?(?:[{symC}]\\B{rxEnd})", re.UNICODE)
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def altDialogStyle(self) -> re.Pattern | None:
|
def altDialogStyle(self) -> re.Pattern | None:
|
||||||
"""Dialogue alternative rule based on user settings."""
|
"""Dialogue alternative rule based on user settings."""
|
||||||
if CONFIG.altDialogOpen and CONFIG.altDialogClose:
|
if CONFIG.altDialogOpen and CONFIG.altDialogClose:
|
||||||
symO = re.escape(compact(CONFIG.altDialogOpen))
|
qO = re.escape(compact(CONFIG.altDialogOpen))
|
||||||
symC = re.escape(compact(CONFIG.altDialogClose))
|
qC = re.escape(compact(CONFIG.altDialogClose))
|
||||||
return re.compile(f"\\B{symO}.*?{symC}\\B", re.UNICODE)
|
return re.compile(f"\\B{qO}.*?{qC}\\B", re.UNICODE)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user