Skip to content

Commit

Permalink
fix(openLinksInNewWindow): encode _ to prevent clash with em
Browse files Browse the repository at this point in the history
Closes #379
  • Loading branch information
tivie committed Apr 25, 2017
1 parent 71acff5 commit 813f832
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 9 deletions.
7 changes: 4 additions & 3 deletions dist/showdown.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/showdown.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/showdown.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.min.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/subParsers/anchors.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ showdown.subParser('anchors', function (text, options, globals) {
}

if (options.openLinksInNewWindow) {
result += ' target="_blank"';
// escaped _
result += ' target="¨E95Eblank"';
}

result += '>' + linkText + '</a>';
Expand Down
2 changes: 1 addition & 1 deletion src/subParsers/autoLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -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 changes: 3 additions & 0 deletions test/features/#379.openLinksInNewWindow-breaks-em-markdup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
My [link](http://example.com) is _important_

My [link](http://example.com) is __important__
2 changes: 2 additions & 0 deletions test/node/testsuite.features.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 813f832

Please sign in to comment.