lib/isodoc/word_function/table.rb in isodoc-2.5.1 vs lib/isodoc/word_function/table.rb in isodoc-2.5.2

- old
+ new

@@ -41,18 +41,25 @@ opt[:bordered] or ret = "" pb = keep_rows_together(cell, rowmax, totalrows, opt) ? "avoid" : "auto" "#{ret}page-break-after:#{pb};" end - def keep_rows_together(cell, rowmax, totalrows, opt) + def keep_rows_together(_cell, rowmax, totalrows, opt) opt[:header] and return true - table_line_count(cell.parent.parent) > 15 and return false + @table_line_count > 15 and return false (totalrows <= 10 && rowmax < totalrows) end + def tbody_parse(node, table) + tbody = node.at(ns("./tbody")) or return + @table_line_count = table_line_count(tbody) + super + end + def table_line_count(tbody) sum = 0 + tbody.xpath(ns(".//tr")).size > 15 and return 16 # short-circuit tbody.xpath(ns(".//tr")).each do |r| i = 1 r.xpath(ns(".//td | .//th")).each do |c| n = c.xpath(ns(".//li | .//p | .//br")).size n > i and i = n @@ -68,11 +75,12 @@ (%w(modspec).include?(c) || !c) or bordered = nil ret = { summary: node["summary"], width: node["width"], style: "mso-table-anchor-horizontal:column;mso-table-overlap:never;" \ "#{bordered}#{keep_style(node)}", - class: (node.text.length > 4000 ? "MsoISOTableBig" : "MsoISOTable") } + class: (node.text.length > 4000 ? "MsoISOTableBig" : "MsoISOTable") + } bordered or ret.delete(:class) super.merge(attr_code(ret)) end def colgroup(node, table) @@ -87,12 +95,11 @@ def table_parse(node, out) @in_table = true table_title_parse(node, out) out.div align: "center", class: "table_container" do |div| div.table **table_attrs(node) do |t| - table_parse_core(node, out) - (dl = node.at(ns("./dl"))) && parse(dl, out) - node.xpath(ns("./note")).each { |n| parse(n, out) } + table_parse_core(node, t) + table_parse_tail(node, t) end end @in_table = false end