mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-04-20 13:11:27 +02:00
Added support for epub output format.
This commit is contained in:
@@ -9,15 +9,15 @@ from collections import defaultdict
|
||||
from functools import partial
|
||||
|
||||
from css_parser.css import CSSRule, CSSStyleDeclaration
|
||||
from css_selectors import parse, SelectorSyntaxError
|
||||
from ebook_converter.css_selectors import parse, SelectorSyntaxError
|
||||
|
||||
from calibre import force_unicode
|
||||
from calibre.ebooks.oeb.base import OEB_STYLES, OEB_DOCS, XHTML, css_text
|
||||
from calibre.ebooks.oeb.normalize_css import normalize_filter_css, normalizers
|
||||
from calibre.ebooks.oeb.polish.pretty import pretty_script_or_style, pretty_xml_tree, serialize
|
||||
from calibre.utils.icu import numeric_sort_key
|
||||
from css_selectors import Select, SelectorError
|
||||
from polyglot.builtins import iteritems, itervalues, unicode_type, filter
|
||||
from ebook_converter import force_unicode
|
||||
from ebook_converter.ebooks.oeb.base import OEB_STYLES, OEB_DOCS, XHTML, css_text
|
||||
from ebook_converter.ebooks.oeb.normalize_css import normalize_filter_css, normalizers
|
||||
from ebook_converter.ebooks.oeb.polish.pretty import pretty_script_or_style, pretty_xml_tree, serialize
|
||||
from ebook_converter.utils.icu import numeric_sort_key
|
||||
from ebook_converter.css_selectors import Select, SelectorError
|
||||
from ebook_converter.polyglot.builtins import iteritems, itervalues, unicode_type, filter
|
||||
|
||||
|
||||
def filter_used_rules(rules, log, select):
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -6,14 +6,14 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import copy, os, re
|
||||
from polyglot.builtins import map, string_or_bytes, range
|
||||
from ebook_converter.polyglot.builtins import map, string_or_bytes, range
|
||||
|
||||
from calibre.ebooks.oeb.base import barename, XPNSMAP, XPath, OPF, XHTML, OEB_DOCS
|
||||
from calibre.ebooks.oeb.polish.errors import MalformedMarkup
|
||||
from calibre.ebooks.oeb.polish.toc import node_from_loc
|
||||
from calibre.ebooks.oeb.polish.replace import LinkRebaser
|
||||
from polyglot.builtins import iteritems, unicode_type
|
||||
from polyglot.urllib import urlparse
|
||||
from ebook_converter.ebooks.oeb.base import barename, XPNSMAP, XPath, OPF, XHTML, OEB_DOCS
|
||||
from ebook_converter.ebooks.oeb.polish.errors import MalformedMarkup
|
||||
from ebook_converter.ebooks.oeb.polish.toc import node_from_loc
|
||||
from ebook_converter.ebooks.oeb.polish.replace import LinkRebaser
|
||||
from ebook_converter.polyglot.builtins import iteritems, unicode_type
|
||||
from ebook_converter.polyglot.urllib import urlparse
|
||||
|
||||
|
||||
class AbortError(ValueError):
|
||||
|
||||
Reference in New Issue
Block a user