From ac6af504227b6d683fc378002373bcec77d0c15b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 16 Apr 2014 08:21:02 +0530 Subject: [PATCH] DOCX Input: Fix some text highlighting colors in the DOCX file not being correctly translated during conversion. Fixes #1308181 [color names change upon conversion](https://bugs.launchpad.net/calibre/+bug/1308181) --- src/calibre/ebooks/docx/char_styles.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/calibre/ebooks/docx/char_styles.py b/src/calibre/ebooks/docx/char_styles.py index e4c9383c68..679add87ff 100644 --- a/src/calibre/ebooks/docx/char_styles.py +++ b/src/calibre/ebooks/docx/char_styles.py @@ -55,6 +55,12 @@ def read_color(parent, dest): ans = simple_color(val) setattr(dest, 'color', ans) +def convert_highlight_color(val): + return { + 'darkBlue': '#000080', 'darkCyan': '#008080', 'darkGray': '#808080', + 'darkGreen': '#008000', 'darkMagenta': '#800080', 'darkRed': '#800000', 'darkYellow': '#808000', + 'lightGray': '#c0c0c0'}.get(val, val) + def read_highlight(parent, dest): ans = inherit for col in XPath('./w:highlight[@w:val]')(parent): @@ -63,6 +69,8 @@ def read_highlight(parent, dest): continue if not val or val == 'none': val = 'transparent' + else: + val = convert_highlight_color(val) ans = val setattr(dest, 'highlight', ans)