diff --git a/lib/helpers/parse_link_title.js b/lib/helpers/parse_link_title.js index 8ca82a3..0d66d23 100644 --- a/lib/helpers/parse_link_title.js +++ b/lib/helpers/parse_link_title.js @@ -3,7 +3,7 @@ 'use strict'; -var unescapeMd = require('../common/utils').unescapeMd; +var unescapeAll = require('../common/utils').unescapeAll; module.exports = function parseLinkTitle(str, pos, max) { @@ -34,7 +34,7 @@ module.exports = function parseLinkTitle(str, pos, max) { if (code === marker) { result.pos = pos + 1; result.lines = lines; - result.str = unescapeMd(str.slice(start + 1, pos)); + result.str = unescapeAll(str.slice(start + 1, pos)); result.ok = true; return result; } else if (code === 0x0A) { diff --git a/lib/renderer.js b/lib/renderer.js index 737e7dc..945c768 100644 --- a/lib/renderer.js +++ b/lib/renderer.js @@ -9,8 +9,7 @@ var assign = require('./common/utils').assign; -var unescapeMd = require('./common/utils').unescapeMd; -var replaceEntities = require('./common/utils').replaceEntities; +var unescapeAll = require('./common/utils').unescapeAll; var escapeHtml = require('./common/utils').escapeHtml; @@ -39,7 +38,7 @@ rules.fence = function (tokens, idx, options /*, env, self*/) { var highlighted; if (token.params) { - langName = escapeHtml(replaceEntities(unescapeMd(token.params.split(/\s+/g)[0]))); + langName = escapeHtml(unescapeAll(token.params.split(/\s+/g)[0])); langClass = ' class="' + langPrefix + langName + '"'; } @@ -101,7 +100,7 @@ rules.paragraph_close = function (tokens, idx /*, options, env */) { rules.link_open = function (tokens, idx /*, options, env */) { - var title = tokens[idx].title ? (' title="' + escapeHtml(replaceEntities(tokens[idx].title)) + '"') : ''; + var title = tokens[idx].title ? (' title="' + escapeHtml(tokens[idx].title) + '"') : ''; var target = tokens[idx].target ? (' target="' + escapeHtml(tokens[idx].target) + '"') : ''; return ''; }; @@ -112,7 +111,7 @@ rules.link_close = function (/* tokens, idx, options, env */) { rules.image = function (tokens, idx, options, env, self) { var src = ' src="' + escapeHtml(tokens[idx].src) + '"'; - var title = tokens[idx].title ? (' title="' + escapeHtml(replaceEntities(tokens[idx].title)) + '"') : ''; + var title = tokens[idx].title ? (' title="' + escapeHtml(tokens[idx].title) + '"') : ''; var alt = ' alt="' + self.renderInlineAsText(tokens[idx].tokens, options, env) + '"'; var suffix = options.xhtmlOut ? ' /' : ''; return ''; diff --git a/test/fixtures/markdown-it/commonmark_extras.txt b/test/fixtures/markdown-it/commonmark_extras.txt index 04d0a63..a205343 100644 --- a/test/fixtures/markdown-it/commonmark_extras.txt +++ b/test/fixtures/markdown-it/commonmark_extras.txt @@ -88,15 +88,27 @@ Autolinks do not allow escaping: Escaping entities in links: . -[](<">) +[](<"> "&ö") -[](<\">) +[](<\"> "\&\ö") -[](<\\">) +[](<\\"> "\\"\\ö") . -

-

-

+

+

+

+. + + +Checking combination of replaceEntities and unescapeMd: + +. +~~~ &\&\\& +just a funny little fence +~~~ +. +
just a funny little fence
+
.