Class: Markbridge::Parsers::HTML::Handlers::UrlHandler

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

Overview

Handler for <a> tags

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeUrlHandler

Returns a new instance of UrlHandler.



9
10
11
# File 'lib/markbridge/parsers/html/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.



22
23
24
# File 'lib/markbridge/parsers/html/handlers/url_handler.rb', line 22

def element_class
  @element_class
end

Instance Method Details

#process(element:, parent:) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/markbridge/parsers/html/handlers/url_handler.rb', line 13

def process(element:, parent:)
  href = element["href"]
  ast_element = AST::Url.new(href:)
  parent << ast_element

  # Return element to signal: process children into this element (link text)
  ast_element
end