|
|
@ -9,7 +9,6 @@ |
|
|
|
|
|
|
|
|
|
|
|
var assign = require('./common/utils').assign; |
|
|
|
var has = require('./common/utils').has; |
|
|
|
var unescapeMd = require('./common/utils').unescapeMd; |
|
|
|
var replaceEntities = require('./common/utils').replaceEntities; |
|
|
|
var escapeHtml = require('./common/utils').escapeHtml; |
|
|
@ -38,29 +37,15 @@ rules.code = function (tokens, idx /*, options, env */) { |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
rules.fence = function (tokens, idx, options, env, self) { |
|
|
|
rules.fence = function (tokens, idx, options /*, env, self*/) { |
|
|
|
var token = tokens[idx]; |
|
|
|
var langClass = ''; |
|
|
|
var langPrefix = options.langPrefix; |
|
|
|
var langName = '', fenceName; |
|
|
|
var langName = ''; |
|
|
|
var highlighted; |
|
|
|
|
|
|
|
if (token.params) { |
|
|
|
|
|
|
|
//
|
|
|
|
// ```foo bar
|
|
|
|
//
|
|
|
|
// Try custom renderer "foo" first. That will simplify overwrite
|
|
|
|
// for diagrams, latex, and any other fenced block with custom look
|
|
|
|
//
|
|
|
|
|
|
|
|
fenceName = token.params.split(/\s+/g)[0]; |
|
|
|
|
|
|
|
if (has(self.rules.fence_custom, fenceName)) { |
|
|
|
return self.rules.fence_custom[fenceName](tokens, idx, options, env, self); |
|
|
|
} |
|
|
|
|
|
|
|
langName = escapeHtml(replaceEntities(unescapeMd(fenceName))); |
|
|
|
langName = escapeHtml(replaceEntities(unescapeMd(token.params.split(/\s+/g)[0]))); |
|
|
|
langClass = ' class="' + langPrefix + langName + '"'; |
|
|
|
} |
|
|
|
|
|
|
@ -76,7 +61,6 @@ rules.fence = function (tokens, idx, options, env, self) { |
|
|
|
+ '</code></pre>\n'; |
|
|
|
}; |
|
|
|
|
|
|
|
rules.fence_custom = {}; |
|
|
|
|
|
|
|
rules.heading_open = function (tokens, idx /*, options, env */) { |
|
|
|
return '<h' + tokens[idx].hLevel + '>'; |
|
|
|