Class: Sablon::HTMLConverter::Root
- Inherits:
-
Collection
- Object
- Node
- Collection
- Sablon::HTMLConverter::Root
- Defined in:
- lib/sablon/html/ast.rb
Overview
Stores all of the AST nodes from the current fragment of HTML being parsed
Constant Summary
Constants inherited from Node
Instance Attribute Summary
Attributes inherited from Collection
Instance Method Summary collapse
- #grep(pattern) ⇒ Object
-
#initialize(env, node) ⇒ Root
constructor
A new instance of Root.
- #inspect ⇒ Object
Methods inherited from Collection
Methods inherited from Node
#accept, convert_style_property, node_name, process_properties, style_conversion, #to_docx
Constructor Details
#initialize(env, node) ⇒ Root
Returns a new instance of Root.
131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/sablon/html/ast.rb', line 131 def initialize(env, node) # strip text nodes from the root level element, these are typically # extra whitespace from indenting the markup if there are any # block level tags at the top level if ASTBuilder.(node.children) node.search('./text()').remove end # convert children from HTML to AST nodes super(ASTBuilder.html_to_ast(env, node.children, {})) end |
Instance Method Details
#grep(pattern) ⇒ Object
143 144 145 146 147 |
# File 'lib/sablon/html/ast.rb', line 143 def grep(pattern) visitor = GrepVisitor.new(pattern) accept(visitor) visitor.result end |
#inspect ⇒ Object
149 150 151 |
# File 'lib/sablon/html/ast.rb', line 149 def inspect "<Root: #{super}>" end |