lib/rouge/formatter.rb in rouge-0.2.8 vs lib/rouge/formatter.rb in rouge-0.2.9

- old
+ new

@@ -17,16 +17,21 @@ def self.find(tag) REGISTRY[tag] end # Format a token stream. Delegates to {#format}. - def self.format(tokens, opts={}) - new(opts).format(tokens) + def self.format(tokens, opts={}, &b) + new(opts).format(tokens, &b) end # Format a token stream. - def format(tokens) - enum_for(:stream, tokens).to_a.join + def format(tokens, &b) + return stream(tokens, &b) if block_given? + + out = '' + stream(tokens) { |piece| out << piece } + + out end # @deprecated Use {#format} instead. def render(tokens) warn 'Formatter#render is deprecated, use #format instead.'