Fix code block highlighting html not escaped when no languages specified

This commit is contained in:
Wu Cheng-Han 2016-10-17 17:54:58 +08:00
parent 5e72a69d18
commit fe912f73ec
1 changed files with 5 additions and 2 deletions

View File

@ -449,13 +449,16 @@ function finishView(view) {
var langDiv = $(value).find('code.hljs');
if (langDiv.length > 0) {
var reallang = langDiv[0].className.replace(/hljs|wrap/g, '').trim();
if (!reallang) return;
var codeDiv = $(value).find('.code');
var code = "";
if (codeDiv.length > 0) code = codeDiv.html();
else code = langDiv.html();
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 = {
value: Prism.highlight(code, Prism.languages.wiki)
};