diff options
Diffstat (limited to 'helpers.py')
| -rw-r--r-- | helpers.py | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -131,3 +131,17 @@ def read_concerts(filename): for match in re.finditer(_CONCERT_RE, f.read()) ) return tuple(sorted(concerts, key=attrgetter('time'))) + + +_TOUCHUPS = ( + (re.compile('([0-9])(st|nd|rd|th|er|ère|nde|ème)'), r'\1<sup>\2</sup>'), + (re.compile('(https://[^ ]+)'), r'<a href="\1" target="_blank">\1</a>'), + (re.compile('([^ ]+@[^ ]+)'), r'<a href="mailto:\1">\1</a>'), +) + + +def touchup_plaintext(plaintext): + text = plaintext + for regexp, repl in _TOUCHUPS: + text = regexp.sub(repl, text) + return text |
