diff --git a/util/format.py b/util/format.py index a5b532e..da20356 100644 --- a/util/format.py +++ b/util/format.py @@ -27,12 +27,21 @@ from datetime import datetime def nl2br(text): - if not text: return text + if not text: + return text if '\n' in text: # Unix or DOS line endings return '
\n'.join(x.replace('\r', '') for x in text.split('\n')) else: # gracefully handle Mac line endigns return '
\n'.join(text.split('\r')) +def nl2pipe(text): + if not text: + return text + if '\n' in text: # Unix or DOS line endings + return ' | '.join(x.replace('\r', '') for x in text.split('\n')) + else: + return ' | '.join(text.split('\r')) + def formatDate(dt=None, type='date', variant='medium', lang='de'): """ type: date, time, dateTime;