From e311a1f6202d02e0bb869d8141b67ee04fec8ab4 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Tue, 18 Oct 2016 00:14:50 +0800 Subject: Fix code block which in deeper level will not be parsed issue --- public/js/extra.js | 9 +++++---- public/js/syncscroll.js | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'public') diff --git a/public/js/extra.js b/public/js/extra.js index ad1e19b5..61e010c6 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -434,12 +434,12 @@ function finishView(view) { }); }); //syntax highlighting - view.find("pre.raw").removeClass("raw") + view.find("pre > code.raw").removeClass("raw") .each(function (key, value) { - var langDiv = $(value).find('code.hljs'); + var langDiv = $(value); if (langDiv.length > 0) { var reallang = langDiv[0].className.replace(/hljs|wrap/g, '').trim(); - var codeDiv = $(value).find('.code'); + var codeDiv = langDiv.find('.code'); var code = ""; if (codeDiv.length > 0) code = codeDiv.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'); token.attrJoin('class', options.langPrefix + langName.replace(/\=$|\=\d+$|\=\+$|\!$|\=\!$/, '')); token.attrJoin('class', 'hljs'); + token.attrJoin('class', 'raw'); } if (options.highlight) { @@ -906,7 +907,7 @@ md.renderer.rules.fence = function (tokens, idx, options, env, self) { return highlighted + '\n'; } - return '
'
+    return  '
'
         + highlighted
         + '
\n'; }; diff --git a/public/js/syncscroll.js b/public/js/syncscroll.js index c2de2d0d..b2fee76c 100644 --- a/public/js/syncscroll.js +++ b/public/js/syncscroll.js @@ -64,6 +64,7 @@ md.renderer.rules.fence = function (tokens, idx, options, env, self) { if (/\!$/.test(info)) token.attrJoin('class', 'wrap'); token.attrJoin('class', options.langPrefix + langName.replace(/\=$|\=\d+$|\=\+$|\!$|\=\!/, '')); token.attrJoin('class', 'hljs'); + token.attrJoin('class', 'raw'); } 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) { var startline = tokens[idx].map[0] + 1; var endline = tokens[idx].map[1]; - return '
'
+        return '
'
         + highlighted
         + '
\n'; } -- cgit v1.2.3