8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/coradoc/markdown/transform/table_transformer.rb', line 8
def transform_table(table)
= []
rows = []
table_rows = Array(table.rows)
if table_rows.any?
first_row = table_rows.first
first_row_cells = Array(first_row&.cells)
if first_row_cells.any?(&:header)
= first_row_cells.map(&:flat_text)
table_rows = table_rows[1..] || []
end
rows = table_rows.map do |row|
Array(row.cells).map(&:flat_text).join(' | ')
end
end
Coradoc::Markdown::Table.new(
headers: ,
rows: rows
)
end
|