Class: Markbridge::Parsers::BBCode::Handlers::SpoilerHandler
- Inherits:
-
BaseHandler
- Object
- BaseHandler
- Markbridge::Parsers::BBCode::Handlers::SpoilerHandler
- 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
-
#element_class ⇒ Object
readonly
Returns the value of attribute element_class.
Instance Method Summary collapse
-
#initialize ⇒ SpoilerHandler
constructor
A new instance of SpoilerHandler.
- #on_open(token:, context:, registry:, tokens: nil) ⇒ Object
Methods inherited from BaseHandler
Constructor Details
#initialize ⇒ SpoilerHandler
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_class ⇒ Object (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 |