Skip to content

Commit

Permalink
Support irc-scheme hyperlinks. Issue #83
Browse files Browse the repository at this point in the history
  • Loading branch information
drbrain committed Dec 14, 2011
1 parent ac9e810 commit 4c26e47
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions History.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Improved title for HTML output to include <code>--title</code> in the
title element.
* <code>rdoc --pipe</code> now understands <code>--markup</code>.
* RDoc now supports irc-scheme hyperlinks. Issue #83 by trans.

* Bug fixes
* Fix title on HTML output for pages.
Expand Down
3 changes: 2 additions & 1 deletion lib/rdoc/markup/to_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def initialize markup = nil
@th = nil

# external links
@markup.add_special(/((link:|https?:|mailto:|ftp:|www\.)\S+\w)/, :HYPERLINK)
@markup.add_special(/((link:|https?:|mailto:|ftp:|irc:|www\.)\S+\w)/,
:HYPERLINK)

# internal links
@markup.add_special(/rdoc-[a-z]+:\S+/, :RDOCLINK)
Expand Down
20 changes: 20 additions & 0 deletions test/test_rdoc_markup_to_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,12 @@ def test_convert_string
assert_equal '&lt;&gt;', @to.convert_string('<>')
end

def test_convert_HYPERLINK_irc
result = @to.convert 'irc://irc.freenode.net/#ruby-lang'

assert_equal "\n<p><a href=\"irc://irc.freenode.net/#ruby-lang\">irc.freenode.net/#ruby-lang</a></p>\n", result
end

def test_convert_RDOCLINK_label_label
result = @to.convert 'rdoc-label:label-One'

Expand Down Expand Up @@ -419,6 +425,12 @@ def test_convert_TIDYLINK_rdoc_label
assert_equal "\n<p><a href=\"#foottext-1\">foo</a></p>\n", result
end

def test_convert_TIDYLINK_irc
result = @to.convert '{ruby-lang}[irc://irc.freenode.net/#ruby-lang]'

assert_equal "\n<p><a href=\"irc://irc.freenode.net/#ruby-lang\">ruby-lang</a></p>\n", result
end

def test_gen_url
assert_equal '<a href="example">example</a>',
@to.gen_url('link:example', 'example')
Expand Down Expand Up @@ -450,6 +462,14 @@ def test_handle_special_HYPERLINK_link
assert_equal '<a href="README.txt">README.txt</a>', link
end

def test_handle_special_HYPERLINK_irc
special = RDoc::Markup::Special.new 0, 'irc://irc.freenode.net/#ruby-lang'

link = @to.handle_special_HYPERLINK special

assert_equal '<a href="irc://irc.freenode.net/#ruby-lang">irc.freenode.net/#ruby-lang</a>', link
end

def test_list_verbatim_2
str = "* one\n verb1\n verb2\n* two\n"

Expand Down

0 comments on commit 4c26e47

Please sign in to comment.