From 5c50675ccaf43bf3c0cfc56ee192af906a107ef1 Mon Sep 17 00:00:00 2001 From: Estevao Soares dos Santos Date: Sun, 26 Feb 2017 19:13:52 +0000 Subject: [PATCH] fix(simpleAutoLinks): URLs with emphasis/strikethrough are parsed correctly When a user enters a URL with emphasis or strikethrough, the html output were incorrect. Now, URLs inside emphasis or strikethrough are parsed corerctly Closes #347 --- dist/showdown.js | Bin 83750 -> 85143 bytes dist/showdown.js.map | Bin 243544 -> 247053 bytes dist/showdown.min.js | Bin 35012 -> 35657 bytes dist/showdown.min.js.map | Bin 37857 -> 38637 bytes src/subParsers/autoLinks.js | 108 +++++++----- src/subParsers/italicsAndBold.js | 31 +++- src/subParsers/spanGamut.js | 3 +- src/subParsers/strikethrough.js | 9 +- .../simplifiedAutoLink/blockquote.html | 3 + .../features/simplifiedAutoLink/blockquote.md | 1 + .../disallow-underscores.html} | 0 .../disallow-underscores.md} | 0 .../does-not-parse-inside-a-tags.html | 1 + .../does-not-parse-inside-a-tags.md | 1 + .../does-not-parse-inside-code.html | 6 + .../does-not-parse-inside-code.md | 5 + .../emphasis-and-strikethrough.html | 7 + .../emphasis-and-strikethrough.md | 13 ++ .../simplifiedAutoLink/ordered-lists.html | 11 ++ .../simplifiedAutoLink/ordered-lists.md | 11 ++ test/features/simplifiedAutoLink/text.html | 6 + test/features/simplifiedAutoLink/text.md | 13 ++ .../simplifiedAutoLink/unordered-lists.html | 11 ++ .../simplifiedAutoLink/unordered-lists.md | 11 ++ test/node/testsuite.features.js | 164 ++++++++++-------- 25 files changed, 289 insertions(+), 126 deletions(-) create mode 100644 test/features/simplifiedAutoLink/blockquote.html create mode 100644 test/features/simplifiedAutoLink/blockquote.md rename test/features/{autolink-and-disallow-underscores.html => simplifiedAutoLink/disallow-underscores.html} (100%) rename test/features/{autolink-and-disallow-underscores.md => simplifiedAutoLink/disallow-underscores.md} (100%) create mode 100644 test/features/simplifiedAutoLink/does-not-parse-inside-a-tags.html create mode 100644 test/features/simplifiedAutoLink/does-not-parse-inside-a-tags.md create mode 100644 test/features/simplifiedAutoLink/does-not-parse-inside-code.html create mode 100644 test/features/simplifiedAutoLink/does-not-parse-inside-code.md create mode 100644 test/features/simplifiedAutoLink/emphasis-and-strikethrough.html create mode 100644 test/features/simplifiedAutoLink/emphasis-and-strikethrough.md create mode 100644 test/features/simplifiedAutoLink/ordered-lists.html create mode 100644 test/features/simplifiedAutoLink/ordered-lists.md create mode 100644 test/features/simplifiedAutoLink/text.html create mode 100644 test/features/simplifiedAutoLink/text.md create mode 100644 test/features/simplifiedAutoLink/unordered-lists.html create mode 100644 test/features/simplifiedAutoLink/unordered-lists.md diff --git a/dist/showdown.js b/dist/showdown.js index dcdf75c4015e0ddbe045293f38a940185f37016e..c111e931fee5a351481b3cb72b5272969c7d008b 100644 GIT binary patch delta 1599 zcmbtUPfQe77|&~6v9z*m_+L=p2Hcrpmwkc?$|BoBlcp)AsYVX&5Ie8~J7IQaGc&lT ztdWb}Se$Qn#|E$V)|8eIZq11D|=Dd=$+z`vajI7M$v{yd zI~^h!AEYuJ_9W$mR`oV`mhpls>oc-F$PKfmIIk;4@uG5?#7U_bO$JKD7 zzZRwz4}g(%AGNR-IR(cQe%PuXHxZiLxhcc?J7|Un@x;V`+8$)jLPO36-MJo^$elDw z+^7cb=W4f9?S<#LR=0)SQWY|rG^tiXB%OnA?z-UWyc>w_0;E@cw6#|Z+?%g6qxFb} zjpY#Z8ewFkKDL`G3=4epb70dw#?o=LAD-%;8vh(emBy_QYVs7MjA^pj4)|-yq|w`9 zakUbrpbYw|YcTns3Lfje4>8tYWu~s?Erb+9Yv8@q&}cV$(xJ+itqvnIC|EzsPAcQ22uOZ5Muw#z2# z3_M-`3BL&_mIQZRPVYj?`3-UBTF!6yVBfz#9)6b=+=-KM!`q7pTzlc3`{Y$aO9>|p z#biZYIOa!QWVi$9pvSr*ozvtTl~H4vL5&NM02=?mxZaM+JO%c3j0KN$dM5^E3Jpwk pMR~EC%6r%}oE@-jZ2S>Kv*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O{aK6#?G zKV!z^ht?5{nUk$-3>mW~=h&n%W>3Cs<1qQ6tB6>pPKu^ZqHUsHQEEX>VsffRwoaO+ z&g75wBJ65v8i}@0TQeQFl{0`!tq=;+(RF6&q)lGvATxQQz53>l4sx248@v=I`{(gb zUYHdqr({!HQk0*UZfBF4Yo}spqYtEP^r2!(lXbFHMd3<7(r}rkY!zN5Buz?_&u4om z!qtLgl(dtymC#MJ&T*H3tAeV48#*_~QvhrzLaWl`pE&_Un46pHjoaMIx!xG&ZZ^!b z=bx-o$3MBDwtw;gBbLebb-yQX5M!Ubw%&u0Yx386Ej}fil++w>uz={vfgv)JZ`AW` UPHN!iV$7Lb)HMl6vUa-w038>&wg3PC diff --git a/dist/showdown.min.js.map b/dist/showdown.min.js.map index 6c893618254a404fac1b4e66609174629bc80183..ca06c1476bd3a1b088e6964b34730739d3c32a3a 100644 GIT binary patch delta 4552 zcmbtXTWlNG5e1b8WH+`^_#w+r(SnlL+L%vCq+J)iyId}>))cj-DVjzLhmvKA6kigb zV(rqe#)+Leb|?7@P!}lBuc8V3RU|+CC{Q&0NPwbfixzE)0EN*ONWc4$&deoaSyq7p z{n_Q-duQg%%$d2vPk%h{&z}su_t_RWv2_kU+cNj?-qyEWTeGXRMOm)pFD^bDdEtxD zm=y6bjN@rqB{X zB(xMRPue6YGxUtNb^c&wvZa$i0dATv9h{14wh*?LUPeI|bS%M7yKKWRP4_^42L5h( zrlpXb2+J$0Q>W=@GAK!xhm0HRj8|i{o2fAdD{RuCFqsu{9HLS87F;4r9Sg3V+zB_L zqhpOYub?-i*I-8)mR8b*DCxNPSPJGtl0@>hwbB}#fg6sGa45$S>yxc%!)3Ixe^tiwrSEeGxn+5@N28<;MU$5;8JSExQR5Fd(MRBu9aAf;h)yMqZ_oUSUh1|o!!y!ZdAHCf*p+^xX~DPZ&17* zffQCaQiKP$yzueGXW>!fL^sI1SXSK$i`7Dc6^$@gsgt6Rohk80ihGGuo?%WCU(%RU zYt<;t5cSd&uXFeivV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Tdw`P*QF&q zX+}-BbbYMnsDK||A9xPes46AkxVIa&pAEw3jr*IAFu*en`2CI3Tg#L)!{QM((*Wn) zhk+`DZU)aH0H_{VODcgjf_ij%Nrppiad&U2feaY^Z6jzs0@XfWO_$d@IC-wtQUBZnA5vF@@PS zVu~#-vDysN?FkB^?RN`T!7I6hmB+&oi#1dATdNHpytgy31RuZWF6UhIM?b}eXu}GF z-89QCS@kNUL`CHS4HjYhJH9|f69Hq1r08%cMS5b9Z9b`|$P^o|(2Qp@hK3tEr}!e= zz4gLaj-P+rQoeO7KhD+}?kXMDmIjB{qT=U5b~?Zfe>TZV{a&b_z0vsX2aLogiluYot*Q5{zN*O97Y?#Sa2m0R5t7;6U({(q9U*7gKO;e)lqeZw3S&o68r zRHrY%AJ@X`(zV-PUyeUhgLRyrBEa_#BCrTK_;Emuj-wM#6d59HDtjCQ z#HE3p$&jQfnVb^#Qk~K4W$gTpn-+2`d`yv0m35L9dcKC(M=wk#HK$0WQze>lf*i9j z&uH^W97P`AcwB&j8fBuhNRA3?kl%p48T^jI%ib_7!d`geb{~8fzH|&b4T(;S>r?68 z#3R)QJ=D+US;B4mQ^Eg$nmI?e(rp$qJLY1y@9c#!cy2j0{9iZ-LbblAC|K&hL}HLl zSy8`}NlypdgZ%za@TKE+&y7H34HqHLW2k5BNZ8exTI?bsMc?SIjv zXUV`5q7;@tM4T`+lO9)Dzl*|tfK_;SXJ1dj=5M#}RChx7?)~0*Hnkut@SD54wvSHI zh{wgo@0cN9^bg~~7foT}ey6f#Y3>LIHv{^X=C|s}1xVi;*xHyvj|@+vx8TVpymjyJ Uw$>DCvQCtVgI{FuqkEzM0CJ^r@c;k- diff --git a/src/subParsers/autoLinks.js b/src/subParsers/autoLinks.js index 1e08785..cc03aca 100644 --- a/src/subParsers/autoLinks.js +++ b/src/subParsers/autoLinks.js @@ -1,54 +1,74 @@ +// url allowed chars [a-z\d_.~:/?#[]@!$&'()*+,;=-] + +var simpleURLRegex = /\b(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+)()(?=\s|$)(?!["<>])/gi, + simpleURLRegex2 = /\b(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+?)([.!?()]?)(?=\s|$)(?!["<>])/gi, + //simpleURLRegex3 = /\b(((https?|ftp):\/\/|www\.)[a-z\d.-]+\.[a-z\d_.~:/?#\[\]@!$&'()*+,;=-]+?)([.!?()]?)(?=\s|$)(?!["<>])/gi, + delimUrlRegex = /<(((https?|ftp|dict):\/\/|www\.)[^'">\s]+)>/gi, + simpleMailRegex = /(^|\s)(?:mailto:)?([A-Za-z0-9!#$%&'*+-/=?^_`{|}~.]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)(?=$|\s)/gmi, + delimMailRegex = /<()(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi, + + replaceLink = function (options) { + 'use strict'; + + return function (wm, link, m2, m3, trailingPunctuation) { + var lnkTxt = link, + append = ''; + if (/^www\./i.test(link)) { + link = link.replace(/^www\./i, 'http://www.'); + } + if (options.excludeTrailingPunctuationFromURLs && trailingPunctuation) { + append = trailingPunctuation; + } + return '' + lnkTxt + '' + append; + }; + }, + + replaceMail = function (options, globals) { + 'use strict'; + return function (wholeMatch, b, mail) { + var href = 'mailto:'; + b = b || ''; + mail = showdown.subParser('unescapeSpecialChars')(mail, options, globals); + if (options.encodeEmails) { + href = showdown.helper.encodeEmailAddress(href + mail); + mail = showdown.helper.encodeEmailAddress(mail); + } else { + href = href + mail; + } + return b + '' + mail + ''; + }; + }; + showdown.subParser('autoLinks', function (text, options, globals) { 'use strict'; text = globals.converter._dispatch('autoLinks.before', text, options, globals); - var simpleURLRegex = /\b(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+)()(?=\s|$)(?!["<>])/gi, - simpleURLRegex2 = /\b(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+?)([.!?()]?)(?=\s|$)(?!["<>])/gi, - delimUrlRegex = /<(((https?|ftp|dict):\/\/|www\.)[^'">\s]+)>/gi, - simpleMailRegex = /(^|\s)(?:mailto:)?([A-Za-z0-9!#$%&'*+-/=?^_`{|}~.]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)(?=$|\s)/gmi, - delimMailRegex = /<()(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi; - - text = text.replace(delimUrlRegex, replaceLink); - text = text.replace(delimMailRegex, replaceMail); - // simpleURLRegex = /\b(((https?|ftp|dict):\/\/|www\.)[-.+~:?#@!$&'()*,;=[\]\w]+)\b/gi, - // Email addresses: - - if (options.simplifiedAutoLink) { - if (options.excludeTrailingPunctuationFromURLs) { - text = text.replace(simpleURLRegex2, replaceLink); - } else { - text = text.replace(simpleURLRegex, replaceLink); - } - text = text.replace(simpleMailRegex, replaceMail); - } - - function replaceLink (wm, link, m2, m3, trailingPunctuation) { - var lnkTxt = link, - append = ''; - if (/^www\./i.test(link)) { - link = link.replace(/^www\./i, 'http://www.'); - } - if (options.excludeTrailingPunctuationFromURLs && trailingPunctuation) { - append = trailingPunctuation; - } - return '' + lnkTxt + '' + append; - } - - function replaceMail (wholeMatch, b, mail) { - var href = 'mailto:'; - b = b || ''; - mail = showdown.subParser('unescapeSpecialChars')(mail, options, globals); - if (options.encodeEmails) { - href = showdown.helper.encodeEmailAddress(href + mail); - mail = showdown.helper.encodeEmailAddress(mail); - } else { - href = href + mail; - } - return b + '' + mail + ''; - } + text = text.replace(delimUrlRegex, replaceLink(options)); + text = text.replace(delimMailRegex, replaceMail(options, globals)); text = globals.converter._dispatch('autoLinks.after', text, options, globals); return text; }); + +showdown.subParser('simplifiedAutoLinks', function (text, options, globals) { + 'use strict'; + + if (!options.simplifiedAutoLink) { + return text; + } + + text = globals.converter._dispatch('simplifiedAutoLinks.before', text, options, globals); + + if (options.excludeTrailingPunctuationFromURLs) { + text = text.replace(simpleURLRegex2, replaceLink(options)); + } else { + text = text.replace(simpleURLRegex, replaceLink(options)); + } + text = text.replace(simpleMailRegex, replaceMail(options, globals)); + + text = globals.converter._dispatch('simplifiedAutoLinks.after', text, options, globals); + + return text; +}); diff --git a/src/subParsers/italicsAndBold.js b/src/subParsers/italicsAndBold.js index 9616136..9fd80c1 100644 --- a/src/subParsers/italicsAndBold.js +++ b/src/subParsers/italicsAndBold.js @@ -7,34 +7,47 @@ showdown.subParser('italicsAndBold', function (text, options, globals) { // because of backtracing, in some cases, it could lead to an exponential effect // called "catastrophic backtrace". Ominous! + function parseInside (txt, left, right) { + if (options.simplifiedAutoLink) { + txt = showdown.subParser('simplifiedAutoLinks')(txt, options, globals); + } + return left + txt + right; + } + // Parse underscores if (options.literalMidWordUnderscores) { - text = text.replace(/\b___(\S[\s\S]*)___\b/g, '$1'); - text = text.replace(/\b__(\S[\s\S]*)__\b/g, '$1'); - text = text.replace(/\b_(\S[\s\S]*?)_\b/g, '$1'); + text = text.replace(/\b___(\S[\s\S]*)___\b/g, function (wm, txt) { + return parseInside (txt, '', ''); + }); + text = text.replace(/\b__(\S[\s\S]*)__\b/g, function (wm, txt) { + return parseInside (txt, '', ''); + }); + text = text.replace(/\b_(\S[\s\S]*?)_\b/g, function (wm, txt) { + return parseInside (txt, '', ''); + }); } else { text = text.replace(/___(\S[\s\S]*?)___/g, function (wm, m) { - return (/\S$/.test(m)) ? '' + m + '' : wm; + return (/\S$/.test(m)) ? parseInside (m, '', '') : wm; }); text = text.replace(/__(\S[\s\S]*?)__/g, function (wm, m) { - return (/\S$/.test(m)) ? '' + m + '' : wm; + return (/\S$/.test(m)) ? parseInside (m, '', '') : wm; }); text = text.replace(/_([^\s_][\s\S]*?)_/g, function (wm, m) { // !/^_[^_]/.test(m) - test if it doesn't start with __ (since it seems redundant, we removed it) - return (/\S$/.test(m)) ? '' + m + '' : wm; + return (/\S$/.test(m)) ? parseInside (m, '', '') : wm; }); } // Now parse asterisks text = text.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g, function (wm, m) { - return (/\S$/.test(m)) ? '' + m + '' : wm; + return (/\S$/.test(m)) ? parseInside (m, '', '') : wm; }); text = text.replace(/\*\*(\S[\s\S]*?)\*\*/g, function (wm, m) { - return (/\S$/.test(m)) ? '' + m + '' : wm; + return (/\S$/.test(m)) ? parseInside (m, '', '') : wm; }); text = text.replace(/\*([^\s*][\s\S]*?)\*/g, function (wm, m) { // !/^\*[^*]/.test(m) - test if it doesn't start with ** (since it seems redundant, we removed it) - return (/\S$/.test(m)) ? '' + m + '' : wm; + return (/\S$/.test(m)) ? parseInside (m, '', '') : wm; }); text = globals.converter._dispatch('italicsAndBold.after', text, options, globals); diff --git a/src/subParsers/spanGamut.js b/src/subParsers/spanGamut.js index d693882..b829ba4 100644 --- a/src/subParsers/spanGamut.js +++ b/src/subParsers/spanGamut.js @@ -16,11 +16,12 @@ showdown.subParser('spanGamut', function (text, options, globals) { text = showdown.subParser('anchors')(text, options, globals); // Make links out of things like `` - // Must come after _DoAnchors(), because you can use < and > + // Must come after anchors, because you can use < and > // delimiters in inline links like [this](). text = showdown.subParser('autoLinks')(text, options, globals); text = showdown.subParser('italicsAndBold')(text, options, globals); text = showdown.subParser('strikethrough')(text, options, globals); + text = showdown.subParser('simplifiedAutoLinks')(text, options, globals); // we need to hash HTML tags inside spans text = showdown.subParser('hashHTMLSpans')(text, options, globals); diff --git a/src/subParsers/strikethrough.js b/src/subParsers/strikethrough.js index e7c8757..4517c67 100644 --- a/src/subParsers/strikethrough.js +++ b/src/subParsers/strikethrough.js @@ -1,9 +1,16 @@ showdown.subParser('strikethrough', function (text, options, globals) { 'use strict'; + function parseInside (txt) { + if (options.simplifiedAutoLink) { + txt = showdown.subParser('simplifiedAutoLinks')(txt, options, globals); + } + return '' + txt + ''; + } + if (options.strikethrough) { text = globals.converter._dispatch('strikethrough.before', text, options, globals); - text = text.replace(/(?:~){2}([\s\S]+?)(?:~){2}/g, '$1'); + text = text.replace(/(?:~){2}([\s\S]+?)(?:~){2}/g, function (wm, txt) { return parseInside(txt); }); text = globals.converter._dispatch('strikethrough.after', text, options, globals); } diff --git a/test/features/simplifiedAutoLink/blockquote.html b/test/features/simplifiedAutoLink/blockquote.html new file mode 100644 index 0000000..f2e95e1 --- /dev/null +++ b/test/features/simplifiedAutoLink/blockquote.html @@ -0,0 +1,3 @@ +
+

