+def reRepl(m):
+ ansiTypes = {
+ 'clear': ansiFormatter.cmdReset(),
+ 'hashtag': ansiFormatter.cmdBold(),
+ 'profile': ansiFormatter.cmdUnderline(),
+ }
+
+ s = None
+ try:
+ mkey = m.lastgroup
+ if m.group(mkey):
+ s = '%s%s%s' % (ansiTypes[mkey], m.group(mkey), ansiTypes['clear'])
+ except IndexError:
+ pass
+ return s
+
+def replaceInStatus(status):
+ txt = gHtmlParser.unescape(status)
+ txt = re.sub(hashtagRe, reRepl, txt)
+ txt = re.sub(profileRe, reRepl, txt)
+ return txt
+