|
@ -3,6 +3,8 @@ |
|
|
|
|
|
|
|
|
var assign = require('object-assign'); |
|
|
var assign = require('object-assign'); |
|
|
var escapeHtml = require('./helpers').escapeHtml; |
|
|
var escapeHtml = require('./helpers').escapeHtml; |
|
|
|
|
|
var escapeHtmlKeepEntities = require('./helpers').escapeHtmlKeepEntities; |
|
|
|
|
|
var unescapeMd = require('./helpers').unescapeMd; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check if we need to hide '\n' before next token
|
|
|
// check if we need to hide '\n' before next token
|
|
@ -40,9 +42,11 @@ rules.fence = function (tokens, idx, options) { |
|
|
var token = tokens[idx]; |
|
|
var token = tokens[idx]; |
|
|
var langMark = ''; |
|
|
var langMark = ''; |
|
|
var langPrefix = options.codeLangPrefix || ''; |
|
|
var langPrefix = options.codeLangPrefix || ''; |
|
|
|
|
|
var params; |
|
|
|
|
|
|
|
|
if (token.params.length) { |
|
|
if (token.params) { |
|
|
langMark = ' class="' + langPrefix + escapeHtml(token.params[0]) + '"'; |
|
|
params = token.params.split(/ +/g); |
|
|
|
|
|
langMark = ' class="' + langPrefix + escapeHtmlKeepEntities(unescapeMd(params[0])) + '"'; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return '<pre><code' + langMark + '>' |
|
|
return '<pre><code' + langMark + '>' |
|
@ -96,7 +100,7 @@ rules.paragraph_close = function (tokens, idx /*, options*/) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rules.link_open = function (tokens, idx /*, options*/) { |
|
|
rules.link_open = function (tokens, idx /*, options*/) { |
|
|
return '<a href="' + tokens[idx].href + '">'; |
|
|
return '<a href="' + escapeHtmlKeepEntities(tokens[idx].href) + '">'; |
|
|
}; |
|
|
}; |
|
|
rules.link_close = function (/*tokens, idx, options*/) { |
|
|
rules.link_close = function (/*tokens, idx, options*/) { |
|
|
return '</a>'; |
|
|
return '</a>'; |
|
|