diff --git a/README.md b/README.md index 8ab5dc1..0ba88d5 100644 --- a/README.md +++ b/README.md @@ -294,6 +294,9 @@ var defaultOptions = showdown.getDefaultOptions(); * **ghMentions**: (boolean) [default false] Enables github @mentions, which link to the username mentioned (since v1.6.0) + * **ghMentionsLink**: (string) [default `https://github.com/{u}`] Changes the link generated by @mentions. Showdown will replace `{u}` with the username. Only applies if ghMentions option is enabled. + Example: `@tivie` with ghMentionsOption set to `//mysite.com/{u}/profile` will result in `@tivie` + * **encodeEmails**: (boolean) [default true] Enables e-mail addresses encoding through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities. (since v1.6.1) NOTE: Prior to version 1.6.1, emails would always be obfuscated through dec and hex encoding. diff --git a/dist/showdown.js b/dist/showdown.js index 93de282..bfbd144 100644 Binary files a/dist/showdown.js and b/dist/showdown.js differ diff --git a/dist/showdown.js.map b/dist/showdown.js.map index 5845a3a..827e8f5 100644 Binary files a/dist/showdown.js.map and b/dist/showdown.js.map differ diff --git a/dist/showdown.min.js b/dist/showdown.min.js index 8e0fdac..032659c 100644 Binary files a/dist/showdown.min.js and b/dist/showdown.min.js differ diff --git a/dist/showdown.min.js.map b/dist/showdown.min.js.map index edd7aa0..c92d706 100644 Binary files a/dist/showdown.min.js.map and b/dist/showdown.min.js.map differ diff --git a/src/options.js b/src/options.js index 87705f8..828b6db 100644 --- a/src/options.js +++ b/src/options.js @@ -106,6 +106,11 @@ function getDefaultOpts(simple) { description: 'Enables github @mentions', type: 'boolean' }, + ghMentionsLink: { + defaultValue: 'https://github.com/{u}', + description: 'Changes the link generated by @mentions. Only applies if ghMentions option is enabled.', + type: 'string' + }, encodeEmails: { defaultValue: true, description: 'Encode e-mail addresses through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities', diff --git a/src/subParsers/anchors.js b/src/subParsers/anchors.js index decc458..341dd87 100644 --- a/src/subParsers/anchors.js +++ b/src/subParsers/anchors.js @@ -73,7 +73,13 @@ showdown.subParser('anchors', function (text, options, globals) { if (escape === '\\') { return st + mentions; } - return st + '' + mentions + ''; + + //check if options.ghMentionsLink is a string + 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 + '' + mentions + ''; }); } diff --git a/test/features/ghMentions.html b/test/features/ghMentions.html index d342cbe..4ee52c5 100644 --- a/test/features/ghMentions.html +++ b/test/features/ghMentions.html @@ -1,3 +1,3 @@ -

hello @tivie how are you?

+

hello @tivie how are you?

this email foo@gmail.com is not parsed

this @mentions is not parsed also