mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
js: Remove some pointless IIFEs.
Some of these were there because they predate block-scoped const/let. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
707d23d1e8
commit
fc9481a24e
@@ -106,81 +106,79 @@ export function process_fenced_code(content) {
|
||||
function handler_for_fence(output_lines, fence, lang, header) {
|
||||
// lang is ignored except for 'quote', as we
|
||||
// don't do syntax highlighting yet
|
||||
return (function () {
|
||||
const lines = [];
|
||||
if (lang === "quote") {
|
||||
return {
|
||||
handle_line(line) {
|
||||
if (line === fence) {
|
||||
this.done();
|
||||
} else {
|
||||
consume_line(lines, line);
|
||||
}
|
||||
},
|
||||
|
||||
done() {
|
||||
const text = wrap_quote(lines.join("\n"));
|
||||
output_lines.push("", text, "");
|
||||
handler_stack.pop();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (lang === "math") {
|
||||
return {
|
||||
handle_line(line) {
|
||||
if (line === fence) {
|
||||
this.done();
|
||||
} else {
|
||||
lines.push(line);
|
||||
}
|
||||
},
|
||||
|
||||
done() {
|
||||
const text = wrap_tex(lines.join("\n"));
|
||||
const placeholder = stash_func(text, true);
|
||||
output_lines.push("", placeholder, "");
|
||||
handler_stack.pop();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (lang === "spoiler") {
|
||||
return {
|
||||
handle_line(line) {
|
||||
if (line === fence) {
|
||||
this.done();
|
||||
} else {
|
||||
lines.push(line);
|
||||
}
|
||||
},
|
||||
|
||||
done() {
|
||||
const text = wrap_spoiler(header, lines.join("\n"), stash_func);
|
||||
output_lines.push("", text, "");
|
||||
handler_stack.pop();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const lines = [];
|
||||
if (lang === "quote") {
|
||||
return {
|
||||
handle_line(line) {
|
||||
if (line === fence) {
|
||||
this.done();
|
||||
} else {
|
||||
lines.push(line.trimEnd());
|
||||
consume_line(lines, line);
|
||||
}
|
||||
},
|
||||
|
||||
done() {
|
||||
const text = wrap_code(lines.join("\n"), lang);
|
||||
// insert safe HTML that is passed through the parsing
|
||||
const text = wrap_quote(lines.join("\n"));
|
||||
output_lines.push("", text, "");
|
||||
handler_stack.pop();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (lang === "math") {
|
||||
return {
|
||||
handle_line(line) {
|
||||
if (line === fence) {
|
||||
this.done();
|
||||
} else {
|
||||
lines.push(line);
|
||||
}
|
||||
},
|
||||
|
||||
done() {
|
||||
const text = wrap_tex(lines.join("\n"));
|
||||
const placeholder = stash_func(text, true);
|
||||
output_lines.push("", placeholder, "");
|
||||
handler_stack.pop();
|
||||
},
|
||||
};
|
||||
})();
|
||||
}
|
||||
|
||||
if (lang === "spoiler") {
|
||||
return {
|
||||
handle_line(line) {
|
||||
if (line === fence) {
|
||||
this.done();
|
||||
} else {
|
||||
lines.push(line);
|
||||
}
|
||||
},
|
||||
|
||||
done() {
|
||||
const text = wrap_spoiler(header, lines.join("\n"), stash_func);
|
||||
output_lines.push("", text, "");
|
||||
handler_stack.pop();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
handle_line(line) {
|
||||
if (line === fence) {
|
||||
this.done();
|
||||
} else {
|
||||
lines.push(line.trimEnd());
|
||||
}
|
||||
},
|
||||
|
||||
done() {
|
||||
const text = wrap_code(lines.join("\n"), lang);
|
||||
// insert safe HTML that is passed through the parsing
|
||||
const placeholder = stash_func(text, true);
|
||||
output_lines.push("", placeholder, "");
|
||||
handler_stack.pop();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function default_hander() {
|
||||
|
||||
Reference in New Issue
Block a user