class Sablon::HTMLConverter::Hyperlink
Creates a clickable URL in the word document, this only supports external urls only
Public Class Methods
new(env, node, properties)
click to toggle source
Calls superclass method
Sablon::HTMLConverter::Node::new
# File lib/sablon/html/ast.rb, line 529 def initialize(env, node, properties) super # properties are passed directly to runs because hyperlink nodes # don't have a corresponding property tag like runs or paragraphs. @runs = ASTBuilder.html_to_ast(env, node.children, properties) @runs = Collection.new(@runs) @target = node.attributes['href'].value # rel_attr = { Type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', Target: @target, TargetMode: 'External' } rid = env.document.add_relationship(rel_attr) @attributes = { 'r:id' => rid } end
Public Instance Methods
accept(visitor)
click to toggle source
Calls superclass method
Sablon::HTMLConverter::Node#accept
# File lib/sablon/html/ast.rb, line 554 def accept(visitor) super @runs.accept(visitor) end
inspect()
click to toggle source
# File lib/sablon/html/ast.rb, line 550 def inspect "<Hyperlink{target:#{@target}}: #{@runs.inspect}>" end
to_docx()
click to toggle source
Calls superclass method
Sablon::HTMLConverter::Node#to_docx
# File lib/sablon/html/ast.rb, line 546 def to_docx super('w:hyperlink') end
Private Instance Methods
children_to_docx()
click to toggle source
# File lib/sablon/html/ast.rb, line 561 def children_to_docx @runs.to_docx end