mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
KEPUB Output: Include leading whitespace in kobo sentence span tags. This prevents unsightly breaks when highlighting across formatted text on the Kobo. Fixes #2103926 [Highlighting space after italicized words on Kobo device](https://bugs.launchpad.net/calibre/+bug/2103926)
This commit is contained in:
parent
32a27227a4
commit
28c1cb4711
@ -180,14 +180,16 @@ def add_kobo_spans(inner, root_lang):
|
|||||||
ws = None
|
ws = None
|
||||||
if num := len(text) - len(stripped):
|
if num := len(text) - len(stripped):
|
||||||
ws = text[:num]
|
ws = text[:num]
|
||||||
|
before = None if stripped else ws
|
||||||
if at:
|
if at:
|
||||||
parent[at-1].tail = ws
|
parent[at-1].tail = before
|
||||||
else:
|
else:
|
||||||
parent.text = ws
|
parent.text = before
|
||||||
if stripped:
|
if stripped:
|
||||||
for pos, sz in sentence_positions(stripped, lang):
|
text = (ws + stripped) if ws else stripped
|
||||||
|
for pos, sz in sentence_positions(text, lang):
|
||||||
s = kobo_span(parent)
|
s = kobo_span(parent)
|
||||||
s.text = stripped[pos:pos+sz]
|
s.text = text[pos:pos+sz]
|
||||||
parent.insert(at, s)
|
parent.insert(at, s)
|
||||||
at += 1
|
at += 1
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user