From 41b687ee27e7b5d95e8bdc04a249d170a8be7ebf Mon Sep 17 00:00:00 2001 From: gryf Date: Sun, 19 Apr 2020 13:53:51 +0200 Subject: [PATCH] Added txt output format --- README.rst | 1 + ebook_converter/ebooks/textile/__init__.py | 7 ------- ebook_converter/ebooks/textile/functions.py | 6 +++--- ebook_converter/ebooks/txt/markdownml.py | 8 ++++---- ebook_converter/ebooks/txt/textileml.py | 12 ++++++------ ebook_converter/ebooks/txt/txtml.py | 10 +++++----- 6 files changed, 19 insertions(+), 25 deletions(-) diff --git a/README.rst b/README.rst index e657b11..bff77ba 100644 --- a/README.rst +++ b/README.rst @@ -71,6 +71,7 @@ Currently, following formats are supported: - mobi - docx - htmlz (zipped HTML file with additional assets, like images) +- txt Installation diff --git a/ebook_converter/ebooks/textile/__init__.py b/ebook_converter/ebooks/textile/__init__.py index 5a0a767..e69de29 100644 --- a/ebook_converter/ebooks/textile/__init__.py +++ b/ebook_converter/ebooks/textile/__init__.py @@ -1,7 +0,0 @@ -from __future__ import absolute_import, division, print_function, unicode_literals -from .functions import textile, textile_restricted, Textile - -if False: - textile, textile_restricted, Textile - -__all__ = ['textile', 'textile_restricted'] diff --git a/ebook_converter/ebooks/textile/functions.py b/ebook_converter/ebooks/textile/functions.py index 5029a2a..34ca7a7 100644 --- a/ebook_converter/ebooks/textile/functions.py +++ b/ebook_converter/ebooks/textile/functions.py @@ -64,9 +64,9 @@ POSSIBILITY OF SUCH DAMAGE. import re import uuid -from calibre.utils.smartypants import smartyPants -from polyglot.builtins import unicode_type -from polyglot.urllib import urlopen, urlparse +from ebook_converter.utils.smartypants import smartyPants +from ebook_converter.polyglot.builtins import unicode_type +from ebook_converter.polyglot.urllib import urlopen, urlparse def _normalize_newlines(string): diff --git a/ebook_converter/ebooks/txt/markdownml.py b/ebook_converter/ebooks/txt/markdownml.py index 4c25c47..87a7ab1 100644 --- a/ebook_converter/ebooks/txt/markdownml.py +++ b/ebook_converter/ebooks/txt/markdownml.py @@ -13,10 +13,10 @@ import re from functools import partial -from calibre.ebooks.htmlz.oeb2html import OEB2HTML -from calibre.ebooks.oeb.base import XHTML, XHTML_NS, barename, namespace, rewrite_links -from calibre.ebooks.oeb.stylizer import Stylizer -from polyglot.builtins import unicode_type, string_or_bytes +from ebook_converter.ebooks.htmlz.oeb2html import OEB2HTML +from ebook_converter.ebooks.oeb.base import XHTML, XHTML_NS, barename, namespace, rewrite_links +from ebook_converter.ebooks.oeb.stylizer import Stylizer +from ebook_converter.polyglot.builtins import unicode_type, string_or_bytes class MarkdownMLizer(OEB2HTML): diff --git a/ebook_converter/ebooks/txt/textileml.py b/ebook_converter/ebooks/txt/textileml.py index e9eecfc..874fac4 100644 --- a/ebook_converter/ebooks/txt/textileml.py +++ b/ebook_converter/ebooks/txt/textileml.py @@ -12,12 +12,12 @@ import re from functools import partial -from calibre.ebooks.htmlz.oeb2html import OEB2HTML -from calibre.ebooks.oeb.base import XHTML, XHTML_NS, barename, namespace, rewrite_links -from calibre.ebooks.oeb.stylizer import Stylizer -from calibre.ebooks import unit_convert -from calibre.ebooks.textile.unsmarten import unsmarten -from polyglot.builtins import string_or_bytes +from ebook_converter.ebooks.htmlz.oeb2html import OEB2HTML +from ebook_converter.ebooks.oeb.base import XHTML, XHTML_NS, barename, namespace, rewrite_links +from ebook_converter.ebooks.oeb.stylizer import Stylizer +from ebook_converter.ebooks import unit_convert +from ebook_converter.ebooks.textile.unsmarten import unsmarten +from ebook_converter.polyglot.builtins import string_or_bytes class TextileMLizer(OEB2HTML): diff --git a/ebook_converter/ebooks/txt/txtml.py b/ebook_converter/ebooks/txt/txtml.py index 14cc7d8..64a44f4 100644 --- a/ebook_converter/ebooks/txt/txtml.py +++ b/ebook_converter/ebooks/txt/txtml.py @@ -12,7 +12,7 @@ Transform OEB content into plain text import re from lxml import etree -from polyglot.builtins import string_or_bytes +from ebook_converter.polyglot.builtins import string_or_bytes BLOCK_TAGS = [ @@ -65,9 +65,9 @@ class TXTMLizer(object): return self.mlize_spine() def mlize_spine(self): - from calibre.ebooks.oeb.base import XHTML - from calibre.ebooks.oeb.stylizer import Stylizer - from calibre.utils.xml_parse import safe_xml_fromstring + from ebook_converter.ebooks.oeb.base import XHTML + from ebook_converter.ebooks.oeb.stylizer import Stylizer + from ebook_converter.utils.xml_parse import safe_xml_fromstring output = [u''] output.append(self.get_toc()) for item in self.oeb_book.spine: @@ -191,7 +191,7 @@ class TXTMLizer(object): @stylizer: The style information attached to the element. @page: OEB page used to determine absolute urls. ''' - from calibre.ebooks.oeb.base import XHTML_NS, barename, namespace + from ebook_converter.ebooks.oeb.base import XHTML_NS, barename, namespace if not isinstance(elem.tag, string_or_bytes) \ or namespace(elem.tag) != XHTML_NS: