|
@@ -102,6 +102,11 @@ function getDefaultOpts(simple) {
|
|
|
defaultValue: false,
|
|
|
description: 'Makes adding a space between `#` and the header text mandatory (GFM Style)',
|
|
|
type: 'boolean'
|
|
|
+ },
|
|
|
+ ghMentions: {
|
|
|
+ defaultValue: false,
|
|
|
+ description: 'Enables github @mentions',
|
|
|
+ type: 'boolean'
|
|
|
}
|
|
|
};
|
|
|
if (simple === false) {
|
|
@@ -152,7 +157,8 @@ var showdown = {},
|
|
|
disableForced4SpacesIndentedSublists: true,
|
|
|
simpleLineBreaks: true,
|
|
|
requireSpaceBeforeHeadingText: true,
|
|
|
- ghCompatibleHeaderId: true
|
|
|
+ ghCompatibleHeaderId: true,
|
|
|
+ ghMentions: true
|
|
|
},
|
|
|
vanilla: getDefaultOpts(true),
|
|
|
allOn: allOptionsOn()
|
|
@@ -1206,11 +1212,16 @@ showdown.subParser('anchors', function (text, options, globals) {
|
|
|
text = text.replace(/(\[((?:\[[^\]]*]|[^\[\]])*)]\([ \t]*()<?(.*?(?:\(.*?\).*?)?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,
|
|
|
writeAnchorTag);
|
|
|
|
|
|
- // Last, handle reference-style shortcuts: [link text]
|
|
|
+ // handle reference-style shortcuts: [link text]
|
|
|
// These must come last in case you've also got [link test][1]
|
|
|
// or [link test](/foo)
|
|
|
text = text.replace(/(\[([^\[\]]+)])()()()()()/g, writeAnchorTag);
|
|
|
|
|
|
+ // Lastly handle GithubMentions if option is enabled
|
|
|
+ if (options.ghMentions) {
|
|
|
+ text = text.replace(/(^|\s)(@([a-z\d\-]+))(?=[.!?;,[\]()]|\s|$)/gmi, '$1<a href="https://www.github.com/$3">$2</a>');
|
|
|
+ }
|
|
|
+
|
|
|
text = globals.converter._dispatch('anchors.after', text, options, globals);
|
|
|
return text;
|
|
|
});
|
|
@@ -1601,6 +1612,7 @@ showdown.subParser('escapeSpecialCharsWithinTagAttributes', function (text) {
|
|
|
return text;
|
|
|
});
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* Handle github codeblocks prior to running HashHTML so that
|
|
|
* HTML contained within the codeblock gets escaped properly
|