Class: Markbridge::Parsers::TextFormatter::Handlers::SimpleHandler
- Inherits:
-
BaseHandler
- Object
- BaseHandler
- Markbridge::Parsers::TextFormatter::Handlers::SimpleHandler
- Defined in:
- lib/markbridge/parsers/text_formatter/handlers/simple_handler.rb
Overview
Handler for simple XML elements that don’t require attributes
This handler creates an AST node of the specified class and processes all child elements. Use this for simple formatting tags like B, I, U, S.
Instance Attribute Summary collapse
-
#element_class ⇒ Object
readonly
Returns the value of attribute element_class.
Instance Method Summary collapse
-
#initialize(element_class) ⇒ SimpleHandler
constructor
A new instance of SimpleHandler.
-
#process(element:, parent:) ⇒ Object
Process the element by creating an AST node and processing children.
Constructor Details
#initialize(element_class) ⇒ SimpleHandler
Returns a new instance of SimpleHandler.
17 18 19 |
# File 'lib/markbridge/parsers/text_formatter/handlers/simple_handler.rb', line 17 def initialize(element_class) @element_class = element_class end |
Instance Attribute Details
#element_class ⇒ Object (readonly)
Returns the value of attribute element_class.
32 33 34 |
# File 'lib/markbridge/parsers/text_formatter/handlers/simple_handler.rb', line 32 def element_class @element_class end |
Instance Method Details
#process(element:, parent:) ⇒ Object
Process the element by creating an AST node and processing children
24 25 26 27 28 29 30 |
# File 'lib/markbridge/parsers/text_formatter/handlers/simple_handler.rb', line 24 def process(element:, parent:) node = @element_class.new parent << node # Return node to signal: process children into this node node end |