@@ -270,9 +270,9 @@ class Parser
270
270
@ makeHolder prefix + escaped
271
271
272
272
# link
273
- text = text .replace / <(https? :\/\/ . + )>/ ig , (matches ... ) =>
273
+ text = text .replace / <(https? :\/\/ . + | (?:mailto:) ? [_ a-z0-9 - \.\+ ] + @ [_ \w -] + \. [ a-z ] {2,} )>/ ig , (matches ... ) =>
274
274
url = @ cleanUrl matches[1 ]
275
- link = @ call ' parseLink' , matches[ 1 ]
275
+ link = @ call ' parseLink' , url
276
276
277
277
@ makeHolder " <a href=\" #{ url} \" >#{ link} </a>"
278
278
@@ -329,13 +329,13 @@ class Parser
329
329
330
330
# strong and em and some fuck
331
331
text = @ parseInlineCallback text
332
- text = text .replace / <([_a-z0-9 -\.\+ ] + @[^ @] + \. [a-z ] {2,} )>/ ig , ' <a href="mailto:$1">$1</a>'
333
332
334
333
# autolink url
335
334
if enableAutoLink
336
- text = text .replace / (^ | [^ \" ] )(https? :\/\/ (www\. )? [-a-zA-Z0-9 @:%. _\+ ~#=] {1,256} \. [a-zA-Z0-9 ()] {1,6} \b ([-a-zA-Z0-9 ()@:%_\+ . ~#?&\/ =] * ))($ | [^ \" ] )/ g , (matches ... ) =>
337
- link = @ call ' parseLink' , matches[2 ]
338
- " #{ matches[1 ]} <a href=\" #{ matches[2 ]} \" >#{ link} </a>#{ matches[5 ]} "
335
+ text = text .replace / (^ | [^ \" ] )(https? :\/\/ (www\. )? [-a-zA-Z0-9 @:%. _\+ ~#=] {1,256} \. [a-zA-Z0-9 ()] {1,6} \b ([-a-zA-Z0-9 ()@:%_\+ . ~#?&\/ =] * )| (?:mailto:)? [_a-z0-9 -\.\+ ] + @[_\w -] + \. [a-z ] {2,} )($ | [^ \" ] )/ g , (matches ... ) =>
336
+ url = @ cleanUrl matches[2 ]
337
+ link = @ call ' parseLink' , url
338
+ " #{ matches[1 ]} <a href=\" #{ link} \" >#{ matches[2 ]} </a>#{ matches[5 ]} "
339
339
340
340
text = @ call ' afterParseInlineBeforeRelease' , text
341
341
text = @ releaseHolder text, clearHolders
@@ -990,7 +990,10 @@ class Parser
990
990
cleanUrl : (url ) ->
991
991
url = url .replace / ["'<>\s ] / g , ' '
992
992
993
- return ' #' if (url .match / ^ \w + :/ i ) and not (url .match / ^ https? :/ i )
993
+ if !! (matches = url .match / ^ (mailto:)? [_a-z0-9 -\.\+ ] + @[_\w -] + \. [a-z ] {2,} $ / i )
994
+ url = ' mailto:' + url if not matches[1 ]?
995
+
996
+ return ' #' if (url .match / ^ \w + :/ i ) and not (url .match / ^ (https? | mailto):/ i )
994
997
995
998
url
996
999
0 commit comments