From 455b051a008aa859a7b0d6fca56de69a38cc1f8d Mon Sep 17 00:00:00 2001 From: drbrain Date: Sun, 10 Feb 2008 03:59:08 +0000 Subject: * lib/rdoc/code_objects.rb: Make some attributes accessible for reuse. * lib/rdoc/generator/html.rb: Pull out ContextUser classes and related methods for reuse. * lib/rdoc/generator.rb: Move ContextUser classes to RDoc::Generator::Context for reuse. * lib/rdoc/rdoc.rb: Make RDoc::RDoc initialization a little easier. * lib/rdoc/options.rb: Make RDoc::Options easier to use without parsing an ARGV. * lib/rdoc/markup/to_*.rb: Subclass RDoc::Markup::Formatter. * lib/rdoc/markup/formatter.rb: Add RDoc::Markup::Formatter to make RDoc markup conversion easier. * lib/rdoc/markup/fragments.rb: Make RDoc::Markup::ListItem easier to test. * lib/rdoc/markup/to_html_hyperlink.rb: Pulled out of the HTML generator for easier reusability. * lib/rdoc/markup.rb: Fix bug with labeled lists containing bullet lists. * lib/rdoc/generators/html/html.rb: Fix Constant display. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rdoc/markup/inline.rb | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'lib/rdoc/markup/inline.rb') diff --git a/lib/rdoc/markup/inline.rb b/lib/rdoc/markup/inline.rb index cbf5032a68..8945e14b83 100644 --- a/lib/rdoc/markup/inline.rb +++ b/lib/rdoc/markup/inline.rb @@ -12,9 +12,9 @@ class RDoc::Markup @@name_to_bitmap = { :_SPECIAL_ => SPECIAL } @@next_bitmap = 2 - def Attribute.bitmap_for(name) + def self.bitmap_for(name) bitmap = @@name_to_bitmap[name] - if !bitmap + unless bitmap then bitmap = @@next_bitmap @@next_bitmap <<= 1 @@name_to_bitmap[name] = bitmap @@ -22,7 +22,7 @@ class RDoc::Markup bitmap end - def Attribute.as_string(bitmap) + def self.as_string(bitmap) return "none" if bitmap.zero? res = [] @@name_to_bitmap.each do |name, bit| @@ -31,7 +31,7 @@ class RDoc::Markup res.join(",") end - def Attribute.each_name_of(bitmap) + def self.each_name_of(bitmap) @@name_to_bitmap.each do |name, bit| next if bit == SPECIAL yield name.to_s if (bitmap & bit) != 0 @@ -85,14 +85,15 @@ class RDoc::Markup self.text == o.text && self.type == o.type end - def to_s - "Special: type=#{type}, name=#{RDoc::Markup::Attribute.as_string type}, text=#{text.dump}" - end - def inspect "#" % [ object_id, @type, RDoc::Markup::Attribute.as_string(type), text.dump] end + + def to_s + "Special: type=#{type}, name=#{RDoc::Markup::Attribute.as_string type}, text=#{text.dump}" + end + end class AttributeManager @@ -165,8 +166,10 @@ class RDoc::Markup def convert_attrs(str, attrs) # first do matching ones tags = MATCHING_WORD_PAIRS.keys.join("") + re = "(^|\\W)([#{tags}])([A-Za-z_]+?)\\2(\\W|\$)" # re = "(^|\\W)([#{tags}])(\\S+?)\\2(\\W|\$)" + 1 while str.gsub!(Regexp.new(re)) { attr = MATCHING_WORD_PAIRS[$2]; attrs.set_attrs($`.length + $1.length + $2.length, $3.length, attr) @@ -185,9 +188,9 @@ class RDoc::Markup end def convert_html(str, attrs) - tags = HTML_TAGS.keys.join("|") - re = "<(#{tags})>(.*?)" - 1 while str.gsub!(Regexp.new(re, Regexp::IGNORECASE)) { + tags = HTML_TAGS.keys.join '|' + + 1 while str.gsub!(/<(#{tags})>(.*?)<\/\1>/i) { attr = HTML_TAGS[$1.downcase] html_length = $1.length + 2 seq = NULL * html_length @@ -210,7 +213,7 @@ class RDoc::Markup # A \ in front of a character that would normally be processed turns off # processing. We do this by turning \< into <#{PROTECT} - PROTECTABLE = [ "<" << "\\" ] #" + PROTECTABLE = [ "<" << "\\" ] def mask_protected_sequences @@ -300,7 +303,6 @@ class RDoc::Markup end def split_into_flow - display_attributes if $DEBUG_RDOC res = [] -- cgit v1.2.3