around our code blocks instead a codehilite , and disable class-specific highlighting
// We special-case the 'quote' language and output a blockquote
r.code = function (code, lang) {
if (lang === 'quote') {
return '' + escape(code, true) + '
';
}
return ''
+ escape(code, true)
+ '\n
';
};
// Our links have title= and target=_blank
r.link = function (href, title, text) {
title = title || href;
var out = '' + text + '';
return out;
};
// Disable ordered lists
// We used GFM + tables, so replace the list start regex for that ruleset
// We remove the |[\d+]\. that matches the numbering in a numbered list
marked.Lexer.rules.tables.list = /^( *)((?:\*)) [\s\S]+?(?:\n+(?=(?: *[\-*_]){3,} *(?:\n+|$))|\n{2,}(?! )(?!\1(?:\*) )\n*|\s*$)/;
// Disable headings
disable_markdown_regex(marked.Lexer.rules.tables, 'heading');
disable_markdown_regex(marked.Lexer.rules.tables, 'lheading');
// Disable __strong__, all
marked.InlineLexer.rules.zulip.strong = /^\*\*([\s\S]+?)\*\*(?!\*)/;
disable_markdown_regex(marked.InlineLexer.rules.zulip, 'em');
disable_markdown_regex(marked.InlineLexer.rules.zulip, 'del');
// Disable autolink as (a) it is not used in our backend and (b) it interferes with @mentions
disable_markdown_regex(marked.InlineLexer.rules.zulip, 'autolink');
exports.set_realm_filters(page_params.realm_filters);
marked.setOptions({
gfm: true,
tables: true,
breaks: true,
pedantic: false,
sanitize: true,
smartLists: true,
smartypants: false,
zulip: true,
emojiHandler: handleEmoji,
userMentionHandler: handleUserMentions,
realmFilterHandler: handleRealmFilter,
renderer: r
});
function on_failed_action(action, callback) {
$("#main_div").on("click", "." + action + "-failed-message", function (e) {
e.stopPropagation();
popovers.hide_all();
var row = $(this).closest(".message_row");
var message_id = rows.id(row);
// Message should be waiting for ack and only have a local id,
// otherwise send would not have failed
var message = waiting_for_ack[message_id];
if (message === undefined) {
blueslip.warning("Got resend or retry on failure request but did not find message in ack list " + message_id);
return;
}
callback(message, row);
});
}
on_failed_action('remove', abort_message);
on_failed_action('refresh', resend_message);
on_failed_action('edit', edit_failed_message);
});
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = echo;
}