mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
Making sure we don't create a link if the @username or #hashtag is already in a markdown link []
This commit is contained in:
parent
d07daced6b
commit
bc4089e5c2
@ -14,9 +14,9 @@
|
||||
return [
|
||||
|
||||
// @username syntax
|
||||
{ type: 'lang', regex: '\\B(\\\\)?@([\\S]+)\\b', replace: function(match, leadingSlash, username) {
|
||||
// Check if we matched the leading \ and return nothing changed if so
|
||||
if (leadingSlash === '\\') {
|
||||
{ type: 'lang', regex: '\\B(.)?@([\\S]+)\\b', replace: function(match, leading, username) {
|
||||
// Check if we matched the leading \ or [ and return nothing changed if so
|
||||
if (['\\','['].indexOf(leading) > -1) {
|
||||
return match;
|
||||
} else {
|
||||
return '<a href="http://twitter.com/' + username + '">@' + username + '</a>';
|
||||
@ -24,9 +24,9 @@
|
||||
}},
|
||||
|
||||
// #hashtag syntax
|
||||
{ type: 'lang', regex: '\\B(\\\\)?#([\\S]+)\\b', replace: function(match, leadingSlash, tag) {
|
||||
// Check if we matched the leading \ and return nothing changed if so
|
||||
if (leadingSlash === '\\') {
|
||||
{ type: 'lang', regex: '\\B(\\\\)?#([\\S]+)\\b', replace: function(match, leading, tag) {
|
||||
// Check if we matched the leading \ or [ and return nothing changed if so
|
||||
if (['\\','['].indexOf(leading) > -1) {
|
||||
return match;
|
||||
} else {
|
||||
return '<a href="http://twitter.com/search/%23' + tag + '">#' + tag + '</a>';
|
||||
|
Loading…
x
Reference in New Issue
Block a user