mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
MOBI output: Dont fail if input document contains invalid % based lengths. Fixes #1956097 [news download crashes with TypeError: '<' not supported between instances of 'float' and 'str'](https://bugs.launchpad.net/calibre/+bug/1956097)
This commit is contained in:
parent
ce138b1744
commit
fdbffe60fe
@ -6,14 +6,17 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.cam>'
|
||||
|
||||
import copy
|
||||
import re
|
||||
import numbers
|
||||
import re
|
||||
from contextlib import suppress
|
||||
from lxml import etree
|
||||
from calibre.ebooks.oeb.base import namespace, barename
|
||||
from calibre.ebooks.oeb.base import XHTML, XHTML_NS, urlnormalize
|
||||
|
||||
from calibre.ebooks.mobi.utils import convert_color_for_font_tag
|
||||
from calibre.ebooks.oeb.base import (
|
||||
XHTML, XHTML_NS, barename, namespace, urlnormalize
|
||||
)
|
||||
from calibre.ebooks.oeb.stylizer import Stylizer
|
||||
from calibre.ebooks.oeb.transforms.flatcss import KeyMapper
|
||||
from calibre.ebooks.mobi.utils import convert_color_for_font_tag
|
||||
from calibre.utils.imghdr import identify
|
||||
from polyglot.builtins import string_or_bytes
|
||||
|
||||
@ -55,6 +58,7 @@ def convert_margin(style, which):
|
||||
ans = asfloat(style[which])
|
||||
raw = style._get(which)
|
||||
if isinstance(raw, str) and '%' in raw:
|
||||
with suppress(TypeError):
|
||||
ans = min(style._unit_convert(raw, base=600), ans)
|
||||
return ans
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user