markdown: Avoid blueslip dependency.

If katex throws an error that we can't deal with,
we just re-throw it now.
This commit is contained in:
Steve Howell
2022-04-05 15:22:53 +00:00
parent 83e3deab44
commit c7ed21f891
2 changed files with 5 additions and 7 deletions

View File

@@ -6,7 +6,6 @@ const markdown_test_cases = require("../../zerver/tests/fixtures/markdown_test_c
const markdown_assert = require("../zjsunit/markdown_assert");
const {set_global, with_field_rewire, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
const blueslip = require("../zjsunit/zblueslip");
const {page_params, user_settings} = require("../zjsunit/zpage_params");
const example_realm_linkifiers = [
@@ -850,7 +849,6 @@ test("missing unicode emojis", ({override_rewire}) => {
});
test("katex_throws_unexpected_exceptions", () => {
blueslip.expect("error", "Error: some-exception");
const message = {raw_content: "$$a$$"};
with_field_rewire(
markdown,
@@ -861,7 +859,10 @@ test("katex_throws_unexpected_exceptions", () => {
},
},
() => {
markdown.apply_markdown(message);
assert.throws(() => markdown.apply_markdown(message), {
name: "Error",
message: "some-exception\nPlease report this to https://github.com/chjj/marked.",
});
},
);
});

View File

@@ -5,8 +5,6 @@ import _ from "lodash";
import * as fenced_code from "../shared/js/fenced_code";
import marked from "../third/marked/lib/marked";
import * as blueslip from "./blueslip";
// This contains zulip's frontend Markdown implementation; see
// docs/subsystems/markdown.md for docs on our Markdown syntax. The other
// main piece in rendering Markdown client-side is
@@ -439,8 +437,7 @@ function handleTex(tex, fullmatch) {
// TeX syntax error
return `<span class="tex-error">${_.escape(fullmatch)}</span>`;
}
blueslip.error(error);
return undefined;
throw new Error(error.message);
}
}