vendor/bundle/ruby/2.1.0/gems/rugments-1.0.0.beta3/lib/rugments.rb
# Highlight some text with a given lexer and formatter.
#
# @example
#   Rouge.highlight('@foo = 1', 'ruby', 'html')
#   Rouge.highlight('var foo = 1;', 'js', 'terminal256')
#
#   # streaming - chunks become available as they are lexed
#   Rouge.highlight(large_string, 'ruby', 'html') do |chunk|
#     $stdout.print chunk
#   end
Highlight some text with a given lexer and formatter.
Highlight some text with a given lexer and formatter .
def highlight(text, lexer, formatter, &b)
    lexer = Lexer.find(lexer) unless lexer.respond_to?(:lex)
    fail "unknown lexer #{lexer}" unless lexer
    formatter = Formatter.find(formatter) unless formatter.respond_to?(:format)
    fail "unknown formatter #{formatter}" unless formatter
    formatter.format(lexer.lex(text), &b)
  end
def highlight ( text , lexer , formatter , & b ) lexer = Lexer . find ( lexer ) unless lexer . respond_to? ( :lex ) fail "unknown lexer #{lexer}" unless lexer formatter = Formatter . find ( formatter ) unless formatter . respond_to? ( :format ) fail "unknown formatter #{formatter}" unless formatter formatter . format ( lexer . lex ( text ) , & b ) end
Highlight some text with a given lexer and formatter.
Highlight some text with a given lexer and formatter .
text
lexer
formatter
b
example
Rouge.highlight('@foo = 1', 'ruby', 'html') Rouge.highlight('var foo = 1;', 'js', 'terminal256') # streaming - chunks become available as they are lexed Rouge.highlight(large_string, 'ruby', 'html') do |chunk| $stdout.print chunk end
Rouge . highlight ( ' @foo = 1 ' ' ruby ' ' html ' ) Rouge . highlight ( ' var foo = 1 ; ' ' js ' ' terminal256 ' ) # streaming - chunks become available as they are lexed Rouge . highlight ( large_string ' ruby ' ' html ' ) do |chunk| $stdout . print chunk end