http://www.google.com

+
diff --git a/test/features/simplifiedAutoLink/blockquote.md b/test/features/simplifiedAutoLink/blockquote.md new file mode 100644 index 0000000..cde3848 --- /dev/null +++ b/test/features/simplifiedAutoLink/blockquote.md @@ -0,0 +1 @@ +> http://www.google.com diff --git a/test/features/autolink-and-disallow-underscores.html b/test/features/simplifiedAutoLink/disallow-underscores.html similarity index 100% rename from test/features/autolink-and-disallow-underscores.html rename to test/features/simplifiedAutoLink/disallow-underscores.html diff --git a/test/features/autolink-and-disallow-underscores.md b/test/features/simplifiedAutoLink/disallow-underscores.md similarity index 100% rename from test/features/autolink-and-disallow-underscores.md rename to test/features/simplifiedAutoLink/disallow-underscores.md diff --git a/test/features/simplifiedAutoLink/does-not-parse-inside-a-tags.html b/test/features/simplifiedAutoLink/does-not-parse-inside-a-tags.html new file mode 100644 index 0000000..044e97b --- /dev/null +++ b/test/features/simplifiedAutoLink/does-not-parse-inside-a-tags.html @@ -0,0 +1 @@ +

www.google.com

diff --git a/test/features/simplifiedAutoLink/does-not-parse-inside-a-tags.md b/test/features/simplifiedAutoLink/does-not-parse-inside-a-tags.md new file mode 100644 index 0000000..51a9890 --- /dev/null +++ b/test/features/simplifiedAutoLink/does-not-parse-inside-a-tags.md @@ -0,0 +1 @@ +www.google.com diff --git a/test/features/simplifiedAutoLink/does-not-parse-inside-code.html b/test/features/simplifiedAutoLink/does-not-parse-inside-code.html new file mode 100644 index 0000000..5a99028 --- /dev/null +++ b/test/features/simplifiedAutoLink/does-not-parse-inside-code.html @@ -0,0 +1,6 @@ +
some code with
+a link
+www.google.com
+
+and another link http://www.google.com
+
diff --git a/test/features/simplifiedAutoLink/does-not-parse-inside-code.md b/test/features/simplifiedAutoLink/does-not-parse-inside-code.md new file mode 100644 index 0000000..c4c8694 --- /dev/null +++ b/test/features/simplifiedAutoLink/does-not-parse-inside-code.md @@ -0,0 +1,5 @@ + some code with + a link + www.google.com + + and another link http://www.google.com diff --git a/test/features/simplifiedAutoLink/emphasis-and-strikethrough.html b/test/features/simplifiedAutoLink/emphasis-and-strikethrough.html new file mode 100644 index 0000000..c3da7fd --- /dev/null +++ b/test/features/simplifiedAutoLink/emphasis-and-strikethrough.html @@ -0,0 +1,7 @@ +

