From e4a2ca2d1933fdf00d0825bef7fb2474bd803684 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Mon, 4 Nov 2024 17:32:22 +0100 Subject: [PATCH] Add horizontal bar to em dash conversion in tokenizer --- novelwriter/formats/tokenizer.py | 8 +++++--- novelwriter/text/patterns.py | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/novelwriter/formats/tokenizer.py b/novelwriter/formats/tokenizer.py index e63fb150..51bfaef1 100644 --- a/novelwriter/formats/tokenizer.py +++ b/novelwriter/formats/tokenizer.py @@ -493,9 +493,11 @@ class Tokenizer(ABC): xRep = re.compile("|".join([re.escape(k) for k in repDict.keys()]), flags=re.DOTALL) self._text = xRep.sub(lambda x: repDict[x.group(0)], self._text) - # Process the character translation map - trDict = {nwUnicode.U_MAPOS: nwUnicode.U_RSQUO} - self._text = self._text.translate(str.maketrans(trDict)) + # Process the translation map for placeholder characters + self._text = self._text.translate(str.maketrans({ + nwUnicode.U_MAPOS: nwUnicode.U_RSQUO, + nwUnicode.U_HBAR: nwUnicode.U_EMDASH, + })) return diff --git a/novelwriter/text/patterns.py b/novelwriter/text/patterns.py index 1f7948e8..55d813f7 100644 --- a/novelwriter/text/patterns.py +++ b/novelwriter/text/patterns.py @@ -3,7 +3,8 @@ novelWriter – Text Pattern Functions ==================================== File History: -Created: 2024-06-01 [2.5ec1] +Created: 2024-06-01 [2.5rc1] RegExPatterns +Created: 2024-11-04 [2.6b1] DialogParser This file is a part of novelWriter Copyright 2018–2024, Veronica Berglyd Olsen