mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 00:43:32 +02:00
HTMLZ Output: Fix svg content from HTML files that contain only SVG being removed. Fixes #1839522 [all images wrapped in <svg> element are lost in htmlz output](https://bugs.launchpad.net/calibre/+bug/1839522)
This commit is contained in:
parent
ab708af9da
commit
c1663d3cc8
1 changed files with 7 additions and 7 deletions
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
from calibre import prepare_string_for_xml
|
from calibre import prepare_string_for_xml
|
||||||
from calibre.ebooks.oeb.base import (
|
from calibre.ebooks.oeb.base import (
|
||||||
XHTML, XHTML_NS, barename, namespace, OEB_IMAGES, XLINK, rewrite_links, urlnormalize)
|
XHTML, XHTML_NS, SVG_NS, barename, namespace, OEB_IMAGES, XLINK, rewrite_links, urlnormalize)
|
||||||
from calibre.ebooks.oeb.stylizer import Stylizer
|
from calibre.ebooks.oeb.stylizer import Stylizer
|
||||||
from calibre.utils.logging import default_log
|
from calibre.utils.logging import default_log
|
||||||
from polyglot.builtins import unicode_type, string_or_bytes, as_bytes
|
from polyglot.builtins import unicode_type, string_or_bytes, as_bytes
|
||||||
|
|
@ -160,9 +160,9 @@ def dump_text(self, elem, stylizer, page):
|
||||||
|
|
||||||
# We can only processes tags. If there isn't a tag return any text.
|
# We can only processes tags. If there isn't a tag return any text.
|
||||||
if not isinstance(elem.tag, string_or_bytes) \
|
if not isinstance(elem.tag, string_or_bytes) \
|
||||||
or namespace(elem.tag) != XHTML_NS:
|
or namespace(elem.tag) not in (XHTML_NS, SVG_NS):
|
||||||
p = elem.getparent()
|
p = elem.getparent()
|
||||||
if p is not None and isinstance(p.tag, string_or_bytes) and namespace(p.tag) == XHTML_NS \
|
if p is not None and isinstance(p.tag, string_or_bytes) and namespace(p.tag) in (XHTML_NS, SVG_NS) \
|
||||||
and elem.tail:
|
and elem.tail:
|
||||||
return [elem.tail]
|
return [elem.tail]
|
||||||
return ['']
|
return ['']
|
||||||
|
|
@ -249,9 +249,9 @@ def dump_text(self, elem, stylizer, page):
|
||||||
|
|
||||||
# We can only processes tags. If there isn't a tag return any text.
|
# We can only processes tags. If there isn't a tag return any text.
|
||||||
if not isinstance(elem.tag, string_or_bytes) \
|
if not isinstance(elem.tag, string_or_bytes) \
|
||||||
or namespace(elem.tag) != XHTML_NS:
|
or namespace(elem.tag) not in (XHTML_NS, SVG_NS):
|
||||||
p = elem.getparent()
|
p = elem.getparent()
|
||||||
if p is not None and isinstance(p.tag, string_or_bytes) and namespace(p.tag) == XHTML_NS \
|
if p is not None and isinstance(p.tag, string_or_bytes) and namespace(p.tag) in (XHTML_NS, SVG_NS) \
|
||||||
and elem.tail:
|
and elem.tail:
|
||||||
return [elem.tail]
|
return [elem.tail]
|
||||||
return ['']
|
return ['']
|
||||||
|
|
@ -352,9 +352,9 @@ def dump_text(self, elem, stylizer, page):
|
||||||
|
|
||||||
# We can only processes tags. If there isn't a tag return any text.
|
# We can only processes tags. If there isn't a tag return any text.
|
||||||
if not isinstance(elem.tag, string_or_bytes) \
|
if not isinstance(elem.tag, string_or_bytes) \
|
||||||
or namespace(elem.tag) != XHTML_NS:
|
or namespace(elem.tag) not in (XHTML_NS, SVG_NS):
|
||||||
p = elem.getparent()
|
p = elem.getparent()
|
||||||
if p is not None and isinstance(p.tag, string_or_bytes) and namespace(p.tag) == XHTML_NS \
|
if p is not None and isinstance(p.tag, string_or_bytes) and namespace(p.tag) in (XHTML_NS, SVG_NS) \
|
||||||
and elem.tail:
|
and elem.tail:
|
||||||
return [elem.tail]
|
return [elem.tail]
|
||||||
return ['']
|
return ['']
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue