From 8aa895294b8d696489b51a5e69b2986f452da905 Mon Sep 17 00:00:00 2001 From: drbrain Date: Sat, 5 Feb 2011 06:20:57 +0000 Subject: Import RDoc 3.5.2 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rdoc/markup/to_html.rb | 144 +++++++++++++++++++-------------------------- 1 file changed, 62 insertions(+), 82 deletions(-) (limited to 'lib/rdoc/markup/to_html.rb') diff --git a/lib/rdoc/markup/to_html.rb b/lib/rdoc/markup/to_html.rb index d587a8abbc..599f3713f1 100644 --- a/lib/rdoc/markup/to_html.rb +++ b/lib/rdoc/markup/to_html.rb @@ -10,6 +10,8 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter include RDoc::Text + # :section: Utilities + ## # Maps RDoc::Markup::Parser::LIST_TOKENS types to HTML tags @@ -55,6 +57,8 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter File.join(*from) end + # :section: + ## # Creates a new formatter that will output HTML @@ -75,54 +79,21 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter init_tags end - ## - # Maps attributes to HTML tags - - def init_tags - add_tag :BOLD, "", "" - add_tag :TT, "", "" - add_tag :EM, "", "" - end + # :section: Special Handling + # + # These methods handle special markup added by RDoc::Markup#add_special. ## - # Generate a hyperlink for +url+, labeled with +text+. Handles the special - # cases for img: and link: described under handle_special_HYPERLINK - - def gen_url(url, text) - if url =~ /([A-Za-z]+):(.*)/ then - type = $1 - path = $2 - else - type = "http" - path = url - url = "http://#{url}" - end - - if type == "link" then - url = if path[0, 1] == '#' then # is this meaningful? - path - else - self.class.gen_relative_url @from_path, path - end - end - - if (type == "http" or type == "link") and - url =~ /\.(gif|png|jpg|jpeg|bmp)$/ then - "" - else - "#{text.sub(%r{^#{type}:/*}, '')}" - end - end - - # :section: Special handling - - ## - # And we're invoked with a potential external hyperlink. mailto: - # just gets inserted. http: links are checked to see if they - # reference an image. If so, that image gets inserted using an - # tag. Otherwise a conventional is used. - # We also support a special type of hyperlink, link:, which is a - # reference to a local file whose path is relative to the --op directory. + # +special+ is a potential hyperlink. The following schemes are handled: + # + # mailto::: + # Inserted as-is. + # http::: + # Links are checked to see if they reference an image. If so, that image + # gets inserted using an tag. Otherwise a conventional + # is used. + # link::: + # Reference to a local file relative to the output directory. def handle_special_HYPERLINK(special) url = special.text @@ -130,8 +101,8 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter end ## - # Here's a hyperlink where the label is different to the URL - # #{text.sub(%r{^#{type}:/*}, '')}" + end + end + ## # Determines the HTML list element for +list_type+ and +open_tag+ @@ -299,6 +270,15 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter tags[open_tag ? 0 : 1] end + ## + # Maps attributes to HTML tags + + def init_tags + add_tag :BOLD, "", "" + add_tag :TT, "", "" + add_tag :EM, "", "" + end + ## # Returns the HTML tag for +list_type+, possible using a label from # +list_item+ -- cgit v1.2.3