Skip to content

Commit

Permalink
[gfm] use new extended email autolink rule to avoid autolinking email…
Browse files Browse the repository at this point in the history
… addresses in code spans (fixes markedjs#1218)
  • Loading branch information
Feder1co5oave committed Sep 18, 2018
1 parent 44b23eb commit 1904ca0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,9 +605,8 @@ inline.pedantic = merge({}, inline.normal, {

inline.gfm = merge({}, inline.normal, {
escape: edit(inline.escape).replace('])', '~|])').getRegex(),
url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/)
.replace('email', inline._email)
.getRegex(),
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
del: /^~+(?=\S)([\s\S]*?\S)~+/,
text: edit(inline.text)
Expand All @@ -616,6 +615,9 @@ inline.gfm = merge({}, inline.normal, {
.getRegex()
});

inline.gfm.url = edit(inline.gfm.url)
.replace('email', inline.gfm._extended_email)
.getRegex();
/**
* GFM + Line Breaks Inline Grammar
*/
Expand Down

0 comments on commit 1904ca0

Please sign in to comment.