js: Normalize strings to double quotes.

Prettier would do this anyway, but it’s separated out for a more
reviewable diff.  Generated by ESLint.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-07-14 16:29:15 -07:00
committed by Tim Abbott
parent 06691e1e45
commit f3726db89a
344 changed files with 14425 additions and 14420 deletions

View File

@@ -33,7 +33,7 @@ exports.translate_emoticons_to_names = (text) => {
let translated = text;
let replacement_text;
const terminal_symbols = ',.;?!()[] "\'\n\t'; // From composebox_typeahead
const symbols_except_space = terminal_symbols.replace(' ', '');
const symbols_except_space = terminal_symbols.replace(" ", "");
const emoticon_replacer = function (match, g1, offset, str) {
const prev_char = str[offset - 1];
@@ -89,11 +89,11 @@ exports.apply_markdown = function (message) {
const options = {
userMentionHandler: function (mention, silently) {
if (mention === 'all' || mention === 'everyone' || mention === 'stream') {
if (mention === "all" || mention === "everyone" || mention === "stream") {
message.mentioned = true;
return '<span class="user-mention" data-user-id="*">' +
'@' + mention +
'</span>';
"@" + mention +
"</span>";
}
let full_name;
@@ -149,7 +149,7 @@ exports.apply_markdown = function (message) {
message.mentioned = true;
message.mentioned_me_directly = true;
}
let str = '';
let str = "";
if (silently) {
str += '<span class="user-mention silent" data-user-id="' + user_id + '">';
} else {
@@ -159,7 +159,7 @@ exports.apply_markdown = function (message) {
// If I mention "@aLiCe sMITH", I still want "Alice Smith" to
// show in the pill.
const actual_full_name = helpers.get_actual_name_from_user_id(user_id);
return str + _.escape(actual_full_name) + '</span>';
return str + _.escape(actual_full_name) + "</span>";
},
groupMentionHandler: function (name) {
const group = helpers.get_user_group_from_name(name);
@@ -168,8 +168,8 @@ exports.apply_markdown = function (message) {
message.mentioned = true;
}
return '<span class="user-group-mention" data-user-group-id="' + group.id + '">' +
'@' + _.escape(group.name) +
'</span>';
"@" + _.escape(group.name) +
"</span>";
}
return;
},
@@ -178,7 +178,7 @@ exports.apply_markdown = function (message) {
const user_mention_re = /<span.*user-mention.*data-user-id="(\d+|\*)"[^>]*>@/gm;
quote = quote.replace(user_mention_re, (match) => {
match = match.replace(/"user-mention"/g, '"user-mention silent"');
match = match.replace(/>@/g, '>');
match = match.replace(/>@/g, ">");
return match;
});
// In most cases, if you are being mentioned in the message you're quoting, you wouldn't
@@ -191,12 +191,12 @@ exports.apply_markdown = function (message) {
},
};
// Our python-markdown processor appends two \n\n to input
message.content = marked(message.raw_content + '\n\n', options).trim();
message.content = marked(message.raw_content + "\n\n", options).trim();
message.is_me_message = exports.is_status_message(message.raw_content);
};
exports.add_topic_links = function (message) {
if (message.type !== 'stream') {
if (message.type !== "stream") {
message.topic_links = [];
return;
}
@@ -233,14 +233,14 @@ exports.add_topic_links = function (message) {
};
exports.is_status_message = function (raw_content) {
return raw_content.startsWith('/me ');
return raw_content.startsWith("/me ");
};
function make_emoji_span(codepoint, title, alt_text) {
return '<span aria-label="' + title + '"' +
' class="emoji emoji-' + codepoint + '"' +
' role="img" title="' + title + '">' + alt_text +
'</span>';
"</span>";
}
function handleUnicodeEmoji(unicode_emoji) {
@@ -248,7 +248,7 @@ function handleUnicodeEmoji(unicode_emoji) {
const emoji_name = helpers.get_emoji_name(codepoint);
if (emoji_name) {
const alt_text = ':' + emoji_name + ':';
const alt_text = ":" + emoji_name + ":";
const title = emoji_name.split("_").join(" ");
return make_emoji_span(codepoint, title, alt_text);
}
@@ -257,7 +257,7 @@ function handleUnicodeEmoji(unicode_emoji) {
}
function handleEmoji(emoji_name) {
const alt_text = ':' + emoji_name + ':';
const alt_text = ":" + emoji_name + ":";
const title = emoji_name.split("_").join(" ");
// Zulip supports both standard/unicode emoji, served by a
@@ -309,7 +309,7 @@ function handleTimestamp(time) {
// Use html5 <time> tag for valid timestamps.
// render time without milliseconds.
const escaped_isotime = _.escape(timeobject.toISOString().split('.')[0] + 'Z');
const escaped_isotime = _.escape(timeobject.toISOString().split(".")[0] + "Z");
return `<time datetime="${escaped_isotime}">${escaped_time}</time>`;
}
@@ -321,7 +321,7 @@ function handleStream(stream_name) {
const href = helpers.stream_hash(stream.stream_id);
return '<a class="stream" data-stream-id="' + stream.stream_id + '" ' +
'href="/' + href + '"' +
'>' + '#' + _.escape(stream.name) + '</a>';
">" + "#" + _.escape(stream.name) + "</a>";
}
function handleStreamTopic(stream_name, topic) {
@@ -330,9 +330,9 @@ function handleStreamTopic(stream_name, topic) {
return;
}
const href = helpers.stream_topic_hash(stream.stream_id, topic);
const text = '#' + _.escape(stream.name) + ' > ' + _.escape(topic);
const text = "#" + _.escape(stream.name) + " > " + _.escape(topic);
return '<a class="stream-topic" data-stream-id="' + stream.stream_id + '" ' +
'href="/' + href + '"' + '>' + text + '</a>';
'href="/' + href + '"' + ">" + text + "</a>";
}
function handleRealmFilter(pattern, matches) {
@@ -353,8 +353,8 @@ function handleTex(tex, fullmatch) {
try {
return katex.renderToString(tex);
} catch (ex) {
if (ex.message.startsWith('KaTeX parse error')) { // TeX syntax error
return '<span class="tex-error">' + _.escape(fullmatch) + '</span>';
if (ex.message.startsWith("KaTeX parse error")) { // TeX syntax error
return '<span class="tex-error">' + _.escape(fullmatch) + "</span>";
}
blueslip.error(ex);
}
@@ -369,9 +369,9 @@ function python_to_js_filter(pattern, url) {
while (match) {
const name = match[1];
// Replace named group with regular matching group
pattern = pattern.replace('(?P<' + name + '>', '(');
pattern = pattern.replace("(?P<" + name + ">", "(");
// Replace named reference in url to numbered reference
url = url.replace('%(' + name + ')s', '\\' + current_group);
url = url.replace("%(" + name + ")s", "\\" + current_group);
// Reset the RegExp state
named_group_re.lastIndex = 0;
@@ -380,7 +380,7 @@ function python_to_js_filter(pattern, url) {
current_group += 1;
}
// Convert any python in-regex flags to RegExp flags
let js_flags = 'g';
let js_flags = "g";
const inline_flag_re = /\(\?([iLmsux]+)\)/;
match = inline_flag_re.exec(pattern);
@@ -413,7 +413,7 @@ function python_to_js_filter(pattern, url) {
// We have an error computing the generated regex syntax.
// We'll ignore this realm filter for now, but log this
// failure for debugging later.
blueslip.error('python_to_js_filter: ' + ex.message);
blueslip.error("python_to_js_filter: " + ex.message);
}
return [final_regex, url];
}
@@ -454,7 +454,7 @@ exports.initialize = function (realm_filters, helper_config) {
// No <code> around our code blocks instead a codehilite <div> and disable
// class-specific highlighting.
r.code = (code) => fenced_code.wrap_code(code) + '\n\n';
r.code = (code) => fenced_code.wrap_code(code) + "\n\n";
// Prohibit empty links for some reason.
const old_link = r.link;
@@ -462,7 +462,7 @@ exports.initialize = function (realm_filters, helper_config) {
// Put a newline after a <br> in the generated HTML to match markdown
r.br = function () {
return '<br>\n';
return "<br>\n";
};
function preprocess_code_blocks(src) {
@@ -481,7 +481,7 @@ exports.initialize = function (realm_filters, helper_config) {
// Disable lheadings
// We only keep the # Heading format.
disable_markdown_regex(marked.Lexer.rules.tables, 'lheading');
disable_markdown_regex(marked.Lexer.rules.tables, "lheading");
// Disable __strong__ (keeping **strong**)
marked.InlineLexer.rules.zulip.strong = /^\*\*([\s\S]+?)\*\*(?!\*)/;
@@ -495,7 +495,7 @@ exports.initialize = function (realm_filters, helper_config) {
marked.InlineLexer.rules.zulip.em = /^\*(?!\s+)((?:\*\*|[\s\S])+?)((?:[\S]))\*(?!\*)/;
// 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');
disable_markdown_regex(marked.InlineLexer.rules.zulip, "autolink");
exports.update_realm_filter_rules(realm_filters);