mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-01-09 05:04:12 +01:00
Added txt output format
This commit is contained in:
@@ -71,6 +71,7 @@ Currently, following formats are supported:
|
|||||||
- mobi
|
- mobi
|
||||||
- docx
|
- docx
|
||||||
- htmlz (zipped HTML file with additional assets, like images)
|
- htmlz (zipped HTML file with additional assets, like images)
|
||||||
|
- txt
|
||||||
|
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
|
|||||||
@@ -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']
|
|
||||||
|
|||||||
@@ -64,9 +64,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
import re
|
import re
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from calibre.utils.smartypants import smartyPants
|
from ebook_converter.utils.smartypants import smartyPants
|
||||||
from polyglot.builtins import unicode_type
|
from ebook_converter.polyglot.builtins import unicode_type
|
||||||
from polyglot.urllib import urlopen, urlparse
|
from ebook_converter.polyglot.urllib import urlopen, urlparse
|
||||||
|
|
||||||
|
|
||||||
def _normalize_newlines(string):
|
def _normalize_newlines(string):
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ import re
|
|||||||
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from calibre.ebooks.htmlz.oeb2html import OEB2HTML
|
from ebook_converter.ebooks.htmlz.oeb2html import OEB2HTML
|
||||||
from calibre.ebooks.oeb.base import XHTML, XHTML_NS, barename, namespace, rewrite_links
|
from ebook_converter.ebooks.oeb.base import XHTML, XHTML_NS, barename, namespace, rewrite_links
|
||||||
from calibre.ebooks.oeb.stylizer import Stylizer
|
from ebook_converter.ebooks.oeb.stylizer import Stylizer
|
||||||
from polyglot.builtins import unicode_type, string_or_bytes
|
from ebook_converter.polyglot.builtins import unicode_type, string_or_bytes
|
||||||
|
|
||||||
|
|
||||||
class MarkdownMLizer(OEB2HTML):
|
class MarkdownMLizer(OEB2HTML):
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ import re
|
|||||||
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from calibre.ebooks.htmlz.oeb2html import OEB2HTML
|
from ebook_converter.ebooks.htmlz.oeb2html import OEB2HTML
|
||||||
from calibre.ebooks.oeb.base import XHTML, XHTML_NS, barename, namespace, rewrite_links
|
from ebook_converter.ebooks.oeb.base import XHTML, XHTML_NS, barename, namespace, rewrite_links
|
||||||
from calibre.ebooks.oeb.stylizer import Stylizer
|
from ebook_converter.ebooks.oeb.stylizer import Stylizer
|
||||||
from calibre.ebooks import unit_convert
|
from ebook_converter.ebooks import unit_convert
|
||||||
from calibre.ebooks.textile.unsmarten import unsmarten
|
from ebook_converter.ebooks.textile.unsmarten import unsmarten
|
||||||
from polyglot.builtins import string_or_bytes
|
from ebook_converter.polyglot.builtins import string_or_bytes
|
||||||
|
|
||||||
|
|
||||||
class TextileMLizer(OEB2HTML):
|
class TextileMLizer(OEB2HTML):
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ Transform OEB content into plain text
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
from polyglot.builtins import string_or_bytes
|
from ebook_converter.polyglot.builtins import string_or_bytes
|
||||||
|
|
||||||
|
|
||||||
BLOCK_TAGS = [
|
BLOCK_TAGS = [
|
||||||
@@ -65,9 +65,9 @@ class TXTMLizer(object):
|
|||||||
return self.mlize_spine()
|
return self.mlize_spine()
|
||||||
|
|
||||||
def mlize_spine(self):
|
def mlize_spine(self):
|
||||||
from calibre.ebooks.oeb.base import XHTML
|
from ebook_converter.ebooks.oeb.base import XHTML
|
||||||
from calibre.ebooks.oeb.stylizer import Stylizer
|
from ebook_converter.ebooks.oeb.stylizer import Stylizer
|
||||||
from calibre.utils.xml_parse import safe_xml_fromstring
|
from ebook_converter.utils.xml_parse import safe_xml_fromstring
|
||||||
output = [u'']
|
output = [u'']
|
||||||
output.append(self.get_toc())
|
output.append(self.get_toc())
|
||||||
for item in self.oeb_book.spine:
|
for item in self.oeb_book.spine:
|
||||||
@@ -191,7 +191,7 @@ class TXTMLizer(object):
|
|||||||
@stylizer: The style information attached to the element.
|
@stylizer: The style information attached to the element.
|
||||||
@page: OEB page used to determine absolute urls.
|
@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) \
|
if not isinstance(elem.tag, string_or_bytes) \
|
||||||
or namespace(elem.tag) != XHTML_NS:
|
or namespace(elem.tag) != XHTML_NS:
|
||||||
|
|||||||
Reference in New Issue
Block a user