diff options
| -rwxr-xr-x | build-concerts.py | 22 | ||||
| -rw-r--r-- | helpers.py | 14 |
2 files changed, 21 insertions, 15 deletions
diff --git a/build-concerts.py b/build-concerts.py index d1a7c11..0e5a70b 100755 --- a/build-concerts.py +++ b/build-concerts.py @@ -5,7 +5,13 @@ from pathlib import Path import re from sys import argv -from helpers import guess_language, read_concerts, relative_path, tmplocale +from helpers import ( + guess_language, + read_concerts, + relative_path, + tmplocale, + touchup_plaintext, +) # TODO: change some jargon: @@ -162,20 +168,6 @@ def break_lines(lines): return tuple(line+'<br>' for line in lines[:-1]) + (lines[-1],) -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 - - def print_concert_details(concert, lang): concert_id = f'concert-{concert.time.strftime("%F")}' classes = ('details',) @@ -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 |
