# File lib/coderay/encoders/term.rb, line 98
98: def finish(options)
99: super
100: end
# File lib/coderay/encoders/term.rb, line 92
92: def setup(options)
93: @out = ''
94: @opened = [nil]
95: @subcolors = nil
96: end
# File lib/coderay/encoders/term.rb, line 102
102: def token text, type = :plain
103: case text
104:
105: when nil
106: # raise 'Token with nil as text was given: %p' % [[text, type]]
107:
108: when String
109:
110: if color = (@subcolors || TOKEN_COLORS)[type]
111: color = color[:self] || return if Hash === color
112:
113: @out << col(color) + text.gsub("\n", col(0) + "\n" + col(color)) + col(0)
114: @out << col(@subcolors[:self]) if @subcolors && @subcolors[:self]
115: else
116: @out << text
117: end
118:
119: # token groups, eg. strings
120: when :open
121: @opened[0] = type
122: if color = TOKEN_COLORS[type]
123: if Hash === color
124: @subcolors = color
125: @out << col(color[:self]) if color[:self]
126: else
127: @subcolors = {}
128: @out << col(color)
129: end
130: end
131: @opened << type
132: when :close
133: if @opened.empty?
134: # nothing to close
135: else
136: @out << col(0) if (@subcolors || {})[:self]
137: @subcolors = nil
138: @opened.pop
139: end
140:
141: # whole lines to be highlighted, eg. a added/modified/deleted lines in a diff
142: when :begin_line
143:
144: when :end_line
145:
146: else
147: raise 'unknown token kind: %p' % [text]
148: end
149: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.