# HG changeset patch # User Mads Kiilerich # Date 1473115878 -7200 # Node ID 26648b25473d1686823c15cc6b6e3d33680ac402 # Parent ca830f9d01a8d38dd7486cb64c7bfd0266b4a557 helpers: inline stylize markup in urlify_text diff -r ca830f9d01a8 -r 26648b25473d kallithea/lib/helpers.py --- a/kallithea/lib/helpers.py Tue Sep 06 00:51:18 2016 +0200 +++ b/kallithea/lib/helpers.py Tue Sep 06 00:51:18 2016 +0200 @@ -540,29 +540,6 @@ return id_ -def desc_stylize(value): - """ - converts tags from value into html equivalent - - :param value: - """ - if not value: - return '' - - value = re.sub(r'\[see\ \=>\ *([a-zA-Z0-9\/\=\?\&\ \:\/\.\-]*)\]', - '
see => \\1
', value) - value = re.sub(r'\[license\ \=>\ *([a-zA-Z0-9\/\=\?\&\ \:\/\.\-]*)\]', - '
\\1
', value) - value = re.sub(r'\[(requires|recommends|conflicts|base)\ \=>\ *([a-zA-Z0-9\-\/]*)\]', - '
\\1 => \\2
', value) - value = re.sub(r'\[(lang|language)\ \=>\ *([a-zA-Z\-\/\#\+]*)\]', - '
\\2
', value) - value = re.sub(r'\[([a-z]+)\]', - '
\\1
', value) - - return value - - def boolicon(value): """Returns boolean value of a value, represented as small html image of true/false icons @@ -1270,7 +1247,13 @@ _URLIFY_RE = re.compile(r''' # URL markup -(?P%s) +(?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), re.VERBOSE | re.MULTILINE | re.IGNORECASE) @@ -1290,6 +1273,23 @@ url = match_obj.group('url') if url is not None: return '%(url)s' % {'url': url} + if stylize: + seen = match_obj.group('seen') + if seen: + return '
see => %s
' % seen + license = match_obj.group('license') + if license: + return '' % (license, license) + tagtype = match_obj.group('tagtype') + if tagtype: + tagvalue = match_obj.group('tagvalue') + return '
%s => %s
' % (tagtype, tagtype, tagvalue, tagvalue) + lang = match_obj.group('lang') + if lang: + return '
%s
' % lang + tag = match_obj.group('tag') + if tag: + return '
%s
' % (tag, tag) return match_obj.group(0) def _urlify(s): @@ -1305,8 +1305,6 @@ s = html_escape(s) if repo_name is not None: s = urlify_changesets(s, repo_name) - if stylize: - s = desc_stylize(s) s = _urlify(s) if repo_name is not None: s = urlify_issues(s, repo_name, link_)