From 50235d6951142cf3d11cf8b80963111e4ae552ea Mon Sep 17 00:00:00 2001 From: Estevao Soares dos Santos Date: Fri, 31 Mar 2017 00:25:40 +0100 Subject: [PATCH] feat(openLinksInNewWindow): add option to open all links in a new window Closes #362, #337, #249, #247, #222 --- README.md | 2 ++ dist/showdown.js | Bin 85343 -> 85694 bytes dist/showdown.js.map | Bin 247518 -> 248451 bytes dist/showdown.min.js | Bin 35726 -> 35930 bytes dist/showdown.min.js.map | Bin 38719 -> 38873 bytes src/options.js | 5 +++++ src/subParsers/anchors.js | 4 ++++ src/subParsers/autoLinks.js | 8 ++++++-- .../features/openLinksInNewWindow/simple.html | 2 ++ test/features/openLinksInNewWindow/simple.md | 3 +++ .../simplifiedAutoLink.html | 1 + .../simplifiedAutoLink.md | 1 + test/node/testsuite.features.js | 16 +++++++++++++++- 13 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 test/features/openLinksInNewWindow/simple.html create mode 100644 test/features/openLinksInNewWindow/simple.md create mode 100644 test/features/openLinksInNewWindow/simplifiedAutoLink.html create mode 100644 test/features/openLinksInNewWindow/simplifiedAutoLink.md diff --git a/README.md b/README.md index 8125943..7568ce0 100644 --- a/README.md +++ b/README.md @@ -310,6 +310,8 @@ var defaultOptions = showdown.getDefaultOptions(); NOTE: Prior to version 1.6.1, emails would always be obfuscated through dec and hex encoding. + * **openLinksInNewWindow**: (boolean) [default false] Open all links in new windows (by adding the attribute `target="_blank"` to `` tags) + **NOTE**: Please note that until version 1.6.0, all of these options are ***DISABLED*** by default in the cli tool. ## Flavors diff --git a/dist/showdown.js b/dist/showdown.js index 01aedbca536e8d2ccb07593ec822a09d52a81bdd..6b8db403cb35d8121907e28d8091007411add258 100644 GIT binary patch delta 269 zcmcaVi*?^zRsm~$Ek%XmjQsMH{PH{nW5bOC-+3nsaIlHw7o_I-WaecTd*=D2mWOBN z0ToO(;FXxfBQ5I>lv7B|$x+AwDNxAFQ^-p#S11RoDW1HLQEoFk-@od~Z)17Hu^FSO zP(AtKcVWJg#G>@n5?iJCq@2XO?9Jag4|9mFQuCjFeOHJQg2hha!sAQ}{G j71R|_O;=K%d~mAteldY5Vlm3(* IvnrL8xdqb}@Bjb+ diff --git a/dist/showdown.js.map b/dist/showdown.js.map index 1e4a77c23a2620827cf66e266d638e16420712c2..5dacbac9a5b72422c971531ae4129bf960d82544 100644 GIT binary patch delta 614 zcmah^O=}Zj5N6)p+RdwVx5*YsG|k&0L~TeTBBD~rYTNjc*oX%&fi_~4kaZJGaM99( zc&G=3l&P769|SyWD@7KC;Cc}XiueaKf;T}cc+16Y>mf+Nff*iVo)6~pef7=*b-5G5 zimsufjAMJ3j_zGf$v41hX5Jf>AHXqrm{XzvG7XM0A71buTYXjDLdt@9-m+XsA)1i5llh58Nm8G4aJ14#xjPH ziKPr9b=)vcS~Ro@qh6{`S|1yv#9pR2s}ej@q(hUZ2!KT>(E=Yf8yeLYL3P|6@KScp z_d^xvm>+^0QMCLKdg<3&2x8@|x6lSd)xz|{4pj;_f>7rGtp0>^v?2AR~a+$u? zSe#lnnX+ffyNbMN3Ui$zik7enwy@V(HodsPh8*)2OWmgSLncScm0GcERpVP&+WW<9 z!;*BhmcM?rP#en)PhT?gR>^60Sk^ZX%UPnUHc8HRSz?ebUJ?8Lx6qd>X6qd>X6qB%f6qit<0S}iz8v+HBfL#-laFzrD za7DM26#)wh0eXj^9|5&AjjDec!xyd|J5qS|~3*t&p^*^F5s- zdH(FY{HZj}bYI}Q#3+4*uSLEs(W+ngtZ5aCPg+(ZTq&X)KqL|rImv%9qju?nneT5W z%;nMKIE(y4b3He`68Y6?Edok?#$hi!;0aOCVKH>;nO@hqNLG0&YCc2gF%3~DJGBb> z_KXLES`5lGItxVvI!}YxT+Piq*sXWB5|zG>&5svs#wv6uR4NF8|z$2M!(l!1+Kk1s^v-^9TUH79v2G)Oc3unzjSTdgnH|BVyY;HFvN5kQxsh7?kS>7?sq=w#|-O>Qt3 zcg)gMQ`5+@RZ`N_NwiI}E=w#@$hJ+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MO+C(ppVSn_jX8^x65QMBpm_Mh{SOBuXC^~>=-`d;J#L00r-4K8K z+@m}3{02voZeAJzGT7Y>GHqn4<1ZrLo1G$I5!_|fZ<;Ib^@@sm)B2gQ9as=+GP z@QyocGDQWP9qJ)8wDpu$`QniH?u+qeF;4m9JR7QguwSLFQ%Tn7HuB6ePtdjmu1t$2 zoZiCQsk1|h>d_Tu)=sCwD>klB@nbdyrH8D>7h_1<__bq_@g%U#B4f__$~Ok9G{&NE zO2DgfK|WYW*Mi=-WN_D~XVrpu_e)1Zi_-*C92Ua_agKdykR*40Lc$z_J1NiFm=YYj zj5B^+soDG*aQ6Dc=yzVd-s^5i!YDA;51q@)*d?mYyN8d}O5s#XEp+JYPbik;8x;=O zls^vk^b{`7<11KOt#2Z5D&|v!f9>NCx4@1Ojt_% zW@O{(ADN5Aw6J5L?WECindc><0*_1t8J}c`zTuZO)@_Z}U^9XfK!azy4&lukn-<7x zgS;49Awf}0*^9PQh~qLIE*^U6p!n(az2b$Jc8k)>pEhD%Hcz#64`0bVkWarG!x8gLKu`9wr~=H-DSOVea_YlN##S>>8Y;T7(kMZCrMeZ@gyq+IVu$Q|G6cc>M;$ z7-|h9OmR* KHSx_?eE$v46v(Xr diff --git a/src/options.js b/src/options.js index abe254a..0dae5e4 100644 --- a/src/options.js +++ b/src/options.js @@ -115,6 +115,11 @@ function getDefaultOpts (simple) { defaultValue: true, description: 'Encode e-mail addresses through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities', type: 'boolean' + }, + openLinksInNewWindow: { + defaultValue: false, + description: 'Open all links in new windows', + type: 'boolean' } }; if (simple === false) { diff --git a/src/subParsers/anchors.js b/src/subParsers/anchors.js index 341dd87..d631e89 100644 --- a/src/subParsers/anchors.js +++ b/src/subParsers/anchors.js @@ -50,6 +50,10 @@ showdown.subParser('anchors', function (text, options, globals) { result += ' title="' + title + '"'; } + if (options.openLinksInNewWindow) { + result += ' target="_blank"'; + } + result += '>' + linkText + ''; return result; diff --git a/src/subParsers/autoLinks.js b/src/subParsers/autoLinks.js index 3fbabd7..354b9be 100644 --- a/src/subParsers/autoLinks.js +++ b/src/subParsers/autoLinks.js @@ -12,14 +12,18 @@ var simpleURLRegex = /\b(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+)()( return function (wm, link, m2, m3, trailingPunctuation) { var lnkTxt = link, - append = ''; + append = '', + target = ''; if (/^www\./i.test(link)) { link = link.replace(/^www\./i, 'http://www.'); } if (options.excludeTrailingPunctuationFromURLs && trailingPunctuation) { append = trailingPunctuation; } - return '' + lnkTxt + '' + append; + if (options.openLinksInNewWindow) { + target = ' target="_blank"'; + } + return '' + lnkTxt + '' + append; }; }, diff --git a/test/features/openLinksInNewWindow/simple.html b/test/features/openLinksInNewWindow/simple.html new file mode 100644 index 0000000..c62a155 --- /dev/null +++ b/test/features/openLinksInNewWindow/simple.html @@ -0,0 +1,2 @@ +

