summaryrefslogtreecommitdiff
path: root/helpers.py
diff options
context:
space:
mode:
Diffstat (limited to 'helpers.py')
-rw-r--r--helpers.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/helpers.py b/helpers.py
index 87ed9c1..a746ea2 100644
--- a/helpers.py
+++ b/helpers.py
@@ -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