diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2022-02-21 19:57:49 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2022-02-21 19:57:49 +0100 |
| commit | 5876793d01ab2e392e93eec9323dd6a7edb53170 (patch) | |
| tree | 9bb1ca9ee8460a9257b5d6e0617606b2f4d34ce5 /helpers.py | |
| parent | 836aaf1fdfa5a60d261ed6e06e880d08b1b68bd0 (diff) | |
| download | quatuorbellefeuille.com-5876793d01ab2e392e93eec9323dd6a7edb53170.tar.xz | |
Extract more stuff out of build-concerts.py
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 |
