Included Modules

Files

Class Index [+]

Quicksearch

CodeRay::Encoders::XML

XML Encoder

Uses REXML. Very slow.

Constants

FILE_EXTENSION
DEFAULT_OPTIONS

Protected Instance Methods

close_token(kind) click to toggle source
    # File lib/coderay/encoders/xml.rb, line 61
61:     def close_token kind
62:       if @node == @root
63:         raise 'no token to close!'
64:       end
65:       @node = @node.parent
66:     end
finish(options) click to toggle source
    # File lib/coderay/encoders/xml.rb, line 31
31:     def finish options
32:       @out = ''
33:       @doc.write @out, options[:pretty], options[:transitive], true
34:       @out
35:     end
open_token(kind) click to toggle source
    # File lib/coderay/encoders/xml.rb, line 57
57:     def open_token kind
58:       @node = @node.add_element kind.to_s
59:     end
setup(options) click to toggle source
    # File lib/coderay/encoders/xml.rb, line 24
24:     def setup options
25:       @doc = REXML::Document.new
26:       @doc << REXML::XMLDecl.new
27:       @tab_width = options[:tab_width]
28:       @root = @node = @doc.add_element('coderay-tokens')
29:     end
text_token(text, kind) click to toggle source
    # File lib/coderay/encoders/xml.rb, line 37
37:     def text_token text, kind
38:       if kind == :space
39:         token = @node
40:       else
41:         token = @node.add_element kind.to_s
42:       end
43:       text.scan(/(\x20+)|(\t+)|(\n)|[^\x20\t\n]+/) do |space, tab, nl|
44:         case
45:         when space
46:           token << REXML::Text.new(space, true)
47:         when tab
48:           token << REXML::Text.new(tab, true)
49:         when nl
50:           token << REXML::Text.new(nl, true)
51:         else
52:           token << REXML::Text.new($&)
53:         end
54:       end
55:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.