Text color mangling converting from DOCX to EPUB/AZW3

Bug #1888897 reported by Colin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calibre
Fix Released
Undecided
Unassigned

Bug Description

Still occurs at least as late as Calibre 4.21, on Windows 10

When converting from DOCX to EPUB or AZW3, Calibre mangles the text colors and sometimes converts Automatic to black, other times leaves it undefined. This problem appears not to occur when converting to MOBI -- that conversion preserves colors properly, so this appears to be something broken in the EPUB and AZW3 conversions specifically.

The expected behavior: Colors in converted documents should match the colors of the text as set in the Word DOCX file. If the text color in the DOCX is set to "Automatic" it should be undefined in the converted EPUB and AZW3 documents. This undefined result is important so that text will appear dark on a white or light sepia background and light in a dark mode view, like Calibre's own black or sepia dark color schemes.

Here's one way to reproduce and immediately see that this is a bug, not just a matter of user preference:

1. Create a Word document and just type three 1-line paragraphs. Text doesn't matter, but I used "Line One." for the first line, "Line Two." for the second line, and "Line Three." for the third. By default, word will have the color for all of these set to Automatic.
2. Drop the file into Calibre, so it creates a book.
3. Convert it to EPUB and view the EPUB file -- as one should expect, the color of the text is not specified -- it's black when viewed on a light background and white when viewed on a dark background. Leave the viewer in Sepia Dark mode.
4. From View Specific format, re-open the Word document and change the color of the second line (the entire paragraph) of text from the original document created in Step 1 to red. Save it.
6. Re-run the conversion to EPUB.
7. View the EPUB file (still in Sepia Dark theme) and note that the colors of the other lines that were not changed in Word changed, but the one that was changed in word (line 2) is the one that did not change in the EPUB viewer. None of the text appears red.

In using Calibre's editor, we can clearly see the problem:

stylesheet.css has the red color listed in the .calibre style, and note that it has also added the .block style with a color of "black" even though we didn't do that in Word:

.block_ {
    color: black;
    display: block;
    line-height: 1.2;
    padding: 0;
    margin: 0 0 8pt
    }
.block_1 {
    display: block;
    line-height: 1.2;
    padding: 0;
    margin: 0 0 8pt
    }
.calibre {
    color: #F00;
    display: block;
    font-family: "Calibri", sans-serif;
    font-size: 1em;
    line-height: 1.2;
    padding-left: 0;
    padding-right: 0;
    margin: 0 5pt
    }

But in the page xhtml, Calibre has assigned the wrong styles to all paragraphs:

<?xml version='1.0' encoding='utf-8'?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  <head>
    <title>Unknown</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <link href="stylesheet.css" rel="stylesheet" type="text/css"/>
<link href="page_styles.css" rel="stylesheet" type="text/css"/>
</head>
  <body class="calibre">
 <p class="block_">Line One.</p>
 <p class="block_1">Line Two.</p>
 <p class="block_">Line Three.</p>

</body></html>

Note this problem does not appear to occur when converting to MOBI. Colors track properly there. The problem occurs when converting to EPUB and AZW3 specifically.

I have also frequently seen, but am not immediately able to reproduce, where setting the color for the entire document to Automatic results in Calibre setting the color to Black. I assume these are related to the same core issue where Calibre's conversion is creating some incorrect styles and mis-applying them to text.

Revision history for this message
Colin (granitestatecolin) wrote :
summary: - Text color problems converting from Word to EPUB/AZW3
+ Text color problems converting from Word DOCX to EPUB/AZW3
summary: - Text color problems converting from Word DOCX to EPUB/AZW3
+ Text color problems converting from DOCX to EPUB/AZW3
summary: - Text color problems converting from DOCX to EPUB/AZW3
+ Text color mangling converting from DOCX to EPUB/AZW3
Revision history for this message
Kovid Goyal (kovid) wrote : Fixed in master

Fixed in branch master. The fix will be in the next release. calibre is usually released every alternate Friday.

 status fixreleased

Changed in calibre:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.