Răsfoiți Sursa

chore(): code style fix and tests fix due to code style changes

Estevão Soares dos Santos 10 ani în urmă
părinte
comite
79829dbbf1

Fișier diff suprimat deoarece este prea mare
+ 426 - 430
dist/showdown.js


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/showdown.js.map


Fișier diff suprimat deoarece este prea mare
+ 1 - 1
dist/showdown.min.js


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/showdown.min.js.map


+ 4 - 3
src/angular.js

@@ -9,9 +9,10 @@ if (typeof angular !== 'undefined' && typeof showdown !== 'undefined') {
   (function (module, showdown) {
     'use strict';
 
-    module.provider('$showdown', provider).directive('sdModelToHtml',
-                                                     ['$showdown', markdownToHtmlDirective]).filter('sdStripHtml',
-                                                                                                    stripHtmlFilter);
+    module
+      .provider('$showdown', provider)
+      .directive('sdModelToHtml',['$showdown', markdownToHtmlDirective])
+      .filter('sdStripHtml', stripHtmlFilter);
 
     /**
      * Angular Provider

+ 1 - 0
src/loader.js

@@ -11,6 +11,7 @@ if (typeof module !== 'undefined' && module.exports) {
 // AMD Loader
 else if (typeof define === 'function' && define.amd) {
   define('showdown', function () {
+    'use strict';
     return showdown;
   });
 }

+ 4 - 3
src/subParsers/autoLinks.js

@@ -5,7 +5,7 @@
 showdown.subParser('autoLinks', function (text) {
   'use strict';
 
-  text = text.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi, "<a href=\"$1\">$1</a>");
+  text = text.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi, '<a href=\"$1\">$1</a>');
 
   // Email addresses: <address@domain.foo>
 
@@ -19,9 +19,10 @@ showdown.subParser('autoLinks', function (text) {
    [-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+
    )
    >
-   /gi, _DoAutoLinks_callback());
+   /gi);
    */
-  text = text.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi, function (wholeMatch, m1) {
+  var pattern = /<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi;
+  text = text.replace(pattern, function (wholeMatch, m1) {
     var unescapedStr = showdown.subParser('unescapeSpecialChars')(m1);
     return showdown.subParser('encodeEmailAddress')(unescapedStr);
   });

+ 11 - 11
src/subParsers/codeBlocks.js

@@ -24,20 +24,20 @@ showdown.subParser('codeBlocks', function (text, options, globals) {
   // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
   text += '~0';
 
-  text = text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
-                      function (wholeMatch, m1, m2) {
-                        var codeblock = m1, nextChar = m2;
+  var pattern = /(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g;
+  text = text.replace(pattern, function (wholeMatch, m1, m2) {
+    var codeblock = m1, nextChar = m2;
 
-                        codeblock = showdown.subParser('outdent')(codeblock);
-                        codeblock = showdown.subParser('encodeCode')(codeblock);
-                        codeblock = showdown.subParser('detab')(codeblock);
-                        codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
-                        codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing whitespace
+    codeblock = showdown.subParser('outdent')(codeblock);
+    codeblock = showdown.subParser('encodeCode')(codeblock);
+    codeblock = showdown.subParser('detab')(codeblock);
+    codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
+    codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing whitespace
 
-                        codeblock = '<pre><code>' + codeblock + '\n</code></pre>';
+    codeblock = '<pre><code>' + codeblock + '\n</code></pre>';
 
-                        return showdown.subParser('hashBlock')(codeblock, options, globals) + nextChar;
-                      });
+    return showdown.subParser('hashBlock')(codeblock, options, globals) + nextChar;
+  });
 
   // attacklab: strip sentinel
   text = text.replace(/~0/, '');

+ 2 - 1
src/subParsers/detab.js

@@ -16,7 +16,8 @@ showdown.subParser('detab', function (text) {
 
   // use the sentinel to anchor our regex so it doesn't explode
   text = text.replace(/~B(.+?)~A/g, function (wholeMatch, m1) {
-    var leadingText = m1, numSpaces = 4 - leadingText.length % 4;  // g_tab_width
+    var leadingText = m1,
+        numSpaces = 4 - leadingText.length % 4;  // g_tab_width
 
     // there *must* be a better way to do this:
     for (var i = 0; i < numSpaces; i++) {

+ 0 - 1
src/subParsers/encodeCode.js

@@ -29,5 +29,4 @@ showdown.subParser('encodeCode', function (text) {
   // ---
 
   return text;
-
 });

+ 4 - 3
src/subParsers/encodeEmailAddress.js

@@ -23,9 +23,11 @@ showdown.subParser('encodeEmailAddress', function (addr) {
   var encode = [
     function (ch) {
       return '&#' + ch.charCodeAt(0) + ';';
-    }, function (ch) {
+    },
+    function (ch) {
       return '&#x' + ch.charCodeAt(0).toString(16) + ';';
-    }, function (ch) {
+    },
+    function (ch) {
       return ch;
     }
   ];
@@ -51,5 +53,4 @@ showdown.subParser('encodeEmailAddress', function (addr) {
   addr = addr.replace(/">.+:/g, '">'); // strip the mailto: from the visible part
 
   return addr;
-
 });

+ 3 - 1
src/subParsers/githubCodeBlocks.js

@@ -18,7 +18,9 @@ showdown.subParser('githubCodeBlocks', function (text, options, globals) {
   text += '~0';
 
   text = text.replace(/(?:^|\n)```(.*)\n([\s\S]*?)\n```/g, function (wholeMatch, m1, m2) {
-    var language = m1, codeblock = m2, end = '\n';
+    var language = m1,
+        codeblock = m2,
+        end = '\n';
 
     if (options.omitExtraWLInCodeBlocks) {
       end = '';

+ 8 - 10
src/subParsers/headers.js

@@ -15,17 +15,15 @@ showdown.subParser('headers', function (text, options, globals) {
   //	--------
   //
   text = text.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm, function (wholeMatch, m1) {
-    return showdown.subParser('hashBlock')('<h1 id="' + headerId(m1) + '">' + showdown.subParser('spanGamut')(m1,
-                                                                                                              options,
-                                                                                                              globals) + '</h1>',
-                                           options, globals);
+    var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
+        hashBlock = '<h1 id="' + headerId(m1) + '">' + spanGamut + '</h1>';
+    return showdown.subParser('hashBlock')(hashBlock, options, globals);
   });
 
   text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm, function (matchFound, m1) {
-    return showdown.subParser('hashBlock')('<h2 id="' + headerId(m1) + '">' + showdown.subParser('spanGamut')(m1,
-                                                                                                              options,
-                                                                                                              globals) + '</h2>',
-                                           options, globals);
+    var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
+        hashBlock = '<h2 id="' + headerId(m1) + '">' + spanGamut + '</h2>';
+    return showdown.subParser('hashBlock')(hashBlock, options, globals);
   });
 
   // atx-style headers:
@@ -48,8 +46,8 @@ showdown.subParser('headers', function (text, options, globals) {
    */
 
   text = text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm, function (wholeMatch, m1, m2) {
-    var span = showdown.subParser('spanGamut')(m2, options,
-                                               globals), header = '<h' + m1.length + ' id="' + headerId(m2) + '">' + span + '</h' + m1.length + '>';
+    var span = showdown.subParser('spanGamut')(m2, options, globals),
+        header = '<h' + m1.length + ' id="' + headerId(m2) + '">' + span + '</h' + m1.length + '>';
 
     return showdown.subParser('hashBlock')(header, options, globals);
   });

+ 6 - 1
src/subParsers/images.js

@@ -11,7 +11,12 @@ showdown.subParser('images', function (text, options, globals) {
   var writeImageTag = function (wholeMatch, m1, m2, m3, m4, m5, m6, m7) {
 
     wholeMatch = m1;
-    var altText = m2, linkId = m3.toLowerCase(), url = m4, title = m7, gUrls = globals.gUrls, gTitles = globals.gTitles;
+    var altText = m2,
+        linkId = m3.toLowerCase(),
+        url = m4,
+        title = m7,
+        gUrls = globals.gUrls,
+        gTitles = globals.gTitles;
 
     if (!title) {
       title = '';

+ 5 - 3
src/subParsers/lists.js

@@ -109,7 +109,8 @@ showdown.subParser('lists', function (text, options, globals) {
 
   if (globals.gListLevel) {
     text = text.replace(wholeList, function (wholeMatch, m1, m2) {
-      var list = m1, listType = (m2.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
+      var list = m1,
+          listType = (m2.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
 
       // Turn double returns into triple returns, so that we can make a
       // paragraph for the last item in a list, if necessary:
@@ -132,8 +133,9 @@ showdown.subParser('lists', function (text, options, globals) {
 
       // Turn double returns into triple returns, so that we can make a
       // paragraph for the last item in a list, if necessary:
-      var list = m2.replace(/\n{2,}/g,
-                            '\n\n\n'), listType = (m3.search(/[*+-]/g) > -1) ? 'ul' : 'ol', result = processListItems(list);
+      var list = m2.replace(/\n{2,}/g, '\n\n\n'),
+          listType = (m3.search(/[*+-]/g) > -1) ? 'ul' : 'ol',
+          result = processListItems(list);
 
       return m1 + '<' + listType + '>\n' + result + '</' + listType + '>\n';
     });

+ 17 - 16
src/subParsers/stripLinkDefinitions.js

@@ -30,25 +30,26 @@
 showdown.subParser('stripLinkDefinitions', function (text, options, globals) {
   'use strict';
 
+  var regex = /^[ ]{0,3}\[(.+)]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|(?=~0))/gm;
+
   // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
   text += '~0';
 
-  text = text.replace(/^[ ]{0,3}\[(.+)]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|(?=~0))/gm,
-                      function (wholeMatch, m1, m2, m3, m4) {
-                        m1 = m1.toLowerCase();
-                        globals.gUrls[m1] = showdown.subParser('encodeAmpsAndAngles')(m2);  // Link IDs are
-                                                                                            // case-insensitive
-                        if (m3) {
-                          // Oops, found blank lines, so it's not a title.
-                          // Put back the parenthetical statement we stole.
-                          return m3 + m4;
-                        } else if (m4) {
-                          globals.gTitles[m1] = m4.replace(/"/g, '&quot;');
-                        }
-
-                        // Completely remove the definition from the text
-                        return '';
-                      });
+  text = text.replace(regex, function (wholeMatch, m1, m2, m3, m4) {
+    m1 = m1.toLowerCase();
+    globals.gUrls[m1] = showdown.subParser('encodeAmpsAndAngles')(m2);  // Link IDs are case-insensitive
+    if (m3) {
+      // Oops, found blank lines, so it's not a title.
+      // Put back the parenthetical statement we stole.
+      return m3 + m4;
+
+    } else if (m4) {
+      globals.gTitles[m1] = m4.replace(/"/g, '&quot;');
+    }
+
+    // Completely remove the definition from the text
+    return '';
+  });
 
   // attacklab: strip sentinel
   text = text.replace(/~0/, '');

+ 1 - 1
test/cases/escaped-number-period.md

@@ -1 +1 @@
-It happened in 1986\.  What a great season.
+It happened in 1986\. What a great season.

+ 5 - 5
test/cases/horizontal-rules.html

@@ -1,9 +1,9 @@
-<hr/>
+<hr />
 
-<hr/>
+<hr />
 
-<hr/>
+<hr />
 
-<hr/>
+<hr />
 
-<hr/>
+<hr />

+ 1 - 2
test/cases/html5-strutural-tags.html

@@ -13,8 +13,7 @@
 <aside>ignore me</aside>
 
 <article>read
-  me
-</article>
+  me</article>
 
 <aside>
   ignore me

+ 3 - 3
test/cases/images.html

@@ -1,5 +1,5 @@
-<p><img src="/path/to/img.jpg" alt="Alt text" title=""/></p>
+<p><img src="/path/to/img.jpg" alt="Alt text" title="" /></p>
 
-<p><img src="/path/to/img.jpg" alt="Alt text" title="Optional title"/></p>
+<p><img src="/path/to/img.jpg" alt="Alt text" title="Optional title" /></p>
 
-<p><img src="url/to/image" alt="Alt text" title="Optional title attribute"/></p>
+<p><img src="url/to/image" alt="Alt text" title="Optional title attribute" /></p>

+ 1 - 2
test/cases/implicit-anchors.html

@@ -1,2 +1 @@
-<p>Search the web at <a href="http://google.com/">Google</a> or <a href="http://daringfireball.net/">Daring Fireball</a>.
-</p>
+<p>Search the web at <a href="http://google.com/">Google</a> or <a href="http://daringfireball.net/">Daring Fireball</a>.</p>

+ 1 - 3
test/cases/inline-style-tag.html

@@ -1,7 +1,5 @@
 <style>
-  p {
-    line-height: 20px;
-  }
+  p { line-height: 20px; }
 </style>
 
 <p>An exciting sentence.</p>

+ 1 - 2
test/cases/list-with-blockquote.html

@@ -4,6 +4,5 @@
     <blockquote>
       <p>This is a blockquote
         inside a list item.</p>
-    </blockquote>
-  </li>
+    </blockquote></li>
 </ul>

+ 1 - 2
test/cases/list-with-code.html

@@ -2,6 +2,5 @@
   <li><p>A list item with code:</p>
 
     <pre><code>alert('Hello world!');
-    </code></pre>
-  </li>
+    </code></pre></li>
 </ul>

+ 1 - 2
test/cases/multiline-unordered-list.html

@@ -1,6 +1,5 @@
 <ul>
   <li>This line spans
-    more than one line and is lazy
-  </li>
+    more than one line and is lazy</li>
   <li>Similar to this line</li>
 </ul>

+ 1 - 2
test/cases/url-with-parenthesis.html

@@ -1,2 +1 @@
-<p>There's an <a href="http://en.memory-alpha.org/wiki/Darmok_(episode)">episode</a> of Star Trek: The Next Generation
-</p>
+<p>There's an <a href="http://en.memory-alpha.org/wiki/Darmok_(episode)">episode</a> of Star Trek: The Next Generation</p>

+ 1 - 2
test/cases/url-with-parenthesis.md

@@ -1,2 +1 @@
-
-There's an [episode](http://en.memory-alpha.org/wiki/Darmok_(episode)) of Star Trek: The Next Generation
+There's an [episode](http://en.memory-alpha.org/wiki/Darmok_(episode)) of Star Trek: The Next Generation

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff