mirror of https://github.com/zulip/zulip.git
minor: Convert `emoticon_regex` to uppercase.
Following the convention, we use uppercase for regex. Also, `emoticon_regex` is given a conventional name ending with `*_RE`: `EMOTICON_RE`.
This commit is contained in:
parent
9f6e6709d3
commit
ffc4724287
|
@ -30,7 +30,7 @@ EMOTICON_CONVERSIONS = emoji_codes["emoticon_conversions"]
|
||||||
possible_emoticons = EMOTICON_CONVERSIONS.keys()
|
possible_emoticons = EMOTICON_CONVERSIONS.keys()
|
||||||
possible_emoticon_regexes = (re.escape(emoticon) for emoticon in possible_emoticons)
|
possible_emoticon_regexes = (re.escape(emoticon) for emoticon in possible_emoticons)
|
||||||
terminal_symbols = ",.;?!()\\[\\] \"'\\n\\t" # from composebox_typeahead.js
|
terminal_symbols = ",.;?!()\\[\\] \"'\\n\\t" # from composebox_typeahead.js
|
||||||
emoticon_regex = (
|
EMOTICON_RE = (
|
||||||
f"(?<![^{terminal_symbols}])(?P<emoticon>("
|
f"(?<![^{terminal_symbols}])(?P<emoticon>("
|
||||||
+ ")|(".join(possible_emoticon_regexes)
|
+ ")|(".join(possible_emoticon_regexes)
|
||||||
+ f"))(?![^{terminal_symbols}])"
|
+ f"))(?![^{terminal_symbols}])"
|
||||||
|
|
|
@ -48,12 +48,7 @@ from typing_extensions import TypedDict
|
||||||
from zerver.lib import mention as mention
|
from zerver.lib import mention as mention
|
||||||
from zerver.lib.cache import NotFoundInCache, cache_with_key
|
from zerver.lib.cache import NotFoundInCache, cache_with_key
|
||||||
from zerver.lib.camo import get_camo_url
|
from zerver.lib.camo import get_camo_url
|
||||||
from zerver.lib.emoji import (
|
from zerver.lib.emoji import EMOTICON_RE, codepoint_to_name, name_to_codepoint, translate_emoticons
|
||||||
codepoint_to_name,
|
|
||||||
emoticon_regex,
|
|
||||||
name_to_codepoint,
|
|
||||||
translate_emoticons,
|
|
||||||
)
|
|
||||||
from zerver.lib.exceptions import MarkdownRenderingException
|
from zerver.lib.exceptions import MarkdownRenderingException
|
||||||
from zerver.lib.markdown import fenced_code
|
from zerver.lib.markdown import fenced_code
|
||||||
from zerver.lib.markdown.fenced_code import FENCE_RE
|
from zerver.lib.markdown.fenced_code import FENCE_RE
|
||||||
|
@ -2247,7 +2242,7 @@ class Markdown(markdown.Markdown):
|
||||||
markdown.inlinepatterns.SimpleTextInlineProcessor(NOT_STRONG_RE), "not_strong", 20
|
markdown.inlinepatterns.SimpleTextInlineProcessor(NOT_STRONG_RE), "not_strong", 20
|
||||||
)
|
)
|
||||||
reg.register(Emoji(EMOJI_REGEX, self), "emoji", 15)
|
reg.register(Emoji(EMOJI_REGEX, self), "emoji", 15)
|
||||||
reg.register(EmoticonTranslation(emoticon_regex, self), "translate_emoticons", 10)
|
reg.register(EmoticonTranslation(EMOTICON_RE, self), "translate_emoticons", 10)
|
||||||
# We get priority 5 from 'nl2br' extension
|
# We get priority 5 from 'nl2br' extension
|
||||||
reg.register(UnicodeEmoji(unicode_emoji_regex), "unicodeemoji", 0)
|
reg.register(UnicodeEmoji(unicode_emoji_regex), "unicodeemoji", 0)
|
||||||
return reg
|
return reg
|
||||||
|
|
Loading…
Reference in New Issue