don't syntax highlight languages that begin with "_"
parent
f8f9c4880a
commit
2ce493307e
|
@ -184,7 +184,7 @@ const transformTags: sanitizeHtml.IOptions["transformTags"] = { // custom to mat
|
||||||
if (typeof attribs.class !== 'undefined') {
|
if (typeof attribs.class !== 'undefined') {
|
||||||
// Filter out all classes other than ones starting with language- for syntax highlighting.
|
// Filter out all classes other than ones starting with language- for syntax highlighting.
|
||||||
const classes = attribs.class.split(/\s/).filter(function(cl) {
|
const classes = attribs.class.split(/\s/).filter(function(cl) {
|
||||||
return cl.startsWith('language-');
|
return cl.startsWith('language-') && !cl.startsWith('language-_');
|
||||||
});
|
});
|
||||||
attribs.class = classes.join(' ');
|
attribs.class = classes.join(' ');
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ export default createReactClass({
|
||||||
} else {
|
} else {
|
||||||
// Only syntax highlight if there's a class starting with language-
|
// Only syntax highlight if there's a class starting with language-
|
||||||
const classes = blocks[i].className.split(/\s+/).filter(function(cl) {
|
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) {
|
if (classes.length != 0) {
|
||||||
|
|
|
@ -64,7 +64,7 @@ function parseCodeBlock(n: HTMLElement, partCreator: PartCreator) {
|
||||||
let language = "";
|
let language = "";
|
||||||
if (n.firstChild && n.firstChild.nodeName === "CODE") {
|
if (n.firstChild && n.firstChild.nodeName === "CODE") {
|
||||||
for (const className of (<HTMLElement>n.firstChild).classList) {
|
for (const className of (<HTMLElement>n.firstChild).classList) {
|
||||||
if (className.startsWith("language-")) {
|
if (className.startsWith("language-") && !className.startsWith("language-_")) {
|
||||||
language = className.substr("language-".length);
|
language = className.substr("language-".length);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue