Skip to content

Commit

Permalink
Support YARD style {http://... title} links when using markdown
Browse files Browse the repository at this point in the history
provider that performs URL autolinking.

Closes #353
  • Loading branch information
lsegal committed Jun 14, 2011
1 parent 598dd8c commit 3384953
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/yard/templates/helpers/html_helper.rb
Expand Up @@ -180,6 +180,11 @@ def resolve_links(text)
next(match[1..-1]) if escape

next(match) if name[0,1] == '|'

if name == '<a' && title =~ /href=["'](.+?)["'].*>.*<\/a>\s*(.+?)\Z/
name, title = $1, $2
end

if object.is_a?(String)
object
else
Expand Down
11 changes: 10 additions & 1 deletion spec/templates/helpers/html_helper_spec.rb
Expand Up @@ -128,7 +128,16 @@ def options; {} end
log.enter_level(Logger::FATAL) do
pending 'This test depends on markdown' unless markup_class(:markdown)
end
htmlify('http://example.com', :markdown).should include('<a href="http://example.com"')
htmlify('http://example.com', :markdown).chomp.should ==
'<p><a href="http://example.com">http://example.com</a></p>'
end

it "should not autolink URLs inside of {} (markdown specific)" do
log.enter_level(Logger::FATAL) do
pending 'This test depends on markdown' unless markup_class(:markdown)
end
htmlify('{http://example.com Title}', :markdown).chomp.should =~
%r{<p><a href="http://example.com".*>Title</a></p>}
end
end

Expand Down

0 comments on commit 3384953

Please sign in to comment.