Heuristic: Tweak italicizing common works to ensure it does not match inside of a word.

This commit is contained in:
John Schember 2011-01-25 19:17:41 -05:00
parent 2912d93027
commit 76fe7be36f

View File

@ -155,7 +155,7 @@ class HeuristicProcessor(object):
] ]
for word in ITALICIZE_WORDS: for word in ITALICIZE_WORDS:
html = html.replace(word, '<i>%s</i>' % word) html = re.sub(r'(?<=\s|>)' + word + r'(?=\s|<)', '<i>%s</i>' % word, html)
for pat in ITALICIZE_STYLE_PATS: for pat in ITALICIZE_STYLE_PATS:
html = re.sub(pat, lambda mo: '<i>%s</i>' % mo.group('words'), html) html = re.sub(pat, lambda mo: '<i>%s</i>' % mo.group('words'), html)