Show More
@@ -55,7 +55,7 b' from kallithea.lib.annotate import annot' | |||||
55 | from kallithea.lib.utils import repo_name_slug, get_custom_lexer |
|
55 | from kallithea.lib.utils import repo_name_slug, get_custom_lexer | |
56 | from kallithea.lib.utils2 import str2bool, safe_unicode, safe_str, \ |
|
56 | from kallithea.lib.utils2 import str2bool, safe_unicode, safe_str, \ | |
57 | get_changeset_safe, datetime_to_time, time_to_datetime, AttributeDict, \ |
|
57 | get_changeset_safe, datetime_to_time, time_to_datetime, AttributeDict, \ | |
58 | safe_int |
|
58 | safe_int, MENTIONS_REGEX | |
59 | from kallithea.lib.markup_renderer import MarkupRenderer, url_re |
|
59 | from kallithea.lib.markup_renderer import MarkupRenderer, url_re | |
60 | from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError |
|
60 | from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError | |
61 | from kallithea.lib.vcs.backends.base import BaseChangeset, EmptyChangeset |
|
61 | from kallithea.lib.vcs.backends.base import BaseChangeset, EmptyChangeset | |
@@ -1397,6 +1397,26 b' def rst_w_mentions(source):' | |||||
1397 | return literal('<div class="rst-block">%s</div>' % |
|
1397 | return literal('<div class="rst-block">%s</div>' % | |
1398 | MarkupRenderer.rst_with_mentions(source)) |
|
1398 | MarkupRenderer.rst_with_mentions(source)) | |
1399 |
|
1399 | |||
|
1400 | ||||
|
1401 | def mentions_replace(match_obj): | |||
|
1402 | return '<b>@%s</b>' % match_obj.group(1) | |||
|
1403 | ||||
|
1404 | ||||
|
1405 | def render_w_mentions(source): | |||
|
1406 | """ | |||
|
1407 | Render plain text with @mention highlighting. | |||
|
1408 | """ | |||
|
1409 | s = source.rstrip() | |||
|
1410 | s = safe_unicode(s) | |||
|
1411 | s = '\n'.join(s.splitlines()) | |||
|
1412 | s = html_escape(s) | |||
|
1413 | # this sequence of html-ifications seems to be safe and non-conflicting | |||
|
1414 | # if the issues regexp is sane | |||
|
1415 | s = _urlify_text(s) | |||
|
1416 | s = MENTIONS_REGEX.sub(mentions_replace, s) | |||
|
1417 | return literal('<code style="white-space:pre-wrap">%s</code>' % s) | |||
|
1418 | ||||
|
1419 | ||||
1400 | def short_ref(ref_type, ref_name): |
|
1420 | def short_ref(ref_type, ref_name): | |
1401 | if ref_type == 'rev': |
|
1421 | if ref_type == 'rev': | |
1402 | return short_id(ref_name) |
|
1422 | return short_id(ref_name) |
General Comments 0
You need to be logged in to leave comments.
Login now