mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit book: Prettify html in newly created books. Fixes #1264390 [[95% F.Request - 5% Bug] Automatically Beautify New Books](https://bugs.launchpad.net/calibre/+bug/1264390)
This commit is contained in:
parent
d5d6d0430c
commit
63b28686d7
@ -12,9 +12,11 @@ from lxml import etree
|
|||||||
|
|
||||||
from calibre import prepare_string_for_xml, CurrentDir
|
from calibre import prepare_string_for_xml, CurrentDir
|
||||||
from calibre.ptempfile import TemporaryDirectory
|
from calibre.ptempfile import TemporaryDirectory
|
||||||
|
from calibre.ebooks.oeb.base import serialize
|
||||||
from calibre.ebooks.metadata.opf2 import metadata_to_opf
|
from calibre.ebooks.metadata.opf2 import metadata_to_opf
|
||||||
|
from calibre.ebooks.oeb.polish.parsing import parse
|
||||||
from calibre.ebooks.oeb.polish.container import OPF_NAMESPACES, guess_type, opf_to_azw3
|
from calibre.ebooks.oeb.polish.container import OPF_NAMESPACES, guess_type, opf_to_azw3
|
||||||
from calibre.ebooks.oeb.polish.pretty import pretty_xml_tree
|
from calibre.ebooks.oeb.polish.pretty import pretty_xml_tree, pretty_html_tree
|
||||||
from calibre.ebooks.oeb.polish.toc import TOC, create_ncx
|
from calibre.ebooks.oeb.polish.toc import TOC, create_ncx
|
||||||
from calibre.utils.localization import lang_as_iso639_1
|
from calibre.utils.localization import lang_as_iso639_1
|
||||||
from calibre.utils.logging import DevNull
|
from calibre.utils.logging import DevNull
|
||||||
@ -73,6 +75,9 @@ def create_book(mi, path, fmt='epub', opf_name='metadata.opf', html_name='start.
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
'''.format(prepare_string_for_xml(mi.title), lang).encode('utf-8')
|
'''.format(prepare_string_for_xml(mi.title), lang).encode('utf-8')
|
||||||
|
h = parse(HTML)
|
||||||
|
pretty_html_tree(None, h)
|
||||||
|
HTML = serialize(h, 'text/html')
|
||||||
ncx = etree.tostring(create_toc(mi, opf, html_name, lang), encoding='utf-8', xml_declaration=True, pretty_print=True)
|
ncx = etree.tostring(create_toc(mi, opf, html_name, lang), encoding='utf-8', xml_declaration=True, pretty_print=True)
|
||||||
pretty_xml_tree(opf)
|
pretty_xml_tree(opf)
|
||||||
opf = etree.tostring(opf, encoding='utf-8', xml_declaration=True, pretty_print=True)
|
opf = etree.tostring(opf, encoding='utf-8', xml_declaration=True, pretty_print=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user