Skip to content

Commit 980e702

Browse files
committed
fix(images): fix js error when using image references
In some circumstances, on a reference style image, the last capturing group is ignored, which causes the fucntion argument to return the number of matches instead of a string (or undefined). Checking if the title parameter is a string ensures that the title parameter is actually something that was caught by the regex and not some metadata. Closes #585
1 parent a48e0cf commit 980e702

File tree

7 files changed

+9
-5
lines changed

7 files changed

+9
-5
lines changed

dist/showdown.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/showdown.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/showdown.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/showdown.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/subParsers/images.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ showdown.subParser('images', function (text, options, globals) {
6161
url = url.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
6262
var result = '<img src="' + url + '" alt="' + altText + '"';
6363

64-
if (title) {
64+
if (title && showdown.helper.isString(title)) {
6565
title = title
6666
.replace(/"/g, '&quot;')
6767
//title = showdown.helper.escapeCharacters(title, '*_', false);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>[<img src="http://example.com/foo.png" alt="the-image" />]</p>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[![the-image]]
2+
3+
[the-image]: http://example.com/foo.png

0 commit comments

Comments
 (0)