Class: Gorgyrella::Formatters::Coderay
- Inherits:
-
Object
- Object
- Gorgyrella::Formatters::Coderay
- Defined in:
- lib/gorgyrella/formatters/coderay.rb
Class Method Summary collapse
-
.highlight(text, lexer, format) ⇒ Object
Will silently ignore unknown lexers, will raise an error if unknown format called.
- .resolve_format(format, parent_filename = nil, first_line = 0) ⇒ Object
- .resolve_lexer(file, language = nil, sample_text = "") ⇒ Object
Class Method Details
.highlight(text, lexer, format) ⇒ Object
Will silently ignore unknown lexers, will raise an error if unknown format called.
10 11 12 |
# File 'lib/gorgyrella/formatters/coderay.rb', line 10 def self.highlight(text, lexer, format) CodeRay.scan(text, lexer.to_sym).send(format.to_sym) end |
.resolve_format(format, parent_filename = nil, first_line = 0) ⇒ Object
22 23 24 |
# File 'lib/gorgyrella/formatters/coderay.rb', line 22 def self.resolve_format(format, parent_filename = nil, first_line = 0) format || 'html' end |
.resolve_lexer(file, language = nil, sample_text = "") ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/gorgyrella/formatters/coderay.rb', line 14 def self.resolve_lexer(file, language = nil, sample_text = "") if language language else CodeRay::FileType.fetch(file, :plaintext, true) end end |