comparison rhodecode/lib/markup_renderer.py @ 2201:ea5ff843b200 beta

#426 fixed mention extracting regex
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 18 Apr 2012 02:07:22 +0200
parents 8ecfed1d8f8b
children cdce3d7282b2
comparison
equal deleted inserted replaced
2200:d7a4c7e3528e 2201:ea5ff843b200
25 # along with this program. If not, see <http://www.gnu.org/licenses/>. 25 # along with this program. If not, see <http://www.gnu.org/licenses/>.
26 26
27 import re 27 import re
28 import logging 28 import logging
29 29
30 from rhodecode.lib.utils2 import safe_unicode 30 from rhodecode.lib.utils2 import safe_unicode, MENTIONS_REGEX
31 31
32 log = logging.getLogger(__name__) 32 log = logging.getLogger(__name__)
33 33
34 34
35 class MarkupRenderer(object): 35 class MarkupRenderer(object):
126 log.warning('Install docutils to use this function') 126 log.warning('Install docutils to use this function')
127 return cls.plain(source) 127 return cls.plain(source)
128 128
129 @classmethod 129 @classmethod
130 def rst_with_mentions(cls, source): 130 def rst_with_mentions(cls, source):
131 mention_pat = re.compile(r'(?:^@|\s@)(\w+)') 131 mention_pat = re.compile(MENTIONS_REGEX)
132 132
133 def wrapp(match_obj): 133 def wrapp(match_obj):
134 uname = match_obj.groups()[0] 134 uname = match_obj.groups()[0]
135 return ' **@%(uname)s** ' % {'uname':uname} 135 return ' **@%(uname)s** ' % {'uname': uname}
136 mention_hl = mention_pat.sub(wrapp, source).strip() 136 mention_hl = mention_pat.sub(wrapp, source).strip()
137 return cls.rst(mention_hl) 137 return cls.rst(mention_hl)