mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-05-01 03:14:05 +02:00
Added support for epub output format.
This commit is contained in:
@@ -7,16 +7,16 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import codecs, shutil, os, posixpath
|
||||
from polyglot.builtins import iteritems, itervalues, map
|
||||
from ebook_converter.polyglot.builtins import iteritems, itervalues, map
|
||||
from functools import partial
|
||||
from collections import Counter, defaultdict
|
||||
|
||||
from calibre import sanitize_file_name
|
||||
from calibre.ebooks.chardet import strip_encoding_declarations
|
||||
from calibre.ebooks.oeb.base import css_text
|
||||
from calibre.ebooks.oeb.polish.css import iter_declarations, remove_property_value
|
||||
from calibre.ebooks.oeb.polish.utils import extract
|
||||
from polyglot.urllib import urlparse, urlunparse
|
||||
from ebook_converter import sanitize_file_name
|
||||
from ebook_converter.ebooks.chardet import strip_encoding_declarations
|
||||
from ebook_converter.ebooks.oeb.base import css_text
|
||||
from ebook_converter.ebooks.oeb.polish.css import iter_declarations, remove_property_value
|
||||
from ebook_converter.ebooks.oeb.polish.utils import extract
|
||||
from ebook_converter.polyglot.urllib import urlparse, urlunparse
|
||||
|
||||
|
||||
class LinkReplacer(object):
|
||||
@@ -151,7 +151,7 @@ def replace_ids(container, id_map):
|
||||
|
||||
|
||||
def smarten_punctuation(container, report):
|
||||
from calibre.ebooks.conversion.preprocess import smarten_punctuation
|
||||
from ebook_converter.ebooks.conversion.preprocess import smarten_punctuation
|
||||
smartened = False
|
||||
for path in container.spine_items:
|
||||
name = container.abspath_to_name(path)
|
||||
@@ -230,9 +230,9 @@ def replace_file(container, name, path, basename, force_mt=None):
|
||||
|
||||
|
||||
def mt_to_category(container, mt):
|
||||
from calibre.ebooks.oeb.polish.utils import guess_type
|
||||
from calibre.ebooks.oeb.polish.container import OEB_FONTS
|
||||
from calibre.ebooks.oeb.base import OEB_DOCS, OEB_STYLES
|
||||
from ebook_converter.ebooks.oeb.polish.utils import guess_type
|
||||
from ebook_converter.ebooks.oeb.polish.container import OEB_FONTS
|
||||
from ebook_converter.ebooks.oeb.base import OEB_DOCS, OEB_STYLES
|
||||
if mt in OEB_DOCS:
|
||||
category = 'text'
|
||||
elif mt in OEB_STYLES:
|
||||
@@ -253,7 +253,7 @@ def get_recommended_folders(container, names):
|
||||
recommendation is based on where the majority of files of the same type are
|
||||
located in the container. If no files of a particular type are present, the
|
||||
recommended folder is assumed to be the folder containing the OPF file. '''
|
||||
from calibre.ebooks.oeb.polish.utils import guess_type
|
||||
from ebook_converter.ebooks.oeb.polish.utils import guess_type
|
||||
counts = defaultdict(Counter)
|
||||
for name, mt in iteritems(container.mime_map):
|
||||
folder = name.rpartition('/')[0] if '/' in name else ''
|
||||
@@ -347,7 +347,7 @@ def remove_links_in_declaration(href_to_name, style, predicate):
|
||||
def remove_links_to(container, predicate):
|
||||
''' predicate must be a function that takes the arguments (name, href,
|
||||
fragment=None) and returns True iff the link should be removed '''
|
||||
from calibre.ebooks.oeb.base import iterlinks, OEB_DOCS, OEB_STYLES, XPath, XHTML
|
||||
from ebook_converter.ebooks.oeb.base import iterlinks, OEB_DOCS, OEB_STYLES, XPath, XHTML
|
||||
stylepath = XPath('//h:style')
|
||||
styleattrpath = XPath('//*[@style]')
|
||||
changed = set()
|
||||
|
||||
Reference in New Issue
Block a user