diff options
author | Sean McGivern <sean@gitlab.com> | 2018-03-23 18:51:28 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2018-03-23 18:51:28 +0300 |
commit | 058dd193603910efb12cba84339474e3e8778c31 (patch) | |
tree | 2b94f1cc5e98bddc2f69a8afc4a8550f235883d7 /lib/banzai | |
parent | b06a44c4ea85b813c0e6497ad801c3367abbf973 (diff) |
Add ?, !, and : to trailing puncutation excluded from auto-linking
Diffstat (limited to 'lib/banzai')
-rw-r--r-- | lib/banzai/filter/autolink_filter.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/banzai/filter/autolink_filter.rb b/lib/banzai/filter/autolink_filter.rb index 75b64ae9af2..ce401c1c31c 100644 --- a/lib/banzai/filter/autolink_filter.rb +++ b/lib/banzai/filter/autolink_filter.rb @@ -21,12 +21,13 @@ module Banzai # # See http://en.wikipedia.org/wiki/URI_scheme # - # The negative lookbehind ensures that users can paste a URL followed by a - # period or comma for punctuation without those characters being included - # in the generated link. + # The negative lookbehind ensures that users can paste a URL followed by + # punctuation without those characters being included in the generated + # link. It matches the behaviour of Rinku 2.0.1: + # https://github.com/vmg/rinku/blob/v2.0.1/ext/rinku/autolink.c#L65 # - # Rubular: http://rubular.com/r/JzPhi6DCZp - LINK_PATTERN = %r{([a-z][a-z0-9\+\.-]+://[^\s>]+)(?<!,|\.)} + # Rubular: http://rubular.com/r/nrL3r9yUiq + LINK_PATTERN = %r{([a-z][a-z0-9\+\.-]+://[^\s>]+)(?<!\?|!|\.|,|:)} # Text matching LINK_PATTERN inside these elements will not be linked IGNORE_PARENTS = %w(a code kbd pre script style).to_set |