TXT Input: Fix self closed title tags being generated

This commit is contained in:
Kovid Goyal 2012-02-05 23:07:50 +05:30
parent 4b9d1e40fc
commit 08c840cba3

View File

@ -16,7 +16,7 @@ from calibre.ebooks.metadata.opf2 import OPFCreator
from calibre.ebooks.conversion.preprocess import DocAnalysis from calibre.ebooks.conversion.preprocess import DocAnalysis
from calibre.utils.cleantext import clean_ascii_chars from calibre.utils.cleantext import clean_ascii_chars
HTML_TEMPLATE = u'<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>%s</title></head><body>\n%s\n</body></html>' HTML_TEMPLATE = u'<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>%s </title></head><body>\n%s\n</body></html>'
def clean_txt(txt): def clean_txt(txt):
''' '''
@ -28,7 +28,7 @@ def clean_txt(txt):
# Strip whitespace from the end of the line. Also replace # Strip whitespace from the end of the line. Also replace
# all line breaks with \n. # all line breaks with \n.
txt = '\n'.join([line.rstrip() for line in txt.splitlines()]) txt = '\n'.join([line.rstrip() for line in txt.splitlines()])
# Replace whitespace at the beginning of the line with &nbsp; # Replace whitespace at the beginning of the line with &nbsp;
txt = re.sub('(?m)(?<=^)([ ]{2,}|\t+)(?=.)', '&nbsp;' * 4, txt) txt = re.sub('(?m)(?<=^)([ ]{2,}|\t+)(?=.)', '&nbsp;' * 4, txt)
@ -75,7 +75,7 @@ def convert_basic(txt, title='', epub_split_size_kb=0):
''' '''
Converts plain text to html by putting all paragraphs in Converts plain text to html by putting all paragraphs in
<p> tags. It condense and retains blank lines when necessary. <p> tags. It condense and retains blank lines when necessary.
Requires paragraphs to be in single line format. Requires paragraphs to be in single line format.
''' '''
txt = clean_txt(txt) txt = clean_txt(txt)
@ -215,7 +215,7 @@ def detect_paragraph_type(txt):
def detect_formatting_type(txt): def detect_formatting_type(txt):
''' '''
Tries to determine the formatting of the document. Tries to determine the formatting of the document.
markdown: Markdown formatting is used. markdown: Markdown formatting is used.
textile: Textile formatting is used. textile: Textile formatting is used.
heuristic: When none of the above formatting types are heuristic: When none of the above formatting types are