Class: Rabbit::Parser::Ext::CodeRay::RabbitEncoder
- Inherits:
-
CodeRay::Encoders::Encoder
- Object
- CodeRay::Encoders::Encoder
- Rabbit::Parser::Ext::CodeRay::RabbitEncoder
- Includes:
- Element
- Defined in:
- lib/rabbit/parser/ext/coderay.rb
Instance Method Summary collapse
- #begin_group(kind) ⇒ Object
- #begin_line(kind) ⇒ Object
- #end_group(kind) ⇒ Object
- #end_line(kind) ⇒ Object
- #finish(options) ⇒ Object
- #setup(options) ⇒ Object
- #text_token(text, type = :plain) ⇒ Object
Instance Method Details
#begin_group(kind) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/rabbit/parser/ext/coderay.rb', line 36 def begin_group(kind) p [:begin_group, kind] if Utils.syntax_highlighting_debug? @containers << TextContainer.new tag = CustomTag.new("syntax-#{kind}") current_container << tag end |
#begin_line(kind) ⇒ Object
43 44 45 |
# File 'lib/rabbit/parser/ext/coderay.rb', line 43 def begin_line(kind) p [:begin_line, kind] if Utils.syntax_highlighting_debug? end |
#end_group(kind) ⇒ Object
51 52 53 54 55 |
# File 'lib/rabbit/parser/ext/coderay.rb', line 51 def end_group(kind) p [:end_group, kind] if Utils.syntax_highlighting_debug? block = @containers.pop current_container << block end |
#end_line(kind) ⇒ Object
47 48 49 |
# File 'lib/rabbit/parser/ext/coderay.rb', line 47 def end_line(kind) p [:end_line, kind] if Utils.syntax_highlighting_debug? end |
#finish(options) ⇒ Object
57 58 59 |
# File 'lib/rabbit/parser/ext/coderay.rb', line 57 def finish() super end |
#setup(options) ⇒ Object
21 22 23 24 25 |
# File 'lib/rabbit/parser/ext/coderay.rb', line 21 def setup() super @out = SyntaxHighlightingBlock.new @containers = [@out] end |
#text_token(text, type = :plain) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/rabbit/parser/ext/coderay.rb', line 27 def text_token(text, type=:plain) p [:text, type, text] if Utils.syntax_highlighting_debug? escaped_text = Escape.(text) text_element = SyntaxHighlightingText.new(Text.new(escaped_text)) tag_name = type.to_s.gsub(/_/, '-') tag = CustomTag.new("syntax-#{tag_name}", text_element) current_container << tag end |