mirror of
https://github.com/zulip/zulip.git
synced 2025-11-16 03:41:58 +00:00
markdown: Move handleLinkifier.
All the other handleFoo functions followed this convention.
This commit is contained in:
@@ -8,20 +8,6 @@ export function get_linkifier_map() {
|
|||||||
return 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) {
|
function python_to_js_linkifier(pattern, url) {
|
||||||
// Converts a python named-group regex to a javascript-compatible numbered
|
// Converts a python named-group regex to a javascript-compatible numbered
|
||||||
// group regex... with a regex!
|
// group regex... with a regex!
|
||||||
@@ -102,6 +88,4 @@ export function update_linkifier_rules(linkifiers) {
|
|||||||
|
|
||||||
export function initialize(linkifiers) {
|
export function initialize(linkifiers) {
|
||||||
update_linkifier_rules(linkifiers);
|
update_linkifier_rules(linkifiers);
|
||||||
|
|
||||||
marked.setOptions({linkifierHandler: handleLinkifier});
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -373,6 +373,20 @@ function handleEmoji(emoji_name) {
|
|||||||
return alt_text;
|
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) {
|
function handleTimestamp(time) {
|
||||||
let timeobject;
|
let timeobject;
|
||||||
if (Number.isNaN(Number(time))) {
|
if (Number.isNaN(Number(time))) {
|
||||||
@@ -509,6 +523,7 @@ export function setup() {
|
|||||||
smartypants: false,
|
smartypants: false,
|
||||||
zulip: true,
|
zulip: true,
|
||||||
emojiHandler: handleEmoji,
|
emojiHandler: handleEmoji,
|
||||||
|
linkifierHandler: handleLinkifier,
|
||||||
unicodeEmojiHandler: handleUnicodeEmoji,
|
unicodeEmojiHandler: handleUnicodeEmoji,
|
||||||
streamHandler: handleStream,
|
streamHandler: handleStream,
|
||||||
streamTopicHandler: handleStreamTopic,
|
streamTopicHandler: handleStreamTopic,
|
||||||
|
|||||||
Reference in New Issue
Block a user