Skip to content

Commit a92f0a1

Browse files
Merge pull request #184 from adam187/fix/image-alt-unescape
Image alt should be unescaped
2 parents b78431f + cd32d55 commit a92f0a1

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/rules.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ rules.link_close = function (/* tokens, idx, options, env */) {
170170
rules.image = function (tokens, idx, options /*, env */) {
171171
var src = ' src="' + escapeHtml(tokens[idx].src) + '"';
172172
var title = tokens[idx].title ? (' title="' + escapeHtml(replaceEntities(tokens[idx].title)) + '"') : '';
173-
var alt = ' alt="' + (tokens[idx].alt ? escapeHtml(replaceEntities(tokens[idx].alt)) : '') + '"';
173+
var alt = ' alt="' + (tokens[idx].alt ? escapeHtml(replaceEntities(unescapeMd(tokens[idx].alt))) : '') + '"';
174174
var suffix = options.xhtmlOut ? ' /' : '';
175175
return '<img' + src + alt + title + suffix + '>';
176176
};

test/fixtures/remarkable/commonmark_extras.txt

+11
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,14 @@ Hello [google] [] where are you?
149149
<p>Hello <a href="https://google.com">google</a> where are you?</p>
150150
<p>Hello <a href="https://google.com">google</a> where are you?</p>
151151
.
152+
153+
154+
Image alt should be unescaped
155+
156+
.
157+
[Foo\\bar\]]: /url
158+
159+
![Foo\\bar\]]
160+
.
161+
<p><img src="/url" alt="Foo\bar]"></p>
162+
.

0 commit comments

Comments
 (0)