Jelajahi Sumber

fix(githubMentions): githubMentions now works with openLinksInNewWindow options

githubMentions links can now be opened in new windows when using the option openLinksInNewWindow

Closes #403
Tobi 8 tahun lalu
induk
melakukan
1194d8803e
3 mengubah file dengan 8 tambahan dan 4 penghapusan
  1. 1 1
      CHANGELOG.md
  2. 1 1
      package.json
  3. 6 2
      src/subParsers/anchors.js

+ 1 - 1
CHANGELOG.md

@@ -10,7 +10,7 @@ Important HOTFIX
 
 
 <a name="1.7.0"></a>
-# [1.7.0](https://github.com/showdownjs/showdown/compare/1.6.4...1.7.0) (2017-06-01)
+## [1.7.0](https://github.com/showdownjs/showdown/compare/1.6.4...1.7.0) (2017-06-01)
 
 (DEPRECATED)
 

+ 1 - 1
package.json

@@ -55,7 +55,7 @@
     "quiet-grunt": "^0.2.3",
     "semver": "^5.0.0",
     "semver-sort": "0.0.4",
-    "sinon": "^1.14.1",
+    "sinon": "^2.3.3",
     "source-map-support": "^0.4.15"
   },
   "dependencies": {

+ 6 - 2
src/subParsers/anchors.js

@@ -82,8 +82,12 @@ showdown.subParser('anchors', function (text, options, globals) {
       if (!showdown.helper.isString(options.ghMentionsLink)) {
         throw new Error('ghMentionsLink option must be a string');
       }
-      var lnk = options.ghMentionsLink.replace(/\{u}/g, username);
-      return st + '<a href="' + lnk + '">' + mentions + '</a>';
+      var lnk = options.ghMentionsLink.replace(/\{u}/g, username),
+          target = '';
+      if (options.openLinksInNewWindow) {
+        target = ' target="¨E95Eblank"';
+      }
+      return st + '<a href="' + lnk + '"' + target + '>' + mentions + '</a>';
     });
   }