mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
feat(ghMentionsLink): add ability to define the generated url in @mentions
This option enables users to define the generated links in @mentions. For instance, with ghMentionsOption set to `//mysite.com/{u}/profile` this text `@tivie` will result in this link `<a href="//mysite.com/tivie/profile">@tivie</a>`
This commit is contained in:
parent
dbf876b6cb
commit
a4c24c9805
|
@ -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)
|
* **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 `<a href="//mysite.com/tivie/profile">@tivie</a>`
|
||||||
|
|
||||||
* **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)
|
* **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.
|
NOTE: Prior to version 1.6.1, emails would always be obfuscated through dec and hex encoding.
|
||||||
|
|
BIN
dist/showdown.js
vendored
BIN
dist/showdown.js
vendored
Binary file not shown.
BIN
dist/showdown.js.map
vendored
BIN
dist/showdown.js.map
vendored
Binary file not shown.
BIN
dist/showdown.min.js
vendored
BIN
dist/showdown.min.js
vendored
Binary file not shown.
BIN
dist/showdown.min.js.map
vendored
BIN
dist/showdown.min.js.map
vendored
Binary file not shown.
|
@ -106,6 +106,11 @@ function getDefaultOpts(simple) {
|
||||||
description: 'Enables github @mentions',
|
description: 'Enables github @mentions',
|
||||||
type: 'boolean'
|
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: {
|
encodeEmails: {
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
description: 'Encode e-mail addresses through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities',
|
description: 'Encode e-mail addresses through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities',
|
||||||
|
|
|
@ -73,7 +73,13 @@ showdown.subParser('anchors', function (text, options, globals) {
|
||||||
if (escape === '\\') {
|
if (escape === '\\') {
|
||||||
return st + mentions;
|
return st + mentions;
|
||||||
}
|
}
|
||||||
return st + '<a href="https://www.github.com/' + username + '">' + mentions + '</a>';
|
|
||||||
|
//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 + '<a href="' + lnk + '">' + mentions + '</a>';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<p>hello <a href="https://www.github.com/tivie">@tivie</a> how are you?</p>
|
<p>hello <a href="https://github.com/tivie">@tivie</a> how are you?</p>
|
||||||
<p>this email foo@gmail.com is not parsed</p>
|
<p>this email foo@gmail.com is not parsed</p>
|
||||||
<p>this @mentions is not parsed also</p>
|
<p>this @mentions is not parsed also</p>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user