Class: Coradoc::Docx::Transform::Rules::TableRule

Inherits:
Coradoc::Docx::Transform::Rule show all
Includes:
OrderedContent
Defined in:
lib/coradoc/docx/transform/rules/table_rule.rb

Overview

Transforms w:tbl (Table) elements to CoreModel::Table.

Walks the OOXML table structure (Table → TableRow → TableCell) and produces the corresponding CoreModel tree.

Cell paragraphs are transformed through the rule system to preserve inline formatting (bold, italic, links) as InlineElement objects. Print-layout properties (frame, grid, width) are NOT mapped — CoreModel is a semantic model, not a print layout language.

Instance Method Summary collapse

Methods included from OrderedContent

#extract_plain_text, #transform_paragraph_content

Methods inherited from Coradoc::Docx::Transform::Rule

#priority

Instance Method Details

#apply(table, context) ⇒ Object



24
25
26
27
28
# File 'lib/coradoc/docx/transform/rules/table_rule.rb', line 24

def apply(table, context)
  CoreModel::Table.new(
    rows: table.rows.map { |r| transform_row(r, context) }
  )
end

#matches?(element) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/coradoc/docx/transform/rules/table_rule.rb', line 19

def matches?(element)
  defined?(Uniword::Wordprocessingml::Table) &&
    element.is_a?(Uniword::Wordprocessingml::Table)
end