foo

+

a link http://www.google.com

diff --git a/test/features/openLinksInNewWindow/simple.md b/test/features/openLinksInNewWindow/simple.md new file mode 100644 index 0000000..28e9e69 --- /dev/null +++ b/test/features/openLinksInNewWindow/simple.md @@ -0,0 +1,3 @@ +[foo](www.google.com) + +a link diff --git a/test/features/openLinksInNewWindow/simplifiedAutoLink.html b/test/features/openLinksInNewWindow/simplifiedAutoLink.html new file mode 100644 index 0000000..c23bf68 --- /dev/null +++ b/test/features/openLinksInNewWindow/simplifiedAutoLink.html @@ -0,0 +1 @@ +

this is http://www.google.com autolink

diff --git a/test/features/openLinksInNewWindow/simplifiedAutoLink.md b/test/features/openLinksInNewWindow/simplifiedAutoLink.md new file mode 100644 index 0000000..d23d672 --- /dev/null +++ b/test/features/openLinksInNewWindow/simplifiedAutoLink.md @@ -0,0 +1 @@ +this is http://www.google.com autolink diff --git a/test/node/testsuite.features.js b/test/node/testsuite.features.js index 0982447..21c54c9 100644 --- a/test/node/testsuite.features.js +++ b/test/node/testsuite.features.js @@ -6,7 +6,8 @@ var bootstrap = require('../bootstrap.js'), assertion = bootstrap.assertion, testsuite = bootstrap.getTestSuite('test/features/'), tableSuite = bootstrap.getTestSuite('test/features/tables/'), - simplifiedAutoLinkSuite = bootstrap.getTestSuite('test/features/simplifiedAutoLink/'); + simplifiedAutoLinkSuite = bootstrap.getTestSuite('test/features/simplifiedAutoLink/'), + openLinksInNewWindowSuite = bootstrap.getTestSuite('test/features/openLinksInNewWindow/'); describe('makeHtml() features testsuite', function () { 'use strict'; @@ -111,4 +112,17 @@ describe('makeHtml() features testsuite', function () { } }); + // test openLinksInNewWindow support + describe('openLinksInNewWindow support in', function () { + var converter, + suite = openLinksInNewWindowSuite; + for (var i = 0; i < suite.length; ++i) { + if (suite[i].name === 'simplifiedAutoLink') { + converter = new showdown.Converter({openLinksInNewWindow: true, simplifiedAutoLink: true}); + } else { + converter = new showdown.Converter({openLinksInNewWindow: true}); + } + it(suite[i].name.replace(/-/g, ' '), assertion(suite[i], converter)); + } + }); });