Browse Source

fix(openLinksInNewWindow): encode _ to prevent clash with em

Closes #379
Estevao Soares dos Santos 8 years ago
parent
commit
813f832160

+ 4 - 3
dist/showdown.js

@@ -1,4 +1,4 @@
-;/*! showdown 23-04-2017 */
+;/*! showdown 25-04-2017 */
 (function(){
 /**
  * Created by Tivie on 13-07-2015.
@@ -1358,7 +1358,8 @@ showdown.subParser('anchors', function (text, options, globals) {
     }
 
     if (options.openLinksInNewWindow) {
-      result += ' target="_blank"';
+      // escaped _
+      result += ' target="¨E95Eblank"';
     }
 
     result += '>' + linkText + '</a>';
@@ -1421,7 +1422,7 @@ var simpleURLRegex  = /\b(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+)()(
           append = trailingPunctuation;
         }
         if (options.openLinksInNewWindow) {
-          target = ' target="_blank"';
+          target = ' target="¨E95Eblank"';
         }
         return '<a href="' + link + '"' + target + '>' + lnkTxt + '</a>' + append;
       };

File diff suppressed because it is too large
+ 0 - 0
dist/showdown.js.map


File diff suppressed because it is too large
+ 1 - 1
dist/showdown.min.js


File diff suppressed because it is too large
+ 0 - 0
dist/showdown.min.js.map


+ 2 - 1
src/subParsers/anchors.js

@@ -51,7 +51,8 @@ showdown.subParser('anchors', function (text, options, globals) {
     }
 
     if (options.openLinksInNewWindow) {
-      result += ' target="_blank"';
+      // escaped _
+      result += ' target="¨E95Eblank"';
     }
 
     result += '>' + linkText + '</a>';

+ 1 - 1
src/subParsers/autoLinks.js

@@ -21,7 +21,7 @@ var simpleURLRegex  = /\b(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+)()(
           append = trailingPunctuation;
         }
         if (options.openLinksInNewWindow) {
-          target = ' target="_blank"';
+          target = ' target="¨E95Eblank"';
         }
         return '<a href="' + link + '"' + target + '>' + lnkTxt + '</a>' + append;
       };

+ 2 - 0
test/features/#379.openLinksInNewWindow-breaks-em-markdup.html

@@ -0,0 +1,2 @@
+<p>My <a href="http://example.com" target="_blank">link</a> is <em>important</em></p>
+<p>My <a href="http://example.com" target="_blank">link</a> is <strong>important</strong></p>

+ 3 - 0
test/features/#379.openLinksInNewWindow-breaks-em-markdup.md

@@ -0,0 +1,3 @@
+My [link](http://example.com) is _important_
+
+My [link](http://example.com) is __important__

+ 2 - 0
test/node/testsuite.features.js

@@ -78,6 +78,8 @@ describe('makeHtml() features testsuite', function () {
         converter = new showdown.Converter({simplifiedAutoLink: true, strikethrough: true});
       } else if (testsuite[i].name === '#378.simplifiedAutoLinks-with-excludeTrailingPunctuationFromURLs') {
         converter = new showdown.Converter({simplifiedAutoLink: true, excludeTrailingPunctuationFromURLs: true});
+      } else if (testsuite[i].name === '#379.openLinksInNewWindow-breaks-em-markdup') {
+        converter = new showdown.Converter({openLinksInNewWindow: true});
       } else {
         converter = new showdown.Converter();
       }

Some files were not shown because too many files changed in this diff