Class: Markbridge::Parsers::BBCode::Handlers::SpoilerHandler

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

Overview

Handler for SPOILER tags Supports:

  • spoiler]text[/spoiler
  • spoiler=title]text[/spoiler
  • hide]text[/hide

    (alias for spoiler)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseHandler

#auto_closeable?, #on_close

Constructor Details

#initializeSpoilerHandler

Returns a new instance of SpoilerHandler.



13
14
15
# File 'lib/markbridge/parsers/bbcode/handlers/spoiler_handler.rb', line 13

def initialize
  @element_class = AST::Spoiler
end

Instance Attribute Details

#element_classObject (readonly)

Returns the value of attribute element_class.



23
24
25
# File 'lib/markbridge/parsers/bbcode/handlers/spoiler_handler.rb', line 23

def element_class
  @element_class
end

Instance Method Details

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



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

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