Class: Markbridge::Parsers::BBCode::Handlers::ColorHandler

Inherits:
BaseHandler
  • Object
show all
Defined in:
lib/markbridge/parsers/bbcode/handlers/color_handler.rb

Overview

Handler for COLOR tags Supports:

  • color=red]text[/color
  • color=#FF0000]text[/color

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseHandler

#on_close

Constructor Details

#initializeColorHandler

Returns a new instance of ColorHandler.



12
13
14
# File 'lib/markbridge/parsers/bbcode/handlers/color_handler.rb', line 12

def initialize
  @element_class = AST::Color
end

Instance Attribute Details

#element_classObject (readonly)

Returns the value of attribute element_class.



26
27
28
# File 'lib/markbridge/parsers/bbcode/handlers/color_handler.rb', line 26

def element_class
  @element_class
end

Instance Method Details

#auto_closeable?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/markbridge/parsers/bbcode/handlers/color_handler.rb', line 22

def auto_closeable?
  true
end

#on_open(token:, context:, registry:, tokens: nil) ⇒ Object



16
17
18
19
20
# File 'lib/markbridge/parsers/bbcode/handlers/color_handler.rb', line 16

def on_open(token:, context:, registry:, tokens: nil)
  color = token.attrs[:color] || token.attrs[:option]
  element = AST::Color.new(color:)
  context.push(element, token:)
end