Browse Source

Skip <code> tags when linkifying groups/users

merge-requests/26/head
Deimos 6 years ago
parent
commit
2afcb216ea
  1. 8
      tildes/tests/test_markdown.py
  2. 2
      tildes/tildes/lib/markdown.py

8
tildes/tests/test_markdown.py

@ -338,3 +338,11 @@ def test_username_ref_inside_pre_ignored():
processed = convert_markdown_to_safe_html(markdown)
assert "<a" not in processed
def test_group_ref_inside_code_ignored():
"""Ensure a group reference inside a <code> tag doesn't get linked."""
markdown = "Strikethrough works like: `this ~should not~ work`."
processed = convert_markdown_to_safe_html(markdown)
assert "<a" not in processed

2
tildes/tildes/lib/markdown.py

@ -170,7 +170,7 @@ def escape_accidental_ordered_lists(markdown: str) -> str:
def postprocess_markdown_html(html: str) -> str:
"""Apply post-processing to HTML generated by markdown parser."""
# list of tag names to exclude from linkification
linkify_skipped_tags = ["pre"]
linkify_skipped_tags = ["code", "pre"]
# search for text that looks like urls and convert to actual links
html = bleach.linkify(

Loading…
Cancel
Save