|
|
@ -90,6 +90,31 @@ function mdInit() { |
|
|
|
return window.twemoji.parse(token[idx].content); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
mdHtml.renderer.rules.fence = function (tokens, idx, options, env, slf) { |
|
|
|
var escapeHtml = mdHtml.utils.escapeHtml, |
|
|
|
unescapeAll = mdHtml.utils.unescapeAll, |
|
|
|
token = tokens[idx], |
|
|
|
info = token.info ? unescapeAll(token.info).trim() : '', |
|
|
|
langName = '', |
|
|
|
highlighted; |
|
|
|
|
|
|
|
if (info) { |
|
|
|
langName = info.split(/\s+/g)[0]; |
|
|
|
token.attrPush([ 'class', options.langPrefix + langName ]); |
|
|
|
} |
|
|
|
|
|
|
|
if (options.highlight) { |
|
|
|
highlighted = options.highlight(token.content, langName) || escapeHtml(token.content); |
|
|
|
} else { |
|
|
|
highlighted = escapeHtml(token.content); |
|
|
|
} |
|
|
|
|
|
|
|
return '<pre class="hljs"><code' + slf.renderAttrs(token) + '>' |
|
|
|
+ highlighted |
|
|
|
+ '</code></pre>\n'; |
|
|
|
}; |
|
|
|
|
|
|
|
//
|
|
|
|
// Inject line numbers for sync scroll. Notes:
|
|
|
|
//
|
|
|
|