Skip to content

Commit

Permalink
Updated auto-link markup fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitrij Denissenko committed Feb 7, 2010
1 parent 1467ab2 commit 33c22cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions config/initializers/b.patches/auto_link.rb
Expand Up @@ -14,7 +14,8 @@ def auto_link_urls(text, html_options = {})
href
else
# ADDED - START
if href.sub!(/&\w+;$/, '')
href.sub!(/&/, '&')
if href.sub!(/&(quot|lt|gt);.*$/, '')
punctuation = $&
end
# ADDED - END
Expand All @@ -30,7 +31,7 @@ def auto_link_urls(text, html_options = {})
link_text = block_given?? yield(href) : href
href = 'http://' + href unless href.index('http') == 0

content_tag(:a, h(link_text), link_attributes.merge('href' => href)) + punctuation
content_tag(:a, escape_once(link_text), link_attributes.merge('href' => href)) + punctuation
end
end
end
Expand Down
3 changes: 3 additions & 0 deletions spec/helpers/format_helper_spec.rb
Expand Up @@ -182,7 +182,10 @@ def do_find
it 'should corretly auto-link in code-blocks' do
helper.markup(%({{{\n<a href="http://retrospectiva.org/wiki/Retrospectiva" />\n}}})).
should == %(<pre><code>&lt;a href=&quot;<a href="http://retrospectiva.org/wiki/Retrospectiva">http://retrospectiva.org/wiki/Retrospectiva</a>&quot; /&gt;\n</code></pre>)
helper.markup(%({{{\n<scheduler>http://retrospectiva.org/wiki/Retrospectiva?a=1&amp;b=2</scheduler>\n}}})).
should == %(<pre><code>&lt;scheduler&gt;<a href="http://retrospectiva.org/wiki/Retrospectiva?a=1&amp;b=2">http://retrospectiva.org/wiki/Retrospectiva?a=1&amp;b=2</a>&lt;/scheduler&gt;\n</code></pre>)
end


end

Expand Down

0 comments on commit 33c22cf

Please sign in to comment.