class RDoc::Markup::AttributeManager
Manages changes of attributes in a block of text
Constants
- NULL
The NUL character
Attributes
The attributes enabled for this markup object.
A bits of exclusive maps
This maps delimiters that occur around words (such as bold or tt
) where the start and end delimiters and the same. This lets us optimize the regexp
A \ in front of a character that would normally be processed turns off processing. We do this by turning < into <#{PROTECT}
And this maps _regexp handling_ sequences to a name. A regexp handling sequence is something like a WikiWord
And this is used when the delimiters aren’t the same. In this case the hash maps a pattern to the attribute character
Public Class Methods
Creates a new attribute manager that understands bold, emphasized and teletype text.
# File rdoc/markup/attribute_manager.rb, line 80 def initialize @html_tags = {} @matching_word_pairs = {} @protectable = %w[<] @regexp_handlings = [] @word_pair_map = {} @exclusive_bitmap = 0 @attributes = RDoc::Markup::Attributes.new add_word_pair "*", "*", :BOLD, true add_word_pair "_", "_", :EM, true add_word_pair "+", "+", :TT, true add_html "em", :EM, true add_html "i", :EM, true add_html "b", :BOLD, true add_html "tt", :TT, true add_html "code", :TT, true end
Public Instance Methods
Return an attribute object with the given turn_on and turn_off bits set
# File rdoc/markup/attribute_manager.rb, line 103 def attribute(turn_on, turn_off) RDoc::Markup::AttrChanger.new turn_on, turn_off end
Changes the current attribute from current
to new
# File rdoc/markup/attribute_manager.rb, line 110 def change_attribute current, new diff = current ^ new attribute(new & diff, current & diff) end
Used by the tests to change attributes by name from current_set
to new_set
# File rdoc/markup/attribute_manager.rb, line 119 def changed_attribute_by_name current_set, new_set current = new = 0 current_set.each do |name| current |= @attributes.bitmap_for(name) end new_set.each do |name| new |= @attributes.bitmap_for(name) end change_attribute(current, new) end
Copies start_pos
to end_pos
from the current string
# File rdoc/markup/attribute_manager.rb, line 135 def copy_string(start_pos, end_pos) res = @str[start_pos...end_pos] res.gsub!(/\000/, '') res end