diff --git a/dist/showdown.js b/dist/showdown.js index dcdf75c..c111e93 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 a915d0b..65a4772 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 e4073af..789dcb7 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 6c89361..ca06c14 100644 Binary files a/dist/showdown.min.js.map and b/dist/showdown.min.js.map differ 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)); } });