From 5557e6282c0556d024330369f230267c219d8455 Mon Sep 17 00:00:00 2001 From: Thomas Hunter II Date: Mon, 12 Nov 2018 22:14:03 -0800 Subject: [PATCH] feat(image): optionally add image captions from alt tags --- dist/showdown.js | Bin 173544 -> 173882 bytes dist/showdown.js.map | Bin 488985 -> 490068 bytes dist/showdown.min.js | Bin 81125 -> 81368 bytes dist/showdown.min.js.map | Bin 91924 -> 92119 bytes src/options.js | 5 +++++ src/subParsers/makehtml/images.js | 13 ++++++++++++- .../cases/features/extractImageCaptions.html | 2 ++ .../cases/features/extractImageCaptions.md | 3 +++ .../functional/makehtml/testsuite.features.js | 2 ++ 9 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 test/functional/makehtml/cases/features/extractImageCaptions.html create mode 100644 test/functional/makehtml/cases/features/extractImageCaptions.md diff --git a/dist/showdown.js b/dist/showdown.js index 36c74cd802fbe1595b2e6bacaae1c6faa19313ce..5482a2a4aaf083a17b3a12f45a15c2eb075358e4 100644 GIT binary patch delta 1151 zcmbVKT}TvB6y_XVcb%2|2{S6|qUrjRJFAxIs*68atc6*LCfLumj_Yi?V>`20NLhwN zLR47XhoB#*Am~MXxM45VTSXRRzLkOxMLlQ_^%6w0bFV@@HVn*nzw_O5&YbUjc`Z%P zNY}P(@RXH!Doe^drB$RzmI``ek)WY!k%GdZ@!G6S6CIJHwaRHD8VDNx{y<1+3=G7> z;{kiAr-}1KjR#1e&mcx1L;^YqkRX?l9xY0YUWH4h?j_wyo2t!vl{e+69eYbNlTl_b zQlQI5Apn{5!!)~zH z;kH;bLX>_jtdgMCt>{FJ7#b&Zi4>VH*{A9T(Rzp;8yL`{hSDv&fsxEFrlYABH|bebdbx4>`UlB3F%UmR*hU(uAy3jkgsS{M8qI;)WEu{N1!_@e)jk!KOWgRQ6&FW+Zm~CXCjx ztT}KIG0&gSDHik5FF0(OYo~RMkVDUO%7mYs}?4rXrlf*`)G#q-=; zc6lR8>6UM7avQD@?!WY471DYy=Fo66I+>>&KLbB|ci;z($||tKLhNw`hDG>@AMLEJ z5+8`O!;6*7OyuP0m{x-Y0#5sIS->~-cotETc;dS4Xk*4MY);|lc|S_*TPqqO=g2|4 z!3$R%!c&4=YB3AXwqX$Hy`$)2$J(*p!Ay9;B68X8<4A4nlY$q0?8JRM0`%Df%>M&V COJWHC delta 707 zcmX|7O-Phc6y@HUpI(0X87k`D$a6wEJPAA0Aen)vpy(Aiine0G5a1GEXKlb7*WZqR$v(2h6viWux$A(0^VC?C}{34xYu$2 zfg9iH@WkPt@OdPkua2gxaY4oC+K5vs+iLNbiK0>yvl%z2^mZ8A)k3*`^wRYR{#1sF z$h)ohR=;mYv0sZSV|Y@FXeN&LHId^9jA_;L1b)>GT5dysX-I7ff0RgI7hXU#gq-NZ zdRd-82fgXQ&N6M2?8S@PMtPuZvX%Q diff --git a/dist/showdown.js.map b/dist/showdown.js.map index 00aa3de48e279c994436552ae3fcaeba52cc9bfa..d25a535bd08d689ab0841a3e79163c670d7d6c4d 100644 GIT binary patch delta 885 zcmbVI-Ahwp7-#SKXgisnu`|n&@J8WhdDev#D$X^Bm6nMa6$^Hn`#4K?*3Mazx^UKo zbP<^^_M}keomVn3I1z!n2%=#hBMl;gU3BTiqW*x+oJJR2L@zuK56|=C_wmkd)~^4o z&3qS#i@yZvw@4uTO^!@836SnV0yx(ZH|?n;{lg65eKe7(yGV_YG5{QOc_|K@XXrgE zckQhXlXz!U)K^8*t96JUq$(j>K>Wis#6iJ>%;cWCf>h4iNw!Lu;VFS+mO0>Gq8doQ zK@3b;jP`mO?MI@QObj~oID-n5>8L(nLF|1pJt$FqpPN` za3s^tSccs0p~F3HcMn)osJiUBXvXO+pRruJV`)UgniR&8iX|K< zqj5+{U@a0XLtx@L-7vYhLhFkw4C8{hi={_`qe@i90cAL-VmYQMcx$2hVz{YPxKCC! ztc0+djK`IP798FNwBd-R#nm=Z49i+1d9@{=jEZVRNewHhSXBKziYfV;EP6{SDjayi z9@4viFdG++*SGs(hJf+p5N=S);adKd7}wR6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WB&s_'; + } + + 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(); }