Class: CabbageDoc::Highlighter
- Inherits:
-
Object
- Object
- CabbageDoc::Highlighter
- Defined in:
- lib/cabbage_doc/highlighter.rb
Instance Attribute Summary collapse
-
#formatter ⇒ Object
Returns the value of attribute formatter.
-
#lexers ⇒ Object
Returns the value of attribute lexers.
Instance Method Summary collapse
- #format(text, type = 'txt') ⇒ Object
-
#initialize(options = {}) ⇒ Highlighter
constructor
A new instance of Highlighter.
Constructor Details
#initialize(options = {}) ⇒ Highlighter
Returns a new instance of Highlighter.
7 8 9 10 |
# File 'lib/cabbage_doc/highlighter.rb', line 7 def initialize( = {}) self.formatter = Rouge::Formatters::HTMLLegacy.new({ css_class: 'highlight' }.merge()) self.lexers = {} end |
Instance Attribute Details
#formatter ⇒ Object
Returns the value of attribute formatter.
5 6 7 |
# File 'lib/cabbage_doc/highlighter.rb', line 5 def formatter @formatter end |
#lexers ⇒ Object
Returns the value of attribute lexers.
5 6 7 |
# File 'lib/cabbage_doc/highlighter.rb', line 5 def lexers @lexers end |
Instance Method Details
#format(text, type = 'txt') ⇒ Object
12 13 14 |
# File 'lib/cabbage_doc/highlighter.rb', line 12 def format(text, type = 'txt') formatter.format(find_lexer(text, type).lex(text)) end |