diff --git a/src/HtmlUtils.tsx b/src/HtmlUtils.tsx
index 6dba041685..77a9579f2c 100644
--- a/src/HtmlUtils.tsx
+++ b/src/HtmlUtils.tsx
@@ -184,7 +184,7 @@ const transformTags: sanitizeHtml.IOptions["transformTags"] = { // custom to mat
if (typeof attribs.class !== 'undefined') {
// Filter out all classes other than ones starting with language- for syntax highlighting.
const classes = attribs.class.split(/\s/).filter(function(cl) {
- return cl.startsWith('language-');
+ return cl.startsWith('language-') && !cl.startsWith('language-_');
});
attribs.class = classes.join(' ');
}
diff --git a/src/components/views/messages/TextualBody.js b/src/components/views/messages/TextualBody.js
index 5784e36a8b..a6a5726281 100644
--- a/src/components/views/messages/TextualBody.js
+++ b/src/components/views/messages/TextualBody.js
@@ -107,7 +107,7 @@ export default createReactClass({
} else {
// Only syntax highlight if there's a class starting with language-
const classes = blocks[i].className.split(/\s+/).filter(function(cl) {
- return cl.startsWith('language-');
+ return cl.startsWith('language-') && !cl.startsWith('language-_');
});
if (classes.length != 0) {
diff --git a/src/editor/deserialize.ts b/src/editor/deserialize.ts
index 48d1d98ae4..d3b83bc08a 100644
--- a/src/editor/deserialize.ts
+++ b/src/editor/deserialize.ts
@@ -64,7 +64,7 @@ function parseCodeBlock(n: HTMLElement, partCreator: PartCreator) {
let language = "";
if (n.firstChild && n.firstChild.nodeName === "CODE") {
for (const className of (n.firstChild).classList) {
- if (className.startsWith("language-")) {
+ if (className.startsWith("language-") && !className.startsWith("language-_")) {
language = className.substr("language-".length);
break;
}