1
0
mirror of https://github.com/gryf/ebook-converter.git synced 2026-04-15 18:43:30 +02:00

Removed overwritten builtins from mosto of the files.

Just started the process of cleaning up the code base.
This commit is contained in:
2020-04-19 19:06:09 +02:00
parent 571da747b3
commit b66cbd2c1e
95 changed files with 167 additions and 269 deletions

View File

@@ -3,8 +3,6 @@ Code to manage ebook library
"""
import os
from ebook_converter.polyglot.builtins import range
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'

View File

@@ -6,7 +6,7 @@ from ebook_converter.customize import CatalogPlugin
from ebook_converter.library.catalogs import FIELDS, TEMPLATE_ALLOWED_FIELDS
from ebook_converter.customize.conversion import DummyReporter
from ebook_converter.ebooks.metadata import format_isbn
from ebook_converter.polyglot.builtins import filter, string_or_bytes, unicode_type
from ebook_converter.polyglot.builtins import string_or_bytes, unicode_type
__license__ = 'GPL v3'

View File

@@ -1,11 +1,10 @@
import re
import bs4
from ebook_converter import prepare_string_for_xml
from ebook_converter.constants import preferred_encoding
from ebook_converter.ebooks.BeautifulSoup import (
BeautifulSoup, CData, Comment, Declaration, NavigableString,
ProcessingInstruction
)
from ebook_converter.ebooks.BeautifulSoup import html5_parser
from ebook_converter.utils.html2text import html2text
from ebook_converter.polyglot.builtins import unicode_type
@@ -83,8 +82,8 @@ def comments_to_html(comments):
# Convert two hyphens to emdash
comments = comments.replace('--', '&mdash;')
soup = BeautifulSoup('<div>' + comments + '</div>').find('div')
result = BeautifulSoup('<div>')
soup = html5_parser('<div>' + comments + '</div>').find('div')
result = html5_parser('<div>')
container = result.find('div')
rtc = 0
open_pTag = False
@@ -92,9 +91,10 @@ def comments_to_html(comments):
all_tokens = list(soup.contents)
inline_tags = ('br', 'b', 'i', 'em', 'strong', 'span', 'font', 'a', 'hr')
for token in all_tokens:
if isinstance(token, (CData, Comment, Declaration, ProcessingInstruction)):
if isinstance(token, (bs4.CData, bs4.Comment, bs4.Declaration,
bs4.ProcessingInstruction)):
continue
if isinstance(token, NavigableString):
if isinstance(token, bs4.NavigableString):
if not open_pTag:
pTag = result.new_tag('p')
open_pTag = True