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

@@ -30,22 +30,22 @@ exports.wrap_code = function (code) {
// Trim trailing \n until there's just one left
// This mirrors how pygments handles code input
return '<div class="codehilite"><pre><span></span><code>' +
_.escape(code.replace(/^\n+|\n+$/g, '')) +
'\n</code></pre></div>\n';
_.escape(code.replace(/^\n+|\n+$/g, "")) +
"\n</code></pre></div>\n";
};
function wrap_quote(text) {
const paragraphs = text.split('\n\n');
const paragraphs = text.split("\n\n");
const quoted_paragraphs = [];
// Prefix each quoted paragraph with > at the
// beginning of each line
for (const paragraph of paragraphs) {
const lines = paragraph.split('\n');
quoted_paragraphs.push(lines.filter((line) => line !== '').map((line) => '> ' + line).join('\n'));
const lines = paragraph.split("\n");
quoted_paragraphs.push(lines.filter((line) => line !== "").map((line) => "> " + line).join("\n"));
}
return quoted_paragraphs.join('\n\n');
return quoted_paragraphs.join("\n\n");
}
function wrap_tex(tex) {
@@ -54,7 +54,7 @@ function wrap_tex(tex) {
displayMode: true,
});
} catch (ex) {
return '<span class="tex-error">' + _.escape(tex) + '</span>';
return '<span class="tex-error">' + _.escape(tex) + "</span>";
}
}
@@ -62,7 +62,7 @@ function wrap_spoiler(header, text, stash_func) {
const output = [];
const header_div_open_html = '<div class="spoiler-block"><div class="spoiler-header">';
const end_header_start_content_html = '</div><div class="spoiler-content" aria-hidden="true">';
const footer_html = '</div></div>';
const footer_html = "</div></div>";
output.push(stash_func(header_div_open_html));
output.push(header);
@@ -77,7 +77,7 @@ exports.set_stash_func = function (stash_handler) {
};
exports.process_fenced_code = function (content) {
const input = content.split('\n');
const input = content.split("\n");
const output = [];
const handler_stack = [];
let consume_line;
@@ -87,7 +87,7 @@ exports.process_fenced_code = function (content) {
// don't do syntax highlighting yet
return (function () {
const lines = [];
if (lang === 'quote') {
if (lang === "quote") {
return {
handle_line: function (line) {
if (line === fence) {
@@ -98,16 +98,16 @@ exports.process_fenced_code = function (content) {
},
done: function () {
const text = wrap_quote(lines.join('\n'));
output_lines.push('');
const text = wrap_quote(lines.join("\n"));
output_lines.push("");
output_lines.push(text);
output_lines.push('');
output_lines.push("");
handler_stack.pop();
},
};
}
if (lang === 'math') {
if (lang === "math") {
return {
handle_line: function (line) {
if (line === fence) {
@@ -118,17 +118,17 @@ exports.process_fenced_code = function (content) {
},
done: function () {
const text = wrap_tex(lines.join('\n'));
const text = wrap_tex(lines.join("\n"));
const placeholder = stash_func(text, true);
output_lines.push('');
output_lines.push("");
output_lines.push(placeholder);
output_lines.push('');
output_lines.push("");
handler_stack.pop();
},
};
}
if (lang === 'spoiler') {
if (lang === "spoiler") {
return {
handle_line: function (line) {
if (line === fence) {
@@ -139,10 +139,10 @@ exports.process_fenced_code = function (content) {
},
done: function () {
const text = wrap_spoiler(header, lines.join('\n'), stash_func);
output_lines.push('');
const text = wrap_spoiler(header, lines.join("\n"), stash_func);
output_lines.push("");
output_lines.push(text);
output_lines.push('');
output_lines.push("");
handler_stack.pop();
},
};
@@ -158,12 +158,12 @@ exports.process_fenced_code = function (content) {
},
done: function () {
const text = exports.wrap_code(lines.join('\n'));
const text = exports.wrap_code(lines.join("\n"));
// insert safe HTML that is passed through the parsing
const placeholder = stash_func(text, true);
output_lines.push('');
output_lines.push("");
output_lines.push(placeholder);
output_lines.push('');
output_lines.push("");
handler_stack.pop();
},
};
@@ -209,11 +209,11 @@ exports.process_fenced_code = function (content) {
handler.done();
}
if (output.length > 2 && output[output.length - 2] !== '') {
output.push('');
if (output.length > 2 && output[output.length - 2] !== "") {
output.push("");
}
return output.join('\n');
return output.join("\n");
};
const fence_length_re = /^ {0,3}(`{3,})/gm;
@@ -225,7 +225,7 @@ exports.get_unused_fence = (content) => {
while ((match = fence_length_re.exec(content)) !== null) {
length = Math.max(length, match[1].length + 1);
}
return '`'.repeat(length);
return "`".repeat(length);
};
window.fenced_code = exports;