http://www.google.com/foobar

+

http://www.google.com/foobar

+

http://www.google.com/foobar

+

http://www.google.com/foobar

+

http://www.google.com/foobar

+

http://www.google.com/foobar

+

http://www.google.com/foobar

diff --git a/test/features/simplifiedAutoLink/emphasis-and-strikethrough.md b/test/features/simplifiedAutoLink/emphasis-and-strikethrough.md new file mode 100644 index 0000000..25814b4 --- /dev/null +++ b/test/features/simplifiedAutoLink/emphasis-and-strikethrough.md @@ -0,0 +1,13 @@ +*http://www.google.com/foobar* + +**http://www.google.com/foobar** + +***http://www.google.com/foobar*** + +~~http://www.google.com/foobar~~ + +_http://www.google.com/foobar_ + +__http://www.google.com/foobar__ + +___http://www.google.com/foobar___ \ No newline at end of file diff --git a/test/features/simplifiedAutoLink/ordered-lists.html b/test/features/simplifiedAutoLink/ordered-lists.html new file mode 100644 index 0000000..cbb2217 --- /dev/null +++ b/test/features/simplifiedAutoLink/ordered-lists.html @@ -0,0 +1,11 @@ +
    +
  1. http://www.google.com/listitem1
  2. +
  3. http://www.google.com/listitem2
  4. +
  5. http://www.google.com/listitem3
  6. +
