Преглед на файлове

test: add several testcases

Estevao Soares dos Santos преди 8 години
родител
ревизия
1bca88f8fa

+ 29 - 11
dist/showdown.js

@@ -1,4 +1,4 @@
-;/*! showdown 31-03-2017 */
+;/*! showdown 23-04-2017 */
 (function(){
 /**
  * Created by Tivie on 13-07-2015.
@@ -53,6 +53,11 @@ function getDefaultOpts (simple) {
       describe: 'Parse midword underscores as literal underscores',
       type: 'boolean'
     },
+    literalMidWordAsterisks: {
+      defaultValue: false,
+      describe: 'Parse midword asterisks as literal asterisks',
+      type: 'boolean'
+    },
     strikethrough: {
       defaultValue: false,
       describe: 'Turn on/off strikethrough support',
@@ -2240,16 +2245,29 @@ showdown.subParser('italicsAndBold', function (text, options, globals) {
   }
 
   // Now parse asterisks
-  text = text.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g, function (wm, m) {
-    return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm;
-  });
-  text = text.replace(/\*\*(\S[\s\S]*?)\*\*/g, function (wm, m) {
-    return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : 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)) ? parseInside (m, '<em>', '</em>') : wm;
-  });
+  if (options.literalMidWordAsterisks) {
+    text = text.trim().replace(/(?:^| +)\*{3}(\S[\s\S]*?)\*{3}(?: +|$)/g, function (wm, txt) {
+      return parseInside (txt, ' <strong><em>', '</em></strong> ');
+    });
+    text = text.trim().replace(/(?:^| +)\*{2}(\S[\s\S]*?)\*{2}(?: +|$)/g, function (wm, txt) {
+      return parseInside (txt, ' <strong>', '</strong> ');
+    });
+    text = text.trim().replace(/(?:^| +)\*{1}(\S[\s\S]*?)\*{1}(?: +|$)/g, function (wm, txt) {
+      return parseInside (txt, ' <em>', '</em>' + (wm.slice(-1) === ' ' ? ' ' : ''));
+    });
+  } else {
+    text = text.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g, function (wm, m) {
+      return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm;
+    });
+    text = text.replace(/\*\*(\S[\s\S]*?)\*\*/g, function (wm, m) {
+      return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : 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)) ? parseInside (m, '<em>', '</em>') : wm;
+    });
+  }
+
 
   text = globals.converter._dispatch('italicsAndBold.after', text, options, globals);
   return text;

Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
dist/showdown.js.map


Файловите разлики са ограничени, защото са твърде много
+ 1 - 1
dist/showdown.min.js


Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
dist/showdown.min.js.map


+ 0 - 0
test/features/disableForced4SpacesIndentedSublists/.gitkeep


+ 2 - 0
test/features/openLinksInNewWindow/simple-cases.html

@@ -0,0 +1,2 @@
+<p><a href="www.google.com" target="_blank">foo</a></p>
+<p>a link <a href="http://www.google.com" target="_blank">http://www.google.com</a></p>

+ 3 - 0
test/features/openLinksInNewWindow/simple-cases.md

@@ -0,0 +1,3 @@
+[foo](www.google.com)
+
+a link <http://www.google.com>

+ 8 - 8
test/issues/#183.gh-code-blocks-within-lists-do-not-render-properly.md

@@ -1,17 +1,17 @@
 1. Hi, I am a thing
 
-   ```sh
+    ```sh
     
-   $ git clone thing.git
+    $ git clone thing.git
    
-   dfgdfg
-   ```
+    dfgdfg
+    ```
 
 1. I am another thing!
 
-   ```sh
+    ```sh
    
-   $ git clone other-thing.git
+    $ git clone other-thing.git
 
-   foobar
-   ```
+    foobar
+    ```

+ 12 - 1
test/node/testsuite.features.js

@@ -7,7 +7,8 @@ var bootstrap = require('../bootstrap.js'),
     testsuite = bootstrap.getTestSuite('test/features/'),
     tableSuite = bootstrap.getTestSuite('test/features/tables/'),
     simplifiedAutoLinkSuite = bootstrap.getTestSuite('test/features/simplifiedAutoLink/'),
-    openLinksInNewWindowSuite = bootstrap.getTestSuite('test/features/openLinksInNewWindow/');
+    openLinksInNewWindowSuite = bootstrap.getTestSuite('test/features/openLinksInNewWindow/'),
+    disableForced4SpacesIndentedSublistsSuite = bootstrap.getTestSuite('test/features/disableForced4SpacesIndentedSublists/');
 
 describe('makeHtml() features testsuite', function () {
   'use strict';
@@ -129,4 +130,14 @@ describe('makeHtml() features testsuite', function () {
       it(suite[i].name.replace(/-/g, ' '), assertion(suite[i], converter));
     }
   });
+
+  // test disableForced4SpacesIndentedSublists support
+  describe('disableForced4SpacesIndentedSublists support in', function () {
+    var converter,
+        suite = disableForced4SpacesIndentedSublistsSuite;
+    for (var i = 0; i < suite.length; ++i) {
+      converter = new showdown.Converter({disableForced4SpacesIndentedSublists: true});
+      it(suite[i].name.replace(/-/g, ' '), assertion(suite[i], converter));
+    }
+  });
 });

Някои файлове не бяха показани, защото твърде много файлове са промени