Skip to content

Commit 4c26e47

Browse files
committed
Support irc-scheme hyperlinks. Issue #83
1 parent ac9e810 commit 4c26e47

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

History.rdoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Improved title for HTML output to include <code>--title</code> in the
77
title element.
88
* <code>rdoc --pipe</code> now understands <code>--markup</code>.
9+
* RDoc now supports irc-scheme hyperlinks. Issue #83 by trans.
910

1011
* Bug fixes
1112
* Fix title on HTML output for pages.

lib/rdoc/markup/to_html.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ def initialize markup = nil
7575
@th = nil
7676

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

8081
# internal links
8182
@markup.add_special(/rdoc-[a-z]+:\S+/, :RDOCLINK)

test/test_rdoc_markup_to_html.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,12 @@ def test_convert_string
389389
assert_equal '&lt;&gt;', @to.convert_string('<>')
390390
end
391391

392+
def test_convert_HYPERLINK_irc
393+
result = @to.convert 'irc://irc.freenode.net/#ruby-lang'
394+
395+
assert_equal "\n<p><a href=\"irc://irc.freenode.net/#ruby-lang\">irc.freenode.net/#ruby-lang</a></p>\n", result
396+
end
397+
392398
def test_convert_RDOCLINK_label_label
393399
result = @to.convert 'rdoc-label:label-One'
394400

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

428+
def test_convert_TIDYLINK_irc
429+
result = @to.convert '{ruby-lang}[irc://irc.freenode.net/#ruby-lang]'
430+
431+
assert_equal "\n<p><a href=\"irc://irc.freenode.net/#ruby-lang\">ruby-lang</a></p>\n", result
432+
end
433+
422434
def test_gen_url
423435
assert_equal '<a href="example">example</a>',
424436
@to.gen_url('link:example', 'example')
@@ -450,6 +462,14 @@ def test_handle_special_HYPERLINK_link
450462
assert_equal '<a href="README.txt">README.txt</a>', link
451463
end
452464

465+
def test_handle_special_HYPERLINK_irc
466+
special = RDoc::Markup::Special.new 0, 'irc://irc.freenode.net/#ruby-lang'
467+
468+
link = @to.handle_special_HYPERLINK special
469+
470+
assert_equal '<a href="irc://irc.freenode.net/#ruby-lang">irc.freenode.net/#ruby-lang</a>', link
471+
end
472+
453473
def test_list_verbatim_2
454474
str = "* one\n verb1\n verb2\n* two\n"
455475

0 commit comments

Comments
 (0)