diff --git a/frontend_tests/node_tests/markdown.js b/frontend_tests/node_tests/markdown.js
index 4c8e6583f1..1ab8b658a9 100644
--- a/frontend_tests/node_tests/markdown.js
+++ b/frontend_tests/node_tests/markdown.js
@@ -819,6 +819,10 @@ test("translate_emoticons_to_names", () => {
}
});
+test("parse_non_message", () => {
+ assert.equal(markdown.parse_non_message("type `/day`"), "
type /day
");
+});
+
test("missing unicode emojis", ({override_rewire}) => {
const message = {raw_content: "\u{1F6B2}"};
diff --git a/static/js/markdown.js b/static/js/markdown.js
index 45171cb7d3..ab78576a50 100644
--- a/static/js/markdown.js
+++ b/static/js/markdown.js
@@ -564,3 +564,9 @@ export function apply_markdown(message) {
message.flags = flags;
message.is_me_message = is_status_message(raw_content);
}
+
+export function parse_non_message(raw_content) {
+ // Occasionally we get markdown from the server that is not technically
+ // a message, but we want to convert it to HTML.
+ return marked(raw_content).trim();
+}
diff --git a/static/js/zcommand.js b/static/js/zcommand.js
index c5e4ec931c..70e13d565d 100644
--- a/static/js/zcommand.js
+++ b/static/js/zcommand.js
@@ -1,12 +1,11 @@
import $ from "jquery";
-import marked from "../third/marked/lib/marked";
-
import * as channel from "./channel";
import * as common from "./common";
import * as dark_theme from "./dark_theme";
import * as feedback_widget from "./feedback_widget";
import {$t} from "./i18n";
+import * as markdown from "./markdown";
import * as scroll_bar from "./scroll_bar";
/*
@@ -66,7 +65,7 @@ export function switch_to_light_theme() {
dark_theme.disable();
feedback_widget.show({
populate($container) {
- const rendered_msg = marked(data.msg).trim();
+ const rendered_msg = markdown.parse_non_message(data.msg);
$container.html(rendered_msg);
},
on_undo() {
@@ -88,7 +87,7 @@ export function switch_to_dark_theme() {
dark_theme.enable();
feedback_widget.show({
populate($container) {
- const rendered_msg = marked(data.msg).trim();
+ const rendered_msg = markdown.parse_non_message(data.msg);
$container.html(rendered_msg);
},
on_undo() {
@@ -110,7 +109,7 @@ export function enter_fluid_mode() {
scroll_bar.set_layout_width();
feedback_widget.show({
populate($container) {
- const rendered_msg = marked(data.msg).trim();
+ const rendered_msg = markdown.parse_non_message(data.msg);
$container.html(rendered_msg);
},
on_undo() {
@@ -132,7 +131,7 @@ export function enter_fixed_mode() {
scroll_bar.set_layout_width();
feedback_widget.show({
populate($container) {
- const rendered_msg = marked(data.msg).trim();
+ const rendered_msg = markdown.parse_non_message(data.msg);
$container.html(rendered_msg);
},
on_undo() {