mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-03-25 20:03:32 +01:00
Compare commits
3 Commits
72d0858ad8
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c89fc132b8 | ||
| 8b8a92e9fd | |||
| 6b7f796cfb |
@@ -123,7 +123,7 @@ managers), i.e:
|
||||
$ . venv/bin/activate
|
||||
(venv) $ git clone https://github.com/gryf/ebook-converter
|
||||
(venv) $ cd ebook-converter
|
||||
(venv) $ pip install -r requirements.txt .
|
||||
(venv) $ pip install .
|
||||
|
||||
Simple as that. And from now on, you can issue converter:
|
||||
|
||||
|
||||
28
ebook_converter/ebooks/oeb/transforms/unsmarten.py
Normal file
28
ebook_converter/ebooks/oeb/transforms/unsmarten.py
Normal file
@@ -0,0 +1,28 @@
|
||||
__license__ = 'GPL 3'
|
||||
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
from ebook_converter.ebooks.oeb.base import OEB_DOCS, XPath
|
||||
from ebook_converter.ebooks.oeb.parse_utils import barename
|
||||
from ebook_converter.utils.unsmarten import unsmarten_text
|
||||
|
||||
|
||||
class UnsmartenPunctuation:
|
||||
|
||||
def __init__(self):
|
||||
self.html_tags = XPath('descendant::h:*')
|
||||
|
||||
def unsmarten(self, root):
|
||||
for x in self.html_tags(root):
|
||||
if not barename(x.tag) == 'pre':
|
||||
if getattr(x, 'text', None):
|
||||
x.text = unsmarten_text(x.text)
|
||||
if getattr(x, 'tail', None) and x.tail:
|
||||
x.tail = unsmarten_text(x.tail)
|
||||
|
||||
def __call__(self, oeb, context):
|
||||
bx = XPath('//h:body')
|
||||
for x in oeb.manifest.items:
|
||||
if x.media_type in OEB_DOCS:
|
||||
for body in bx(x.data):
|
||||
self.unsmarten(body)
|
||||
40
ebook_converter/utils/unsmarten.py
Normal file
40
ebook_converter/utils/unsmarten.py
Normal file
@@ -0,0 +1,40 @@
|
||||
__license__ = 'GPL 3'
|
||||
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
from ebook_converter.utils.mreplace import MReplace
|
||||
|
||||
_mreplace = MReplace({
|
||||
'–': '--',
|
||||
'–': '--',
|
||||
'–': '--',
|
||||
'—': '---',
|
||||
'—': '---',
|
||||
'—': '---',
|
||||
'…': '...',
|
||||
'…': '...',
|
||||
'…': '...',
|
||||
'“': '"',
|
||||
'”': '"',
|
||||
'„': '"',
|
||||
'″': '"',
|
||||
'“': '"',
|
||||
'”': '"',
|
||||
'„': '"',
|
||||
'″': '"',
|
||||
'“':'"',
|
||||
'”':'"',
|
||||
'„':'"',
|
||||
'″':'"',
|
||||
'‘':"'",
|
||||
'’':"'",
|
||||
'′':"'",
|
||||
'‘':"'",
|
||||
'’':"'",
|
||||
'′':"'",
|
||||
'‘':"'",
|
||||
'’':"'",
|
||||
'′':"'",
|
||||
})
|
||||
|
||||
unsmarten_text = _mreplace.mreplace
|
||||
@@ -1,5 +1,5 @@
|
||||
[build-system]
|
||||
requires = ["setuptools >= 61.0"]
|
||||
requires = ["setuptools >= 77.0"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
@@ -24,11 +24,10 @@ readme = "README.rst"
|
||||
authors = [
|
||||
{name = "gryf", email = "gryf73@gmail.com"}
|
||||
]
|
||||
license = {text = "GPLv3"}
|
||||
license = "GPL-3.0-or-later"
|
||||
classifiers = [
|
||||
"Environment :: Console",
|
||||
"Intended Audience :: Other Audience",
|
||||
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
||||
"Operating System :: POSIX :: Linux",
|
||||
"Development Status :: 3 - Alpha",
|
||||
"Programming Language :: Python",
|
||||
|
||||
Reference in New Issue
Block a user