145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
# File 'lib/nandoc/support/stream-colorizer.rb', line 145
def process string, out
ret = nil
while line = next_line(string)
if other = rule_list.detect{|x| x.match(string)}
next_state_name = other.state
ret = next_state_name
break
else
next_line(string, true)
use_line = nil
if @trailing_whitespace_style
/\A(|.*[^[:space:]])([[:space:]]*)\Z/ =~ line or fail('oops')
head, tail = $1, $2
colored_head = colorize(head, *colors)
use_line = colored_head.dup
unless tail.empty?
ws_style = parent.stylesheet[@trailing_whitespace_style] or
style_not_found_failure('@trailing_whitespace_style')
colored_tail = colorize(tail, *ws_style)
use_line.concat colored_tail
end
else
use_line = colorize(line, *colors)
end
out.puts use_line
end
end
ret
end
|