Class: Sablon::HTMLConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/sablon/html/ast.rb,
lib/sablon/html/visitor.rb,
lib/sablon/html/converter.rb,
lib/sablon/html/ast_builder.rb,
lib/sablon/html/node_properties.rb

Defined Under Namespace

Classes: ASTBuilder, Collection, GrepVisitor, Hyperlink, LastNewlineRemoverVisitor, List, ListParagraph, Newline, Node, NodeProperties, Paragraph, Root, Run, Table, TableCell, TableRow, Visitor

Instance Method Summary collapse

Instance Method Details

#build_ast(input) ⇒ Object



17
18
19
20
# File 'lib/sablon/html/converter.rb', line 17

def build_ast(input)
  doc = Nokogiri::HTML.fragment(input)
  Root.new(@env, doc)
end

#process(input, env) ⇒ Object



6
7
8
9
# File 'lib/sablon/html/converter.rb', line 6

def process(input, env)
  @env = env
  processed_ast(input).to_docx
end

#processed_ast(input) ⇒ Object



11
12
13
14
15
# File 'lib/sablon/html/converter.rb', line 11

def processed_ast(input)
  ast = build_ast(input)
  ast.accept LastNewlineRemoverVisitor.new
  ast
end