Mercurial > p > roundup > code
diff roundup/cgi/templating.py @ 6280:6ed5152a92d0
issue2551096 - enable markdown autolink for email and bare url's.
Modify raw markdown adding appropriate link markers '<' and '>' on the
fly so bare urls and email addreses are recognized as explicit links
by markdown backends. Patch by Cedric Krier.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Thu, 29 Oct 2020 23:15:31 -0400 |
| parents | 9ec3a9bc4ea5 |
| children | d30501bafdfb |
line wrap: on
line diff
--- a/roundup/cgi/templating.py Thu Oct 29 17:08:44 2020 -0400 +++ b/roundup/cgi/templating.py Thu Oct 29 23:15:31 2020 -0400 @@ -1621,6 +1621,23 @@ return match.group(0) def _hyper_repl_markdown(self, match): + for group in ['url', 'email']: + if match.group(group): + start = match.start(group) - 1 + end = match.end(group) + if start >= 0: + prefix = match.string[start] + if end < len(match.string): + suffix = match.string[end] + if (prefix, suffix) in { + ('<', '>'), + ('(', ')'), + }: + continue + if prefix == '(' and match.string[end - 1] == ')': + continue + s = match.group(group) + return '<%s>' % s if match.group('id') and len(match.group('id')) < 10: return self._hyper_repl_item(match,'[%(item)s](%(cls)s%(id)s)') else:
