Htmlz does not apply inline css from <body>

Bug #1242261 reported by Slobberchopz on 2013-10-20
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calibre
Undecided
John Schember

Bug Description

Calibre 1.7 32bit, Windows 7 64 bit

When a stylesheet has a selector and styling for the body element, and htmlz conversion is set to inline, htmlz does not apply it.

I think the error is in the following file: https://github.com/kovidgoyal/calibre/blob/master/src/calibre/ebooks/htmlz/oeb2html.py line 260

259 if not style['page-break-before'] == 'always':
260 style_a = 'page-break-before: always;' + ' ' if style_a else '' + style_a

I don't see any sense in line 260; it either sets `style_a` to page-break-before:always *and leaves out* the other styles, or sets it to itself, when it should be adding page-break-before:always??

It should be along the lines of:

style['page-break-before'] = 'always'
style_a = '%s' % style

if `style` is modifiable;

or

style_a = re.sub('page-break-before:[^;]*;?|', 'page-break-before:always;', style_a)

(the `;?` being for when it at the end of string with no semicolon and the `|` being for when page-break-before doesn't yet exist in the string)

Thanks

description: updated
description: updated
description: updated

Changing the component for this bug.

 assignee user-none
 status triaged

Changed in calibre:
assignee: nobody → John Schember (user-none)
status: New → Triaged
John Schember (user-none) wrote :

You need to look at the whole block

256 style_a = '%s' % style
257 if tag == 'body':
258 tag = 'div'
259 if not style['page-break-before'] == 'always':
260 style_a = 'page-break-before: always;' + ' ' if style_a else '' + style_a
261 tags.append(tag)

256 Get the style as a string
257 If the tag is body
258 Change the tag to div because we're merging multiple documents into one..
259 Most renders (All the ones I've seen) by default treat a new document as a page break. Check if the body style already has page break before set.
260 If the body does not have page break before add it to the style
261 Add the tag

There is an issue with line 260 not adding the style properly because the + style_a at the end is being treated as part of the else. That said it should also remove all page-break styles so before is the only one set.

Changed in calibre:
status: Triaged → Fix Committed

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

 status fixreleased

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

Other bug subscribers