mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix indents.
This commit is contained in:
parent
b5599f8ff2
commit
c7332d3651
@ -113,24 +113,24 @@ class PreProcessor(object):
|
|||||||
# some lit files don't have any <p> tags or equivalent (generally just plain text between
|
# some lit files don't have any <p> tags or equivalent (generally just plain text between
|
||||||
# <pre> tags), check and mark up line endings if required before proceeding
|
# <pre> tags), check and mark up line endings if required before proceeding
|
||||||
if self.no_markup(html, 0.1):
|
if self.no_markup(html, 0.1):
|
||||||
self.log("not enough paragraph markers, adding now")
|
self.log("not enough paragraph markers, adding now")
|
||||||
# check if content is in pre tags, use txt processor to mark up if so
|
# check if content is in pre tags, use txt processor to mark up if so
|
||||||
pre = re.compile(r'<pre>', re.IGNORECASE)
|
pre = re.compile(r'<pre>', re.IGNORECASE)
|
||||||
if len(pre.findall(html)) == 1:
|
if len(pre.findall(html)) == 1:
|
||||||
self.log("Running Text Processing")
|
self.log("Running Text Processing")
|
||||||
from calibre.ebooks.txt.processor import convert_basic, preserve_spaces, \
|
from calibre.ebooks.txt.processor import convert_basic, preserve_spaces, \
|
||||||
separate_paragraphs_single_line
|
separate_paragraphs_single_line
|
||||||
outerhtml = re.compile(r'.*?(?<=<pre>)(?P<text>.*)(?=</pre>).*', re.IGNORECASE|re.DOTALL)
|
outerhtml = re.compile(r'.*?(?<=<pre>)(?P<text>.*)(?=</pre>).*', re.IGNORECASE|re.DOTALL)
|
||||||
html = outerhtml.sub('\g<text>', html)
|
html = outerhtml.sub('\g<text>', html)
|
||||||
html = separate_paragraphs_single_line(html)
|
html = separate_paragraphs_single_line(html)
|
||||||
html = preserve_spaces(html)
|
html = preserve_spaces(html)
|
||||||
html = convert_basic(html, epub_split_size_kb=0)
|
html = convert_basic(html, epub_split_size_kb=0)
|
||||||
else:
|
else:
|
||||||
# Add markup naively
|
# Add markup naively
|
||||||
# TODO - find out if there are cases where there are more than one <pre> tag or
|
# TODO - find out if there are cases where there are more than one <pre> tag or
|
||||||
# other types of unmarked html and handle them in some better fashion
|
# other types of unmarked html and handle them in some better fashion
|
||||||
add_markup = re.compile('(?<!>)(\n)')
|
add_markup = re.compile('(?<!>)(\n)')
|
||||||
html = add_markup.sub('</p>\n<p>', html)
|
html = add_markup.sub('</p>\n<p>', html)
|
||||||
|
|
||||||
###### Mark Indents/Cleanup ######
|
###### Mark Indents/Cleanup ######
|
||||||
#
|
#
|
||||||
@ -164,8 +164,8 @@ class PreProcessor(object):
|
|||||||
self.log("deleting blank lines")
|
self.log("deleting blank lines")
|
||||||
html = blankreg.sub('', html)
|
html = blankreg.sub('', html)
|
||||||
elif float(len(blanklines)) / float(len(lines)) > 0.40:
|
elif float(len(blanklines)) / float(len(lines)) > 0.40:
|
||||||
blanks_between_paragraphs = True
|
blanks_between_paragraphs = True
|
||||||
#print "blanks between paragraphs is marked True"
|
#print "blanks between paragraphs is marked True"
|
||||||
else:
|
else:
|
||||||
blanks_between_paragraphs = False
|
blanks_between_paragraphs = False
|
||||||
#self.dump(html, 'before_chapter_markup')
|
#self.dump(html, 'before_chapter_markup')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user