Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
markdown: Move handleLinkifier.
Steve Howell2a240d3e1901
diff --git a/static/js/linkifiers.js b/static/js/linkifiers.jsindex 2c423130384..ad335eeca2d 100644--- a/static/js/linkifiers.js+++ b/static/js/linkifiers.js@@ -8,20 +8,6 @@ export function get_linkifier_map() {return linkifier_map;}-function handleLinkifier(pattern, matches) {- let url = linkifier_map.get(pattern);-- let current_group = 1;-- for (const match of matches) {- const back_ref = "\\" + current_group;- url = url.replace(back_ref, match);- current_group += 1;- }-- return url;-}-function python_to_js_linkifier(pattern, url) {// Converts a python named-group regex to a javascript-compatible numbered// group regex... with a regex!@@ -102,6 +88,4 @@ export function update_linkifier_rules(linkifiers) {export function initialize(linkifiers) {update_linkifier_rules(linkifiers);-- marked.setOptions({linkifierHandler: handleLinkifier});}diff --git a/static/js/markdown.js b/static/js/markdown.jsindex 961fc48512f..424e38f8d75 100644--- a/static/js/markdown.js+++ b/static/js/markdown.js@@ -373,6 +373,20 @@ function handleEmoji(emoji_name) {return alt_text;}+function handleLinkifier(pattern, matches) {+ let url = linkifiers.get_linkifier_map().get(pattern);++ let current_group = 1;++ for (const match of matches) {+ const back_ref = "\\" + current_group;+ url = url.replace(back_ref, match);+ current_group += 1;+ }++ return url;+}+function handleTimestamp(time) {let timeobject;if (Number.isNaN(Number(time))) {@@ -509,6 +523,7 @@ export function setup() {smartypants: false,zulip: true,emojiHandler: handleEmoji,+ linkifierHandler: handleLinkifier,unicodeEmojiHandler: handleUnicodeEmoji,streamHandler: handleStream,streamTopicHandler: handleStreamTopic,