diff --git a/src/calibre/ebooks/oeb/polish/kepubify.py b/src/calibre/ebooks/oeb/polish/kepubify.py index 3537b78e22..201707a3d0 100644 --- a/src/calibre/ebooks/oeb/polish/kepubify.py +++ b/src/calibre/ebooks/oeb/polish/kepubify.py @@ -16,7 +16,7 @@ import re from lxml import etree -from calibre.ebooks.oeb.base import XHTML, XPath +from calibre.ebooks.oeb.base import XHTML, XPath, serialize from calibre.ebooks.oeb.parse_utils import barename, merge_multiple_html_heads_and_bodies from calibre.ebooks.oeb.polish.parsing import parse from calibre.ebooks.oeb.polish.tts import lang_for_elem @@ -177,6 +177,10 @@ def remove_kobo_markup_from_html(root): unwrap_body_contents(body) +def serialize_html(root) -> bytes: + return serialize(root, 'text/html') + + def kepubify_parsed_html(root, metadata_lang: str = 'en'): remove_kobo_markup_from_html(root) merge_multiple_html_heads_and_bodies(root) diff --git a/src/calibre/ebooks/oeb/polish/tests/kepubify.py b/src/calibre/ebooks/oeb/polish/tests/kepubify.py index 86ffb4d620..90aacf87ed 100644 --- a/src/calibre/ebooks/oeb/polish/tests/kepubify.py +++ b/src/calibre/ebooks/oeb/polish/tests/kepubify.py @@ -2,8 +2,7 @@ # License: GPLv3 Copyright: 2025, Kovid Goyal -from calibre.ebooks.oeb.base import serialize -from calibre.ebooks.oeb.polish.kepubify import kepubify_html_data +from calibre.ebooks.oeb.polish.kepubify import kepubify_html_data, serialize_html from calibre.ebooks.oeb.polish.tests.base import BaseTest @@ -53,6 +52,6 @@ div#book-inner { margin-top: 0; margin-bottom: 0; }