diff --git a/kallithea/lib/helpers.py b/kallithea/lib/helpers.py --- a/kallithea/lib/helpers.py +++ b/kallithea/lib/helpers.py @@ -1248,13 +1248,15 @@ def fancy_file_stats(stats): _URLIFY_RE = re.compile(r''' # URL markup (?P%s) | +# @mention markup +(?P%s) | # "Stylize" markup \[see\ \=>\ *(?P[a-zA-Z0-9\/\=\?\&\ \:\/\.\-]*)\] | \[license\ \=>\ *(?P[a-zA-Z0-9\/\=\?\&\ \:\/\.\-]*)\] | \[(?Prequires|recommends|conflicts|base)\ \=>\ *(?P[a-zA-Z0-9\-\/]*)\] | \[(?:lang|language)\ \=>\ *(?P[a-zA-Z\-\/\#\+]*)\] | \[(?P[a-z]+)\] -''' % (url_re.pattern), +''' % (url_re.pattern, MENTIONS_REGEX.pattern), re.VERBOSE | re.MULTILINE | re.IGNORECASE) @@ -1273,6 +1275,9 @@ def urlify_text(s, repo_name=None, link_ url = match_obj.group('url') if url is not None: return '%(url)s' % {'url': url} + mention = match_obj.group('mention') + if mention is not None: + return '%s' % mention if stylize: seen = match_obj.group('seen') if seen: @@ -1308,7 +1313,6 @@ def urlify_text(s, repo_name=None, link_ s = _urlify(s) if repo_name is not None: s = urlify_issues(s, repo_name, link_) - s = MENTIONS_REGEX.sub(_mentions_replace, s) s = s.replace('\r\n', '
').replace('\n', '
') return literal(s) @@ -1413,10 +1417,6 @@ def urlify_issues(newtext, repo_name, li return newtext -def _mentions_replace(match_obj): - return '@%s' % match_obj.group(1) - - def render_w_mentions(source, repo_name=None): """ Render plain text with revision hashes and issue references urlified diff --git a/kallithea/lib/markup_renderer.py b/kallithea/lib/markup_renderer.py --- a/kallithea/lib/markup_renderer.py +++ b/kallithea/lib/markup_renderer.py @@ -190,10 +190,9 @@ class MarkupRenderer(object): @classmethod def rst_with_mentions(cls, source): - mention_pat = re.compile(MENTIONS_REGEX) def wrapp(match_obj): uname = match_obj.groups()[0] return '\ **@%(uname)s**\ ' % {'uname': uname} - mention_hl = mention_pat.sub(wrapp, source).strip() + mention_hl = MENTIONS_REGEX.sub(wrapp, source).strip() return cls.rst(mention_hl)