Class: Markbridge::Parsers::BBCode::Handlers::UrlHandler

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

Overview

Handler for URL tags

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseHandler

#auto_closeable?, #on_close

Constructor Details

#initializeUrlHandler

Returns a new instance of UrlHandler.



9
10
11
# File 'lib/markbridge/parsers/bbcode/handlers/url_handler.rb', line 9

def initialize
  @element_class = AST::Url
end

Instance Attribute Details

#element_classObject (readonly)

Returns the value of attribute element_class.



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

def element_class
  @element_class
end

Instance Method Details

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



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

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