added a search for emphasized lines during chapter markup

This commit is contained in:
ldolse 2010-11-17 10:25:51 +08:00
parent 4526ced6d1
commit 26ba75f76c

View File

@ -177,9 +177,10 @@ class PreProcessor(object):
numeric_chapters = r".?(\d+\.?|(CHAPTER\s*([\dA-Z\-\'\"\?\.!#,]+\s*){1,10}))\s*"
uppercase_chapters = r"\s*.?([A-Z#]+(\s|-){0,3}){1,5}\s*"
numeric_titles = r".?(\d+\.?\s+([\d\w-]+\:?\'?-?\s?){0,5})\s*"
emphasized_lines = r"<b[^>]*>\s*(<span[^>]*>)?\s*(\s*(?=[\w#\-*\s]+<)([\w#-*]+\s*){1,5}\s*)(</span>)?\s*</b>"
full_chapter_line = chapter_line_open+chapter_header_open+typical_chapters+chapter_header_close+chapter_line_close
n_lookahead = re.sub("(out|inn|cha)", "l", full_chapter_line)
n_lookahead = re.sub("(ou|in|cha)", "lookahead_", full_chapter_line)
print "n_lookahead is " + n_lookahead
print "Chapter line is " + full_chapter_line + "\n\n"
chapter_marker = lookahead+full_chapter_line+blank_lines+n_lookahead_open+n_lookahead+n_lookahead_close+opt_title_open+title_line_open+title_header_open+default_title+title_header_close+title_line_close+opt_title_close
@ -195,7 +196,18 @@ class PreProcessor(object):
if self.html_preprocess_sections < 10:
self.log("not enough chapters, only " + unicode(self.html_preprocess_sections) + ", trying numeric chapters")
full_chapter_line = chapter_line_open+chapter_header_open+numeric_chapters+chapter_header_close+chapter_line_close
n_lookahead = re.sub("(out|inn|cha)", "l", full_chapter_line)
n_lookahead = re.sub("(ou|in|cha)", "lookahead_", full_chapter_line)
print "n_lookahead is " + n_lookahead
print "Chapter line is " + full_chapter_line + "\n\n"
chapter_marker = lookahead+full_chapter_line+blank_lines+n_lookahead_open+n_lookahead+n_lookahead_close+opt_title_open+title_line_open+title_header_open+default_title+title_header_close+title_line_close+opt_title_close
print chapter_marker
chapdetect2 = re.compile(r'%s' % chapter_marker, re.IGNORECASE)
html = chapdetect2.sub(self.chapter_head, html)
if self.html_preprocess_sections < 10:
self.log("not enough chapters, only " + unicode(self.html_preprocess_sections) + ", trying emphazised lines")
full_chapter_line = chapter_line_open+chapter_header_open+emphasized_lines+chapter_header_close+chapter_line_close
n_lookahead = re.sub("(ou|in|cha)", "lookahead_", full_chapter_line)
print "n_lookahead is " + n_lookahead
print "Chapter line is " + full_chapter_line + "\n\n"
chapter_marker = lookahead+full_chapter_line+blank_lines+n_lookahead_open+n_lookahead+n_lookahead_close+opt_title_open+title_line_open+title_header_open+default_title+title_header_close+title_line_close+opt_title_close
@ -206,7 +218,7 @@ class PreProcessor(object):
if self.html_preprocess_sections < 10:
self.log("not enough chapters, only " + unicode(self.html_preprocess_sections) + ", trying with uppercase words")
full_chapter_line = chapter_line_open+chapter_header_open+uppercase_chapters+chapter_header_close+chapter_line_close
n_lookahead = re.sub("(out|inn|cha)", "l", full_chapter_line)
n_lookahead = re.sub("(ou|in|cha)", "lookahead_", full_chapter_line)
print "n_lookahead is " + n_lookahead
print "Chapter line is " + full_chapter_line + "\n\n"
chapter_marker = lookahead+full_chapter_line+blank_lines+n_lookahead_open+n_lookahead+n_lookahead_close+opt_title_open+title_line_open+title_header_open+default_title+title_header_close+title_line_close+opt_title_close
@ -217,7 +229,7 @@ class PreProcessor(object):
if self.html_preprocess_sections < 10:
self.log("not enough chapters, only " + unicode(self.html_preprocess_sections) + ", trying numeric chapters with titles")
full_chapter_line = chapter_line_open+chapter_header_open+numeric_titles+chapter_header_close+chapter_line_close
n_lookahead = re.sub("(out|inn|cha)", "l", full_chapter_line)
n_lookahead = re.sub("(ou|in|cha)", "lookahead_", full_chapter_line)
print "n_lookahead is " + n_lookahead
print "Chapter line is " + full_chapter_line + "\n\n"
chapter_marker = lookahead+full_chapter_line+blank_lines+n_lookahead_open+n_lookahead+n_lookahead_close+opt_title_open+title_line_open+title_header_open+default_title+title_header_close+title_line_close+opt_title_close