This project is archived and is in readonly mode.
auto_link should not create a link inside a link which has the rel attribute
-
Egor Baranov
The solution above does not solve auto_link_urls problem in such situation:
>> auto_link('<a href="http://google.com"><b>http://google.com</b></a>') => <a href="http://google.com"><b><a href="http://google.com">http://google.com</a></b></a>It's better to use a solution like in attached file
if (left =~ /<[^>]+$/ && right =~ /^[^>]*>/) || (right =~ LINK_CLOSE_TAG_RE && $` !~ LINK_OPEN_TAG_RE)We try to check if we are in the "A" tag already and if we are in it - do not create link from url.
-
Repository
- State changed from new to resolved
(from [17b4fd25e4de8f05d40ccaa776e51636745aa8e8]) avoid auto_linking already linked emails; more robust detection of linked URLs
References #1523 auto_link should not linkify URLs in the middle of a tag [#1862 Running autolink on text containing a mailto: link breaks state:resolved] [#3591 auto_link should not create a link inside a link which has the rel attribute state:resolved]
Add test that shows how link text can contain HTML if needed:
the trick is using block form in combination withraw.
Let link text be automatically HTML-escaped[#2017 Should not html_escape auto_link block form state:resolved] http://github.com/rails/rails/commit/17b4fd25e4de8f05d40ccaa776e516...
-
Repository
(from [8f0b2138ee979799092e0489f7298289c90901b9]) avoid auto_linking already linked emails; more robust detection of linked URLs
References #1523 auto_link should not linkify URLs in the middle of a tag [#1862 Running autolink on text containing a mailto: link breaks state:resolved] [#3591 auto_link should not create a link inside a link which has the rel attribute state:resolved]
Add test that shows how link text can contain HTML if needed:
the trick is using block form in combination withraw.
Let link text be automatically HTML-escaped[#2017 Should not html_escape auto_link block form state:resolved] http://github.com/rails/rails/commit/8f0b2138ee979799092e0489f72982...