+

foo

+
    +
  1. http://www.google.com/listitem1

  2. +
  3. http://www.google.com/listitem2

  4. +
  5. http://www.google.com/listitem3

  6. +
diff --git a/test/features/simplifiedAutoLink/ordered-lists.md b/test/features/simplifiedAutoLink/ordered-lists.md new file mode 100644 index 0000000..df50da9 --- /dev/null +++ b/test/features/simplifiedAutoLink/ordered-lists.md @@ -0,0 +1,11 @@ +1. http://www.google.com/listitem1 +2. http://www.google.com/listitem2 +3. http://www.google.com/listitem3 + +foo + +1. http://www.google.com/listitem1 + +2. http://www.google.com/listitem2 + +3. http://www.google.com/listitem3 \ No newline at end of file diff --git a/test/features/simplifiedAutoLink/text.html b/test/features/simplifiedAutoLink/text.html new file mode 100644 index 0000000..5f7d35c --- /dev/null +++ b/test/features/simplifiedAutoLink/text.html @@ -0,0 +1,6 @@ +

http://www.google.com/foobar

+

www.google.com/foobar

+

ftp://user:password@host.com:port/path

+

this has some http://www.google.com/foobar in text

+

this has some www.google.com/foobar in text

+

this has some ftp://user:password@host.com:port/path in text

