module Rouge
The containing module for Rouge
not required by the main lib. to use this module, require 'rouge/cli'.
automatically generated by `rake builtins:gherkin`
automatically generated by `rake builtins:lua`
automatically generated by `rake builtins:matlab`
automatically generated by `rake builtins:php`
DO NOT EDIT: automatically generated by `rake builtins:vim`. see tasks/vim.rake for more info.
this file is not require'd from the root. To use this plugin, run:
require 'rouge/plugins/redcarpet'
Public Class Methods
highlight(text, lexer, formatter, &b)
click to toggle source
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
# File lib/rouge.rb, line 18 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
version()
click to toggle source
# File lib/rouge/version.rb, line 3 def self.version "1.10.1" end