diff --git a/dist/showdown.js b/dist/showdown.js index 36c74cd..5482a2a 100644 Binary files a/dist/showdown.js and b/dist/showdown.js differ diff --git a/dist/showdown.js.map b/dist/showdown.js.map index 00aa3de..d25a535 100644 Binary files a/dist/showdown.js.map and b/dist/showdown.js.map differ diff --git a/dist/showdown.min.js b/dist/showdown.min.js index a298817..5a400d5 100644 Binary files a/dist/showdown.min.js and b/dist/showdown.min.js differ diff --git a/dist/showdown.min.js.map b/dist/showdown.min.js.map index 4889b77..8203460 100644 Binary files a/dist/showdown.min.js.map and b/dist/showdown.min.js.map differ diff --git a/src/options.js b/src/options.js index afefab0..0f6cb95 100644 --- a/src/options.js +++ b/src/options.js @@ -46,6 +46,11 @@ function getDefaultOpts (simple) { describe: 'Turn on/off image dimension parsing', type: 'boolean' }, + extractImageCaptions: { + defaultValue: false, + describe: 'Extract image alt tag as a caption for the image', + type: 'boolean' + }, simplifiedAutoLink: { defaultValue: false, describe: 'Turn on/off GFM autolink style', diff --git a/src/subParsers/makehtml/images.js b/src/subParsers/makehtml/images.js index 63d9f09..1b41c92 100644 --- a/src/subParsers/makehtml/images.js +++ b/src/subParsers/makehtml/images.js @@ -59,7 +59,13 @@ showdown.subParser('makehtml.images', function (text, options, globals) { .replace(showdown.helper.regexes.asteriskDashTildeAndColon, showdown.helper.escapeCharactersCallback); //url = showdown.helper.escapeCharacters(url, '*_', false); url = url.replace(showdown.helper.regexes.asteriskDashTildeAndColon, showdown.helper.escapeCharactersCallback); - var result = '' + altText + ''; + result += ''; + } + return result; } diff --git a/test/functional/makehtml/cases/features/extractImageCaptions.html b/test/functional/makehtml/cases/features/extractImageCaptions.html new file mode 100644 index 0000000..531c508 --- /dev/null +++ b/test/functional/makehtml/cases/features/extractImageCaptions.html @@ -0,0 +1,2 @@ +

This is a caption
This is a caption

+

diff --git a/test/functional/makehtml/cases/features/extractImageCaptions.md b/test/functional/makehtml/cases/features/extractImageCaptions.md new file mode 100644 index 0000000..1506636 --- /dev/null +++ b/test/functional/makehtml/cases/features/extractImageCaptions.md @@ -0,0 +1,3 @@ +![This is a caption](./image.png) + +![](./no-caption.png) diff --git a/test/functional/makehtml/testsuite.features.js b/test/functional/makehtml/testsuite.features.js index 4affe1c..082a300 100644 --- a/test/functional/makehtml/testsuite.features.js +++ b/test/functional/makehtml/testsuite.features.js @@ -95,6 +95,8 @@ describe('makeHtml() features testsuite', function () { converter = new showdown.Converter({openLinksInNewWindow: true}); } else if (testsuite[i].name === '#355.simplifiedAutoLink-URLs-inside-parenthesis-followed-by-another-character-are-not-parsed-correctly') { converter = new showdown.Converter({simplifiedAutoLink: true}); + } else if (testsuite[i].name === 'extractImageCaptions') { + converter = new showdown.Converter({extractImageCaptions: true}); } else { converter = new showdown.Converter(); }