diff --git a/test/features/simplifiedAutoLink/text.md b/test/features/simplifiedAutoLink/text.md new file mode 100644 index 0000000..9c65067 --- /dev/null +++ b/test/features/simplifiedAutoLink/text.md @@ -0,0 +1,13 @@ +http://www.google.com/foobar + +www.google.com/foobar + +ftp://user:password@host.com:port/path + +this has some http://www.google.com/foobar in text + +this has some www.google.com/foobar in text + +this has some ftp://user:password@host.com:port/path in text + + diff --git a/test/features/simplifiedAutoLink/unordered-lists.html b/test/features/simplifiedAutoLink/unordered-lists.html new file mode 100644 index 0000000..bc728f6 --- /dev/null +++ b/test/features/simplifiedAutoLink/unordered-lists.html @@ -0,0 +1,11 @@ + +

a

+ diff --git a/test/features/simplifiedAutoLink/unordered-lists.md b/test/features/simplifiedAutoLink/unordered-lists.md new file mode 100644 index 0000000..0d7e6f4 --- /dev/null +++ b/test/features/simplifiedAutoLink/unordered-lists.md @@ -0,0 +1,11 @@ + - http://www.google.com/foo + - http://www.google.com/bar + - http://www.google.com/baz + +a + + - http://www.google.com/foo + + - http://www.google.com/bar + + - http://www.google.com/baz diff --git a/test/node/testsuite.features.js b/test/node/testsuite.features.js index 46946da..0982447 100644 --- a/test/node/testsuite.features.js +++ b/test/node/testsuite.features.js @@ -5,87 +5,109 @@ var bootstrap = require('../bootstrap.js'), showdown = bootstrap.showdown, assertion = bootstrap.assertion, testsuite = bootstrap.getTestSuite('test/features/'), - tableSuite = bootstrap.getTestSuite('test/features/tables/'); + tableSuite = bootstrap.getTestSuite('test/features/tables/'), + simplifiedAutoLinkSuite = bootstrap.getTestSuite('test/features/simplifiedAutoLink/'); describe('makeHtml() features testsuite', function () { 'use strict'; - for (var i = 0; i < testsuite.length; ++i) { - var converter; - if (testsuite[i].name === '#143.support-image-dimensions') { - converter = new showdown.Converter({parseImgDimensions: true}); - } else if (testsuite[i].name === '#69.header-level-start') { - converter = new showdown.Converter({headerLevelStart: 3}); - } else if (testsuite[i].name === '#164.1.simple-autolink' || testsuite[i].name === '#204.certain-links-with-at-and-dot-break-url') { - converter = new showdown.Converter({simplifiedAutoLink: true}); - } else if (testsuite[i].name === '#164.2.disallow-underscore-emphasis-mid-word') { - converter = new showdown.Converter({literalMidWordUnderscores: true}); - } else if (testsuite[i].name === '#164.3.strikethrough' || testsuite[i].name === '#214.escaped-markdown-chars-break-strikethrough') { - converter = new showdown.Converter({strikethrough: true}); - } else if (testsuite[i].name === 'disable-gh-codeblocks') { - converter = new showdown.Converter({ghCodeBlocks: false}); - } else if (testsuite[i].name === '#164.4.tasklists') { - converter = new showdown.Converter({tasklists: true}); - } else if (testsuite[i].name === 'autolink-and-disallow-underscores') { - converter = new showdown.Converter({literalMidWordUnderscores: true, simplifiedAutoLink: true}); - } else if (testsuite[i].name === '#198.literalMidWordUnderscores-changes-behavior-of-asterisk') { - converter = new showdown.Converter({literalMidWordUnderscores: true}); - } else if (testsuite[i].name === '#259.es6-template-strings-indentation-issues') { - converter = new showdown.Converter({smartIndentationFix: true}); - } else if (testsuite[i].name === '#284.simplifiedAutoLink-does-not-match-GFM-style') { - converter = new showdown.Converter({simplifiedAutoLink: true}); - } else if (testsuite[i].name === 'disableForced4SpacesIndentedSublists') { - converter = new showdown.Converter({disableForced4SpacesIndentedSublists: true}); - } else if (testsuite[i].name === '#206.treat-single-line-breaks-as-br') { - converter = new showdown.Converter({simpleLineBreaks: true}); - } else if (testsuite[i].name === 'simpleLineBreaks2') { - converter = new showdown.Converter({simpleLineBreaks: true}); - } else if (testsuite[i].name === '#316.new-simpleLineBreaks-option-breaks-lists') { - converter = new showdown.Converter({simpleLineBreaks: true}); - } else if (testsuite[i].name === '#323.simpleLineBreaks-breaks-with-strong') { - converter = new showdown.Converter({simpleLineBreaks: true}); - } else if (testsuite[i].name === '#318.simpleLineBreaks-does-not-work-with-chinese-characters') { - converter = new showdown.Converter({simpleLineBreaks: true}); - } else if (testsuite[i].name === 'simpleLineBreaks-handle-html-pre') { - converter = new showdown.Converter({simpleLineBreaks: true}); - } else if (testsuite[i].name === 'excludeTrailingPunctuationFromURLs-option') { - converter = new showdown.Converter({simplifiedAutoLink: true, excludeTrailingPunctuationFromURLs: true}); - } else if (testsuite[i].name === 'requireSpaceBeforeHeadingText') { - converter = new showdown.Converter({requireSpaceBeforeHeadingText: true}); - } else if (testsuite[i].name === '#320.github-compatible-generated-header-id') { - converter = new showdown.Converter({ghCompatibleHeaderId: true}); - } else if (testsuite[i].name === 'ghMentions') { - converter = new showdown.Converter({ghMentions: true}); - } else if (testsuite[i].name === 'disable-email-encoding') { - converter = new showdown.Converter({encodeEmails: false}); - } else if (testsuite[i].name === '#330.simplifiedAutoLink-drops-character-before-and-after-linked-mail') { - converter = new showdown.Converter({encodeEmails: false, simplifiedAutoLink: true}); - } else if (testsuite[i].name === '#331.allow-escaping-of-tilde') { - converter = new showdown.Converter({strikethrough: true}); - } else if (testsuite[i].name === 'prefixHeaderId-simple') { - converter = new showdown.Converter({prefixHeaderId: true}); - } else if (testsuite[i].name === 'prefixHeaderId-string') { - converter = new showdown.Converter({prefixHeaderId: 'my-prefix-'}); - } else if (testsuite[i].name === 'prefixHeaderId-string-and-ghCompatibleHeaderId') { - converter = new showdown.Converter({prefixHeaderId: 'my-prefix-', ghCompatibleHeaderId: true}); - } else if (testsuite[i].name === 'prefixHeaderId-string-and-ghCompatibleHeaderId2') { - converter = new showdown.Converter({prefixHeaderId: 'my prefix ', ghCompatibleHeaderId: true}); - } else { - converter = new showdown.Converter(); - } - it(testsuite[i].name.replace(/-/g, ' '), assertion(testsuite[i], converter)); - } + describe('issues', function () { + for (var i = 0; i < testsuite.length; ++i) { + var converter; + if (testsuite[i].name === '#143.support-image-dimensions') { + converter = new showdown.Converter({parseImgDimensions: true}); + } else if (testsuite[i].name === '#69.header-level-start') { + converter = new showdown.Converter({headerLevelStart: 3}); + } else if (testsuite[i].name === '#164.1.simple-autolink' || testsuite[i].name === '#204.certain-links-with-at-and-dot-break-url') { + converter = new showdown.Converter({simplifiedAutoLink: true}); + } else if (testsuite[i].name === '#164.2.disallow-underscore-emphasis-mid-word') { + converter = new showdown.Converter({literalMidWordUnderscores: true}); + } else if (testsuite[i].name === '#164.3.strikethrough' || testsuite[i].name === '#214.escaped-markdown-chars-break-strikethrough') { + converter = new showdown.Converter({strikethrough: true}); + } else if (testsuite[i].name === 'disable-gh-codeblocks') { + converter = new showdown.Converter({ghCodeBlocks: false}); + } else if (testsuite[i].name === '#164.4.tasklists') { + converter = new showdown.Converter({tasklists: true}); + } else if (testsuite[i].name === '#198.literalMidWordUnderscores-changes-behavior-of-asterisk') { + converter = new showdown.Converter({literalMidWordUnderscores: true}); + } else if (testsuite[i].name === '#259.es6-template-strings-indentation-issues') { + converter = new showdown.Converter({smartIndentationFix: true}); + } else if (testsuite[i].name === '#284.simplifiedAutoLink-does-not-match-GFM-style') { + converter = new showdown.Converter({simplifiedAutoLink: true}); + } else if (testsuite[i].name === 'disableForced4SpacesIndentedSublists') { + converter = new showdown.Converter({disableForced4SpacesIndentedSublists: true}); + } else if (testsuite[i].name === '#206.treat-single-line-breaks-as-br') { + converter = new showdown.Converter({simpleLineBreaks: true}); + } else if (testsuite[i].name === 'simpleLineBreaks2') { + converter = new showdown.Converter({simpleLineBreaks: true}); + } else if (testsuite[i].name === '#316.new-simpleLineBreaks-option-breaks-lists') { + converter = new showdown.Converter({simpleLineBreaks: true}); + } else if (testsuite[i].name === '#323.simpleLineBreaks-breaks-with-strong') { + converter = new showdown.Converter({simpleLineBreaks: true}); + } else if (testsuite[i].name === '#318.simpleLineBreaks-does-not-work-with-chinese-characters') { + converter = new showdown.Converter({simpleLineBreaks: true}); + } else if (testsuite[i].name === 'simpleLineBreaks-handle-html-pre') { + converter = new showdown.Converter({simpleLineBreaks: true}); + } else if (testsuite[i].name === 'excludeTrailingPunctuationFromURLs-option') { + converter = new showdown.Converter({simplifiedAutoLink: true, excludeTrailingPunctuationFromURLs: true}); + } else if (testsuite[i].name === 'requireSpaceBeforeHeadingText') { + converter = new showdown.Converter({requireSpaceBeforeHeadingText: true}); + } else if (testsuite[i].name === '#320.github-compatible-generated-header-id') { + converter = new showdown.Converter({ghCompatibleHeaderId: true}); + } else if (testsuite[i].name === 'ghMentions') { + converter = new showdown.Converter({ghMentions: true}); + } else if (testsuite[i].name === 'disable-email-encoding') { + converter = new showdown.Converter({encodeEmails: false}); + } else if (testsuite[i].name === '#330.simplifiedAutoLink-drops-character-before-and-after-linked-mail') { + converter = new showdown.Converter({encodeEmails: false, simplifiedAutoLink: true}); + } else if (testsuite[i].name === '#331.allow-escaping-of-tilde') { + converter = new showdown.Converter({strikethrough: true}); + } else if (testsuite[i].name === 'prefixHeaderId-simple') { + converter = new showdown.Converter({prefixHeaderId: true}); + } else if (testsuite[i].name === 'prefixHeaderId-string') { + converter = new showdown.Converter({prefixHeaderId: 'my-prefix-'}); + } else if (testsuite[i].name === 'prefixHeaderId-string-and-ghCompatibleHeaderId') { + converter = new showdown.Converter({prefixHeaderId: 'my-prefix-', ghCompatibleHeaderId: true}); + } else if (testsuite[i].name === 'prefixHeaderId-string-and-ghCompatibleHeaderId2') { + converter = new showdown.Converter({prefixHeaderId: 'my prefix ', ghCompatibleHeaderId: true}); + } else if (testsuite[i].name === 'simplifiedAutoLink') { + converter = new showdown.Converter({simplifiedAutoLink: true, strikethrough: true}); + } else { + converter = new showdown.Converter(); + } + it(testsuite[i].name.replace(/-/g, ' '), assertion(testsuite[i], converter)); + } + }); + + // test Table Syntax Support describe('table support', function () { - var converter; - for (var i = 0; i < tableSuite.length; ++i) { - if (tableSuite[i].name === 'basic-with-header-ids') { + var converter, + suite = tableSuite; + for (var i = 0; i < suite.length; ++i) { + if (suite[i].name === 'basic-with-header-ids') { converter = new showdown.Converter({tables: true, tableHeaderId: true}); - } else if (tableSuite[i].name === '#179.parse-md-in-table-ths') { + } else if (suite[i].name === '#179.parse-md-in-table-ths') { converter = new showdown.Converter({tables: true, strikethrough: true}); } else { converter = new showdown.Converter({tables: true}); } - it(tableSuite[i].name.replace(/-/g, ' '), assertion(tableSuite[i], converter)); + it(suite[i].name.replace(/-/g, ' '), assertion(suite[i], converter)); + } + }); + + // test simplifiedAutoLink Support + describe('simplifiedAutoLink support in', function () { + var converter, + suite = simplifiedAutoLinkSuite; + for (var i = 0; i < suite.length; ++i) { + if (suite[i].name === 'emphasis-and-strikethrough') { + converter = new showdown.Converter({simplifiedAutoLink: true, strikethrough: true}); + } else if (suite[i].name === 'disallow-underscores') { + converter = new showdown.Converter({literalMidWordUnderscores: true, simplifiedAutoLink: true}); + } else { + converter = new showdown.Converter({simplifiedAutoLink: true}); + } + it(suite[i].name.replace(/-/g, ' '), assertion(suite[i], converter)); } });