DOCX Input: Preserve underline style and color. Fixes #2028404 [Private bug](https://bugs.launchpad.net/calibre/+bug/2028404)

This commit is contained in:
Kovid Goyal 2023-08-01 09:34:41 +05:30
parent 1f484c5e29
commit 1b39279dd1
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -109,7 +109,18 @@ def read_underline(parent, dest, XPath, get):
for col in XPath('./w:u[@w:val]')(parent):
val = get(col, 'w:val')
if val:
ans = val if val == 'none' else 'underline'
style = {
'dotted': 'dotted', 'dash': 'dashed', 'dashDotDotHeavy': 'dotted', 'dashDotHeavy': 'dashed', 'dashedHeavy': 'dashed',
'dashLong': 'dashed', 'dashLongHeavy': 'dashed', 'dotDash': 'dotted', 'dotDotDash': 'dotted', 'dottedHeavy': 'dotted',
'double': 'double', 'none': 'none', 'single': 'solid', 'thick': 'solid', 'wave': 'wavy', 'wavyDouble': 'wavy',
'wavyHeavy': 'wavy', 'words': 'solid'}.get(val, 'solid')
if style == 'none':
ans = 'none'
else:
ans = 'underline ' + style
color = get(col, 'w:color')
if color and color != 'auto':
ans += ' #' + color
setattr(dest, 'text_decoration', ans)