# File lib/coderay/encoders/xml.rb, line 58 def begin_group kind @node = @node.add_element kind.to_s end
# File lib/coderay/encoders/xml.rb, line 62 def end_group kind if @node == @root raise 'no token to close!' end @node = @node.parent end
# File lib/coderay/encoders/xml.rb, line 38 def text_token text, kind if kind == :space token = @node else token = @node.add_element kind.to_s end text.scan(%r(\x20+)|(\t+)|(\n)|[^\x20\t\n]+/) do |space, tab, nl| case when space token << REXML::Text.new(space, true) when tab token << REXML::Text.new(tab, true) when nl token << REXML::Text.new(nl, true) else token << REXML::Text.new($&) end end end
# File lib/coderay/encoders/xml.rb, line 31 def finish options @doc.write @out, options[:pretty], options[:transitive], true super end
# File lib/coderay/encoders/xml.rb, line 22 def setup options super @doc = REXML::Document.new @doc << REXML::XMLDecl.new @tab_width = options[:tab_width] @root = @node = @doc.add_element('coderay-tokens') end