From b0d475fc087c8340d80f10a9bafb4fe1d05f6515 Mon Sep 17 00:00:00 2001 From: Estevao Soares dos Santos Date: Fri, 14 Sep 2018 15:48:28 +0100 Subject: [PATCH] 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 --- dist/showdown.js | Bin 164196 -> 164231 bytes dist/showdown.js.map | Bin 461268 -> 461353 bytes dist/showdown.min.js | Bin 79317 -> 79339 bytes dist/showdown.min.js.map | Bin 88834 -> 88864 bytes src/subParsers/makehtml/images.js | 2 +- ...585.error-when-using-image-references.html | 4 +--- .../#585.error-when-using-image-references.md | 3 +++ 7 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dist/showdown.js b/dist/showdown.js index 5cacdeb0ad519ea906bcecabeea02b13ef5499b9..7569cb6cd8591c57e5b57a210c44f5e1860dfcb4 100644 GIT binary patch delta 37 tcmaFT#MR!+)v$#zZ1Lm(GqK6{G}zfnGD~t&HK*52WYpT;u$b}5T>u!74?q9_ delta 32 qcmV+*0N?+Ig9_w=3V^f$R->0vo&ge0uqP6#{!4H#{-AI#{{>(#|7nD1Ry3RAea841Q`Z&X>@F5DVMPi Q1{0S^69yT#&>{u|=gA~1Q~&?~ delta 59 zcmZ2EMdr$6nT8g|Elf4XCnrqgWy)}xzF+~9)bt5aOdRd^k23)=GZ3?Ezki(dd(`yB OvTVZJd6d~?p928?fEhUe diff --git a/dist/showdown.min.js b/dist/showdown.min.js index e30d275f86f05ebfb9a243b35bc88931d0e6d0cd..b6229e0a34fff3ecb378abe7dcceac774afb7046 100644 GIT binary patch delta 35 rcmccmn&tItmJLDIMUwO~QgaGYi}W&!gG-7s^U^gkH8%%bZ;b;0C`=EO delta 14 WcmaF;n&s+imJLDIH)mXLjspNePzXx^ diff --git a/dist/showdown.min.js.map b/dist/showdown.min.js.map index a394f171e8c6991fc6655b129dfff9dad573ae7f..6a777a3cdc698ac6ea7385c5e46b00fecca78552 100644 GIT binary patch delta 49 zcmZqL#=2k|>xQN;O74!1!RA%YI<7!E*Gb3U(b3;mCm6`duXNV&cJwZA-rV-3CJg|* CNfE;U delta 19 bcmZ3mjkReT>xQN;ES`?uZkv~UsYwF>SYrtb diff --git a/src/subParsers/makehtml/images.js b/src/subParsers/makehtml/images.js index 6ae02ef..65f72c6 100644 --- a/src/subParsers/makehtml/images.js +++ b/src/subParsers/makehtml/images.js @@ -61,7 +61,7 @@ showdown.subParser('makehtml.images', function (text, options, globals) { url = url.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback); var result = '' + altText + '[the-image]

diff --git a/test/functional/makehtml/cases/issues/#585.error-when-using-image-references.md b/test/functional/makehtml/cases/issues/#585.error-when-using-image-references.md index e69de29..8855cb3 100644 --- a/test/functional/makehtml/cases/issues/#585.error-when-using-image-references.md +++ b/test/functional/makehtml/cases/issues/#585.error-when-using-image-references.md @@ -0,0 +1,3 @@ +[![the-image]] + +[the-image]: http://example.com/foo.png