mirror of https://github.com/showdownjs/showdown
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 #585pull/583/merge
parent
63763b136f
commit
b0d475fc08
|
@ -3331,7 +3331,7 @@ showdown.subParser('makehtml.images', function (text, options, globals) {
|
|||
url = url.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
|
||||
var result = '<img src="' + url + '" alt="' + altText + '"';
|
||||
|
||||
if (title) {
|
||||
if (title && showdown.helper.isString(title)) {
|
||||
title = title
|
||||
.replace(/"/g, '"')
|
||||
//title = showdown.helper.escapeCharacters(title, '*_', false);
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -61,7 +61,7 @@ showdown.subParser('makehtml.images', function (text, options, globals) {
|
|||
url = url.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
|
||||
var result = '<img src="' + url + '" alt="' + altText + '"';
|
||||
|
||||
if (title) {
|
||||
if (title && showdown.helper.isString(title)) {
|
||||
title = title
|
||||
.replace(/"/g, '"')
|
||||
//title = showdown.helper.escapeCharacters(title, '*_', false);
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
[![the-image]]
|
||||
|
||||
[the-image]: http://example.com/foo.png
|
||||
<p>[<img src="http://example.com/foo.png" alt="the-image" />]</p>
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
[![the-image]]
|
||||
|
||||
[the-image]: http://example.com/foo.png
|
Loading…
Reference in New Issue