From c38bacc0ba798e9b54cdcb088341d1e9d2ad21b3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 2 Mar 2024 16:57:25 +0530 Subject: [PATCH] Also handle soft hyphens with trailing spaces --- src/calibre/ebooks/docx/writer/from_html.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/calibre/ebooks/docx/writer/from_html.py b/src/calibre/ebooks/docx/writer/from_html.py index af8b9db1f23d..92cf5ca72b4b 100644 --- a/src/calibre/ebooks/docx/writer/from_html.py +++ b/src/calibre/ebooks/docx/writer/from_html.py @@ -124,6 +124,9 @@ def add_text(text, preserve_whitespace): add_text(' ', True) makeelement(r, 'w:softHyphen') elif x: + if not preserve_whitespace and x.startswith(' ') and len(r) and r[-1].tag and 'softHyphen' in r[-1].tag: + x = x.lstrip() + add_text(' ', True) add_text(x, preserve_whitespace) else: add_text('', preserve_whitespace)