diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -717,3 +717,12 @@ def urlify_text(text): def rst(source): return literal('
%s
' % MarkupRenderer.rst(source)) + +def rst_w_mentions(source): + """ + Wrapped rst renderer with @mention highlighting + + :param source: + """ + return literal('
%s
' % + MarkupRenderer.rst_with_mentions(source)) diff --git a/rhodecode/lib/markup_renderer.py b/rhodecode/lib/markup_renderer.py --- a/rhodecode/lib/markup_renderer.py +++ b/rhodecode/lib/markup_renderer.py @@ -127,3 +127,13 @@ class MarkupRenderer(object): log.warning('Install docutils to use this function') return cls.plain(source) + @classmethod + def rst_with_mentions(cls, source): + mention_pat = re.compile(r'(?:^@|\s@)(\w+)') + + def wrapp(match_obj): + uname = match_obj.groups()[0] + return ' **@%(uname)s** ' % {'uname':uname} + mention_hl = mention_pat.sub(wrapp, source).strip() + return cls.rst(mention_hl) + diff --git a/rhodecode/model/notification.py b/rhodecode/model/notification.py --- a/rhodecode/model/notification.py +++ b/rhodecode/model/notification.py @@ -104,7 +104,7 @@ class NotificationModel(BaseModel): email_subject = NotificationModel().make_description(notif, False) type_ = type_ email_body = body - kwargs = {'subject':subject, 'body':h.rst(body)} + kwargs = {'subject':subject, 'body':h.rst_w_mentions(body)} kwargs.update(email_kwargs) email_body_html = EmailNotificationModel()\ .get_email_tmpl(type_, **kwargs) diff --git a/rhodecode/templates/admin/notifications/show_notification.html b/rhodecode/templates/admin/notifications/show_notification.html --- a/rhodecode/templates/admin/notifications/show_notification.html +++ b/rhodecode/templates/admin/notifications/show_notification.html @@ -39,7 +39,7 @@ -
${h.rst(c.notification.body)}
+
${h.rst_w_mentions(c.notification.body)}
diff --git a/rhodecode/templates/changeset/changeset_file_comment.html b/rhodecode/templates/changeset/changeset_file_comment.html --- a/rhodecode/templates/changeset/changeset_file_comment.html +++ b/rhodecode/templates/changeset/changeset_file_comment.html @@ -25,7 +25,7 @@ ${_('Delete')} %endif - ${h.rst(co.text)|n} + ${h.rst_w_mentions(co.text)|n}