markdown: Fix emojis not rendering with :bogus: in the line.

This fixes an issue where invalid emoji name prevents following
emojis from rendering.

This reverts the code change in
8842349629, while still passing the
tests added in that commit (it seems the original commit had
misdiagnosed an ordering bug and thus introduced this issue).

Fixes: #11770.
This commit is contained in:
overide 2019-03-05 12:48:59 +05:30 committed by Tim Abbott
parent 0be410d3fe
commit 58d28eed5d
2 changed files with 6 additions and 1 deletions

View File

@ -1179,7 +1179,7 @@ class Emoji(markdown.inlinepatterns.Pattern):
elif name in name_to_codepoint:
return make_emoji(name_to_codepoint[name], orig_syntax)
else:
return None
return orig_syntax
def content_has_emoji_syntax(content: str) -> bool:
return re.search(EMOJI_REGEX, content) is not None

View File

@ -542,6 +542,11 @@
"expected_output": "<p>Emojis like :man-girl-girl: which have ZWJ are banned for now.</p>",
"text_content": "Emojis like :man-girl-girl: which have ZWJ are banned for now."
},
{
"name": "valid_emoji_preceded_by_invalid_emoji",
"input": "This is :invalidemoji: which should not prevent rendering :smile:",
"expected_output": "<p>This is :invalidemoji: which should not prevent rendering <span aria-label=\"smile\" class=\"emoji emoji-263a\" role=\"img\" title=\"smile\">:smile:</span></p>"
},
{
"name": "safe_html",
"input": "<h1>stay normal</h1> thanks",