From 0051ca5db6a84c480f045c2d7b3344469858f828 Mon Sep 17 00:00:00 2001 From: Harshit Bansal Date: Wed, 16 Jan 2019 09:11:30 +0000 Subject: [PATCH] markdown: Extract `make_emoji_span()`. --- static/js/markdown.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/static/js/markdown.js b/static/js/markdown.js index 97adf7b0dc..298954b843 100644 --- a/static/js/markdown.js +++ b/static/js/markdown.js @@ -140,15 +140,19 @@ exports.is_status_message = function (raw_content, content) { content.indexOf('

') !== -1; }; +function make_emoji_span(codepoint, title, alt_text) { + return '' + alt_text + + ''; +} + function handleUnicodeEmoji(unicode_emoji) { var codepoint = unicode_emoji.codePointAt(0).toString(16); if (emoji_codes.codepoint_to_name.hasOwnProperty(codepoint)) { var emoji_name = emoji_codes.codepoint_to_name[codepoint]; var alt_text = ':' + emoji_name + ':'; var title = emoji_name.split("_").join(" "); - return '' + alt_text + - ''; + return make_emoji_span(codepoint, title, alt_text); } return unicode_emoji; } @@ -163,9 +167,7 @@ function handleEmoji(emoji_name) { ' title="' + title + '">'; } else if (emoji_codes.name_to_codepoint.hasOwnProperty(emoji_name)) { var codepoint = emoji_codes.name_to_codepoint[emoji_name]; - return '' + alt_text + - ''; + return make_emoji_span(codepoint, title, alt_text); } return alt_text; }