class CodeRay::Encoders::XML

def text_token text, kind

def text_token text, kind
  if kind == :space
    token = @node
  else
    token = @node.add_element kind.to_s
  end
  text.scan(/(\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