module Rouge
def self.version
def self.version "1.3.2" end
def highlight(text, lexer, formatter, &b)
$stdout.print chunk
Rouge.highlight(large_string, 'ruby', 'html') do |chunk|
# streaming - chunks become available as they are lexed
Rouge.highlight('var foo = 1;', 'js', 'terminal256')
Rouge.highlight('@foo = 1', 'ruby', 'html')
@example
Highlight some text with a given lexer and formatter.
def highlight(text, lexer, formatter, &b) lexer = Lexer.find(lexer) unless lexer.respond_to? :lex raise "unknown lexer #{lexer}" unless lexer formatter = Formatter.find(formatter) unless formatter.respond_to? :format raise "unknown formatter #{formatter}" unless formatter formatter.format(lexer.lex(text), &b) end