Class: Sablon::HTMLConverter::Paragraph

Inherits:
Node
  • Object
show all
Defined in:
lib/sablon/html/ast.rb

Overview

An AST node representing the top level content container for a word document. These cannot be nested within other paragraph elements

Direct Known Subclasses

ListParagraph

Constant Summary collapse

PROPERTIES =
%w[framePr ind jc keepLines keepNext numPr
outlineLvl pBdr pStyle rPr sectPr shd spacing
tabs textAlignment].freeze
CHILD_TAGS =

Permitted child tags defined by the OpenXML spec

%w[w:bdo w:bookmarkEnd w:bookmarkStart w:commentRangeEnd
w:commentRangeStart w:customXml
w:customXmlDelRangeEnd w:customXmlDelRangeStart
w:customXmlInsRangeEnd w:customXmlInsRangeStart
w:customXmlMoveFromRangeEnd w:customXmlMoveFromRangeStart
w:customXmlMoveToRangeEnd w:customXmlMoveToRangeStart
w:del w:dir w:fldSimple w:hyperlink w:ins w:moveFrom
w:moveFromRangeEnd w:moveFromRangeStart w:moveTo
w:moveToRangeEnd w:moveToRangeStart m:oMath m:oMathPara
w:pPr w:proofErr w:r w:sdt w:smartTag]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

convert_style_property, node_name, process_properties, style_conversion

Constructor Details

#initialize(env, node, properties) ⇒ Paragraph

Returns a new instance of Paragraph.



175
176
177
178
179
180
181
182
183
# File 'lib/sablon/html/ast.rb', line 175

def initialize(env, node, properties)
  super
  properties = self.class.process_properties(properties)
  @properties = NodeProperties.paragraph(properties)
  #
  trans_props = transferred_properties
  @runs = ASTBuilder.html_to_ast(env, node.children, trans_props)
  @runs = Collection.new(@runs)
end

Instance Attribute Details

#runsObject

Returns the value of attribute runs.



157
158
159
# File 'lib/sablon/html/ast.rb', line 157

def runs
  @runs
end

Instance Method Details

#accept(visitor) ⇒ Object



189
190
191
192
# File 'lib/sablon/html/ast.rb', line 189

def accept(visitor)
  super
  runs.accept(visitor)
end

#inspectObject



194
195
196
# File 'lib/sablon/html/ast.rb', line 194

def inspect
  "<Paragraph{#{@properties[:pStyle]}}: #{runs.inspect}>"
end

#to_docxObject



185
186
187
# File 'lib/sablon/html/ast.rb', line 185

def to_docx
  super('w:p')
end