Class: Markbridge::Parsers::BBCode::Handlers::SizeHandler

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

Overview

Handler for SIZE tags Supports:

  • size=20]text[/size
  • size=large]text[/size

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseHandler

#on_close

Constructor Details

#initializeSizeHandler

Returns a new instance of SizeHandler.



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

def initialize
  @element_class = AST::Size
end

Instance Attribute Details

#element_classObject (readonly)

Returns the value of attribute element_class.



26
27
28
# File 'lib/markbridge/parsers/bbcode/handlers/size_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/size_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/size_handler.rb', line 16

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