Class: Markbridge::Parsers::HTML::Handlers::ImageHandler
- Inherits:
-
BaseHandler
- Object
- BaseHandler
- Markbridge::Parsers::HTML::Handlers::ImageHandler
- Defined in:
- lib/markbridge/parsers/html/handlers/image_handler.rb
Overview
Handler for <img> tags
Instance Attribute Summary collapse
-
#element_class ⇒ Object
readonly
Returns the value of attribute element_class.
Instance Method Summary collapse
-
#initialize ⇒ ImageHandler
constructor
A new instance of ImageHandler.
- #process(element:, parent:) ⇒ Object
Constructor Details
#initialize ⇒ ImageHandler
Returns a new instance of ImageHandler.
9 10 11 |
# File 'lib/markbridge/parsers/html/handlers/image_handler.rb', line 9 def initialize @element_class = AST::Image end |
Instance Attribute Details
#element_class ⇒ Object (readonly)
Returns the value of attribute element_class.
25 26 27 |
# File 'lib/markbridge/parsers/html/handlers/image_handler.rb', line 25 def element_class @element_class end |
Instance Method Details
#process(element:, parent:) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/markbridge/parsers/html/handlers/image_handler.rb', line 13 def process(element:, parent:) src = element["src"] width = sanitize_dimension(element["width"]) height = sanitize_dimension(element["height"]) ast_element = AST::Image.new(src:, width:, height:) parent << ast_element # Return nil to signal: don't process children (void element) nil end |