Fix code block which in deeper level will not be parsed issue
This commit is contained in:
parent
e097622098
commit
e311a1f620
2 changed files with 7 additions and 5 deletions
|
@ -434,12 +434,12 @@ function finishView(view) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
//syntax highlighting
|
//syntax highlighting
|
||||||
view.find("pre.raw").removeClass("raw")
|
view.find("pre > code.raw").removeClass("raw")
|
||||||
.each(function (key, value) {
|
.each(function (key, value) {
|
||||||
var langDiv = $(value).find('code.hljs');
|
var langDiv = $(value);
|
||||||
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();
|
||||||
var codeDiv = $(value).find('.code');
|
var codeDiv = langDiv.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();
|
||||||
|
@ -894,6 +894,7 @@ md.renderer.rules.fence = function (tokens, idx, options, env, self) {
|
||||||
if (/\!$/.test(info)) token.attrJoin('class', 'wrap');
|
if (/\!$/.test(info)) token.attrJoin('class', 'wrap');
|
||||||
token.attrJoin('class', options.langPrefix + langName.replace(/\=$|\=\d+$|\=\+$|\!$|\=\!$/, ''));
|
token.attrJoin('class', options.langPrefix + langName.replace(/\=$|\=\d+$|\=\+$|\!$|\=\!$/, ''));
|
||||||
token.attrJoin('class', 'hljs');
|
token.attrJoin('class', 'hljs');
|
||||||
|
token.attrJoin('class', 'raw');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.highlight) {
|
if (options.highlight) {
|
||||||
|
@ -906,7 +907,7 @@ md.renderer.rules.fence = function (tokens, idx, options, env, self) {
|
||||||
return highlighted + '\n';
|
return highlighted + '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<pre class="raw"><code' + self.renderAttrs(token) + '>'
|
return '<pre><code' + self.renderAttrs(token) + '>'
|
||||||
+ highlighted
|
+ highlighted
|
||||||
+ '</code></pre>\n';
|
+ '</code></pre>\n';
|
||||||
};
|
};
|
||||||
|
|
|
@ -64,6 +64,7 @@ md.renderer.rules.fence = function (tokens, idx, options, env, self) {
|
||||||
if (/\!$/.test(info)) token.attrJoin('class', 'wrap');
|
if (/\!$/.test(info)) token.attrJoin('class', 'wrap');
|
||||||
token.attrJoin('class', options.langPrefix + langName.replace(/\=$|\=\d+$|\=\+$|\!$|\=\!/, ''));
|
token.attrJoin('class', options.langPrefix + langName.replace(/\=$|\=\d+$|\=\+$|\!$|\=\!/, ''));
|
||||||
token.attrJoin('class', 'hljs');
|
token.attrJoin('class', 'hljs');
|
||||||
|
token.attrJoin('class', 'raw');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.highlight) {
|
if (options.highlight) {
|
||||||
|
@ -79,7 +80,7 @@ md.renderer.rules.fence = function (tokens, idx, options, env, self) {
|
||||||
if (tokens[idx].map && tokens[idx].level === 0) {
|
if (tokens[idx].map && tokens[idx].level === 0) {
|
||||||
var startline = tokens[idx].map[0] + 1;
|
var startline = tokens[idx].map[0] + 1;
|
||||||
var endline = tokens[idx].map[1];
|
var endline = tokens[idx].map[1];
|
||||||
return '<pre class="part raw" data-startline="' + startline + '" data-endline="' + endline + '"><code' + self.renderAttrs(token) + '>'
|
return '<pre class="part" data-startline="' + startline + '" data-endline="' + endline + '"><code' + self.renderAttrs(token) + '>'
|
||||||
+ highlighted
|
+ highlighted
|
||||||
+ '</code></pre>\n';
|
+ '</code></pre>\n';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue