Skip to content

Commit b12e3a1

Browse files
authored
Merge pull request #1075 from junaidrsd/fix-markdown-escape-hljs
escape hljs attributed div and markdown-it version update
2 parents fc2c7ad + c74027e commit b12e3a1

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

lib/modules/markdown.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,20 @@ module.exports = {
5454
$('pre > code').each(function() {
5555
var code = $(this);
5656
var lang = '';
57-
// Capture any "language-" className values
58-
if (code.attr('class')) {
59-
lang = code.attr('class').split(/\s+/).reduce(function(pv, cv) {
60-
return pv + (cv.startsWith('language-') ? cv.substr(9 - cv.length) + ' ' : '');
61-
}, '').trim();
62-
}
63-
// Replace parent PRE element with hljs attributed DIV
64-
code.parent().replaceWith(
57+
if(code.attr('class') !== 'lang-escape-hljs') {
58+
// Capture any "language-" className values
59+
if (code.attr('class')) {
60+
lang = code.attr('class').split(/\s+/).reduce(function(pv, cv) {
61+
return pv + (cv.startsWith('language-') ? cv.substr(9 - cv.length) + ' ' : '');
62+
}, '').trim();
63+
}
64+
//Replace parent PRE element with hljs attributed DIV
65+
code.parent().replaceWith(
6566
'<div hljs' + (lang.length ? ' hljs-language="' + lang + '"' : '') + '>' +
6667
code.html() +
6768
'</div>'
68-
);
69+
);
70+
}
6971
});
7072
$('p, a, li, pre, h1, h2, h3, h4, h5, h6, table, thead, tbody, tr, th, td').not('[sg-no-style]').addClass('sg');
7173
excludeLinks.forEach(function(link) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"gulp-util": "~3.0.5",
5252
"kss": "~2.1.0",
5353
"lodash": "~3.10.1",
54-
"markdown-it": "^5.1.0",
54+
"markdown-it": "^8.3.1",
5555
"minimatch": "~3.0.0",
5656
"minimist": "^1.2.0",
5757
"morgan": "~1.6.0",

0 commit comments

Comments
 (0)