class Rouge::CLI
def highlight(file=nil)
def highlight(file=nil) filename = options[:file] || file source = filename ? File.read(filename) : $stdin.read if options[:lexer].nil? lexer_class = Lexer.guess( :filename => filename, :mimetype => options[:mimetype], :source => source, ) else lexer_class = Lexer.find(options[:lexer]) raise "unknown lexer: #{options[:lexer]}" unless lexer_class end formatter_class = Formatter.find(options[:formatter]) # only HTML is supported for now formatter = formatter_class.new(normalize_hash_keys(options[:formatter_opts])) lexer = lexer_class.new(normalize_hash_keys(options[:lexer_opts])) puts Rouge.highlight(source, lexer, formatter) end