提交 1a73e986 编写于 作者: K Kevin Glowacz 提交者: Pratik Naik

Fix auto_link helper for already linked urls. [#72 state:resolved]

Signed-off-by: NPratik Naik <pratiknaik@gmail.com>
上级 cff2291d
...@@ -454,7 +454,7 @@ def set_cycle(name, cycle_object) ...@@ -454,7 +454,7 @@ def set_cycle(name, cycle_object)
( # leading text ( # leading text
<\w+.*?>| # leading HTML tag, or <\w+.*?>| # leading HTML tag, or
[^=!:'"/]| # leading punctuation, or [^=!:'"/]| # leading punctuation, or
| # nothing ^ # beginning of line
) )
( (
(?:https?://)| # protocol spec, or (?:https?://)| # protocol spec, or
...@@ -468,7 +468,7 @@ def set_cycle(name, cycle_object) ...@@ -468,7 +468,7 @@ def set_cycle(name, cycle_object)
(?:\?[\w\+@%&=.;-]+)? # query string (?:\?[\w\+@%&=.;-]+)? # query string
(?:\#[\w\-]*)? # trailing anchor (?:\#[\w\-]*)? # trailing anchor
) )
([[:punct:]]|\s|<|$) # trailing text ([[:punct:]]|<|$|) # trailing text
}x unless const_defined?(:AUTO_LINK_RE) }x unless const_defined?(:AUTO_LINK_RE)
# Turns all urls into clickable links. If a block is given, each url # Turns all urls into clickable links. If a block is given, each url
......
...@@ -264,6 +264,7 @@ def test_auto_linking ...@@ -264,6 +264,7 @@ def test_auto_linking
assert_equal '', auto_link(nil) assert_equal '', auto_link(nil)
assert_equal '', auto_link('') assert_equal '', auto_link('')
assert_equal "#{link_result} #{link_result} #{link_result}", auto_link("#{link_raw} #{link_raw} #{link_raw}") assert_equal "#{link_result} #{link_result} #{link_result}", auto_link("#{link_raw} #{link_raw} #{link_raw}")
assert_equal '<a href="http://www.rubyonrails.com">Ruby On Rails</a>', auto_link('<a href="http://www.rubyonrails.com">Ruby On Rails</a>')
end end
def test_auto_link_at_eol def test_auto_link_at_eol
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册