Make dialog parser and keyword lines work with 4 byte unicode

This commit is contained in:
Veronica Berglyd Olsen
2025-07-05 01:50:47 +02:00
parent f8a333c4ea
commit 57bed18ccf
3 changed files with 45 additions and 9 deletions
+6 -2
View File
@@ -27,7 +27,7 @@ from __future__ import annotations
import re
from novelwriter import CONFIG
from novelwriter.common import compact, uniqueCompact
from novelwriter.common import compact, uniqueCompact, utf16CharMap
from novelwriter.constants import nwRegEx, nwUnicode
@@ -170,7 +170,7 @@ class DialogParser:
return
def __call__(self, text: str) -> list[tuple[int, int]]:
def __call__(self, text: str, wideChar: bool = False) -> list[tuple[int, int]]:
"""Caller wrapper for dialogue processing."""
temp: list[int] = []
result: list[tuple[int, int]] = []
@@ -218,4 +218,8 @@ class DialogParser:
result.append((start, pos))
start = None
if wideChar:
posMap = utf16CharMap(text)
result = [(posMap[s], posMap[p]) for s, p in result]
return result