Fix code block highlighting html not escaped when no languages specified
This commit is contained in:
parent
5e72a69d18
commit
fe912f73ec
1 changed files with 5 additions and 2 deletions
|
@ -449,13 +449,16 @@ function finishView(view) {
|
||||||
var langDiv = $(value).find('code.hljs');
|
var langDiv = $(value).find('code.hljs');
|
||||||
if (langDiv.length > 0) {
|
if (langDiv.length > 0) {
|
||||||
var reallang = langDiv[0].className.replace(/hljs|wrap/g, '').trim();
|
var reallang = langDiv[0].className.replace(/hljs|wrap/g, '').trim();
|
||||||
if (!reallang) return;
|
|
||||||
var codeDiv = $(value).find('.code');
|
var codeDiv = $(value).find('.code');
|
||||||
var code = "";
|
var code = "";
|
||||||
if (codeDiv.length > 0) code = codeDiv.html();
|
if (codeDiv.length > 0) code = codeDiv.html();
|
||||||
else code = langDiv.html();
|
else code = langDiv.html();
|
||||||
code = md.utils.unescapeAll(code);
|
code = md.utils.unescapeAll(code);
|
||||||
if (reallang == "tiddlywiki" || reallang == "mediawiki") {
|
if (!reallang) {
|
||||||
|
var result = {
|
||||||
|
value: md.utils.escapeHtml(code)
|
||||||
|
};
|
||||||
|
} else if (reallang == "tiddlywiki" || reallang == "mediawiki") {
|
||||||
var result = {
|
var result = {
|
||||||
value: Prism.highlight(code, Prism.languages.wiki)
|
value: Prism.highlight(code, Prism.languages.wiki)
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue