Module: IsoDoc::WordFunction::Body
- Included in:
- IsoDoc::WordConvert
- Defined in:
- lib/isodoc/word_function/body.rb,
lib/isodoc/word_function/lists.rb,
lib/isodoc/word_function/table.rb,
lib/isodoc/word_function/inline.rb
Constant Summary collapse
- MAIN_ELEMENTS =
"//sections/*[@displayorder] | //annex[@displayorder] | " \ "//bibliography/*[@displayorder] | //colophon/*[@displayorder] | " \ "//indexsect[@displayorder]".freeze
- WORD_DT_ATTRS =
{ class: @note ? "Note" : nil, align: "left", style: "margin-left:0pt;text-align:left;" }.freeze
- WORD_EMBED_DL_ATTRS =
"text-indent: -2.0cm; margin-left: 2.0cm; tab-stops: 2.0cm;".freeze
- SW1 =
"solid windowtext".freeze
Instance Method Summary collapse
- #admonition_subclass(_node) ⇒ Object
- #body_attr ⇒ Object
- #colgroup(node, table) ⇒ Object
-
#convert1(docxml, filename, dir) ⇒ Object
Apply empty_tags even when postprocess is skipped (debug mode), so convert1’s output is valid HTML5 (non-void self-closing tags expanded: <a id=“_”/> -> <a id=“_”></a>).
- #convert1_namespaces(html) ⇒ Object
- #datauri_word(uri) ⇒ Object
- #ddef_first_para(out, ddef) ⇒ Object
- #ddef_other_paras(out, ddef) ⇒ Object
- #define_head(head, filename, _dir) ⇒ Object
- #dl_parse(node, out) ⇒ Object
- #dl_parse_nontable(node, out) ⇒ Object
- #dl_parse_nontable1(out, dterm, ddef) ⇒ Object
- #dl_parse_table(node, out) ⇒ Object
- #dl_parse_table1(table, dterm, ddefn) ⇒ Object
- #dl_parse_table_notes(node, out) ⇒ Object
- #dl_table_attrs(node) ⇒ Object
- #dt_parse(dterm, term) ⇒ Object
- #emf_attributes(node) ⇒ Object
- #example_table_attr(node) ⇒ Object
- #figure_name_parse(_node, div, name) ⇒ Object
- #figure_parse1(node, out) ⇒ Object
- #formula_parse1(node, out) ⇒ Object
- #image_parse(node, out) ⇒ Object
- #imgsrc(node) ⇒ Object
- #info(xml, out) ⇒ Object
- #insert_tab(out, count) ⇒ Object
- #keep_rows_together(_cell, rowmax, totalrows, opt) ⇒ Object
- #li_checkbox(node) ⇒ Object
- #make_body1(body, _docxml) ⇒ Object
- #make_body2(body, docxml) ⇒ Object
- #make_body3(body, docxml) ⇒ Object
- #make_tr_attr(cell, row, totalrows, header, bordered) ⇒ Object
- #make_tr_attr_style(cell, row, rowmax, totalrows, opt) ⇒ Object
- #new_fullcolspan_row(table, tfoot) ⇒ Object
- #note_p_class ⇒ Object
- #page_break(out) ⇒ Object
- #pagebreak_parse(node, out) ⇒ Object
- #para_attrs(node) ⇒ Object
- #para_class(node) ⇒ Object
- #para_parse(node, out) ⇒ Object
- #remove_bottom_border(cell) ⇒ Object
- #rt_parse(node, out) ⇒ Object
- #ruby_parse(node, out) ⇒ Object
- #section_break(body, continuous: false) ⇒ Object
- #suffix_url(url) ⇒ Object
- #table_attrs(node) ⇒ Object
- #table_border_css(node) ⇒ Object
- #table_class(node) ⇒ Object
- #table_line_count(tbody) ⇒ Object
- #table_of_contents(clause, out) ⇒ Object
- #table_parse(node, out) ⇒ Object
- #table_title_parse(node, out) ⇒ Object
- #tbody_parse(node, table) ⇒ Object
- #termnote_p_class ⇒ Object
- #toc_info(xml) ⇒ Object
- #xref_parse(node, out) ⇒ Object
Instance Method Details
#admonition_subclass(_node) ⇒ Object
100 101 102 |
# File 'lib/isodoc/word_function/body.rb', line 100 def admonition_subclass(_node) "" end |
#body_attr ⇒ Object
36 37 38 |
# File 'lib/isodoc/word_function/body.rb', line 36 def body_attr { lang: "EN-US", link: "blue", vlink: "#954F72" } end |
#colgroup(node, table) ⇒ Object
101 102 103 104 105 106 107 108 |
# File 'lib/isodoc/word_function/table.rb', line 101 def colgroup(node, table) colgroup = node.at(ns("./colgroup")) or return table.colgroup do |cg| colgroup.xpath(ns("./col")).each do |c| cg.col width: c["width"] end end end |
#convert1(docxml, filename, dir) ⇒ Object
Apply empty_tags even when postprocess is skipped (debug mode), so convert1’s output is valid HTML5 (non-void self-closing tags expanded: <a id=“_”/> -> <a id=“_”></a>). Idempotent: running again in postprocess#toHTML is a no-op.
20 21 22 |
# File 'lib/isodoc/word_function/body.rb', line 20 def convert1(docxml, filename, dir) (super) end |
#convert1_namespaces(html) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/isodoc/word_function/body.rb', line 8 def convert1_namespaces(html) super html.add_namespace("v", "urn:schemas-microsoft-com:vml") html.add_namespace("o", "urn:schemas-microsoft-com:office:office") html.add_namespace("w", "urn:schemas-microsoft-com:office:word") html.add_namespace("m", "http://schemas.microsoft.com/office/2004/12/omml") end |
#datauri_word(uri) ⇒ Object
137 138 139 140 141 142 143 144 145 146 |
# File 'lib/isodoc/word_function/body.rb', line 137 def datauri_word(uri) ret = %r{^data:}.match?(uri) ? save_dataimage(uri) : uri if ret.end_with?(".svg") v = Vectory::Svg.from_node(Nokogiri::XML(File.read(ret))).to_emf target_path = imgfile_suffix(ret, "emf") v.write(target_path).to_uri.content ret = target_path end ret end |
#ddef_first_para(out, ddef) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/isodoc/word_function/lists.rb', line 51 def ddef_first_para(out, ddef) if ddef.elements&.first&.name == "p" ddef.children.first.children.each { |n| parse(n, out) } else ddef.children.each { |n| parse(n, out) } end end |
#ddef_other_paras(out, ddef) ⇒ Object
59 60 61 62 |
# File 'lib/isodoc/word_function/lists.rb', line 59 def ddef_other_paras(out, ddef) ddef.elements&.first&.name == "p" or return ddef.children[1..].each { |n| parse(n, out) } end |
#define_head(head, filename, _dir) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/isodoc/word_function/body.rb', line 24 def define_head(head, filename, _dir) head. "http-equiv": "Content-Type", content: "text/html; charset=UTF-8" head.style do |style| loc = File.join(File.dirname(__FILE__), "..", "base_style", "metanorma_word.scss") stylesheet = File.read(loc, encoding: "utf-8") style.comment "\n#{stylesheet}\n" end super end |
#dl_parse(node, out) ⇒ Object
20 21 22 23 24 |
# File 'lib/isodoc/word_function/lists.rb', line 20 def dl_parse(node, out) node.ancestors("table, dl").empty? or return dl_parse_nontable(node, out) dl_parse_table(node, out) end |
#dl_parse_nontable(node, out) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/isodoc/word_function/lists.rb', line 26 def dl_parse_nontable(node, out) out.div(**attr_code(class: "figdl")) do |div| node["id"] and bookmark_parse(node, div) list_title_parse(node, div) node.elements.select { |n| dt_dd?(n) } .each_slice(2) do |dt, dd| dl_parse_nontable1(div, dt, dd) end dl_parse_notes(node, div) end end |
#dl_parse_nontable1(out, dterm, ddef) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/isodoc/word_function/lists.rb', line 41 def dl_parse_nontable1(out, dterm, ddef) out.p(**attr_code(style: WORD_EMBED_DL_ATTRS, id: dterm["id"])) do |p| dterm.children.each { |n| parse(n, p) } insert_tab(p, 1) ddef["id"] and bookmark_parse(ddef, out) ddef_first_para(out, ddef) end ddef_other_paras(out, ddef) end |
#dl_parse_table(node, out) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/isodoc/word_function/lists.rb', line 72 def dl_parse_table(node, out) out.div(**attr_code(align: "left")) do |div| list_title_parse(node, div) div.table(**attr_code(dl_table_attrs(node))) do |v| node.elements.select { |n| dt_dd?(n) } .each_slice(2) do |dt, dd| dl_parse_table1(v, dt, dd) end dl_parse_table_notes(node, v) end end end |
#dl_parse_table1(table, dterm, ddefn) ⇒ Object
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/isodoc/word_function/lists.rb', line 85 def dl_parse_table1(table, dterm, ddefn) table.tr do |tr| tr.td valign: "top", align: "left" do |term| dt_parse(dterm, term) end tr.td valign: "top" do |listitem| ddefn.children.each { |n| parse(n, listitem) } end end end |
#dl_parse_table_notes(node, out) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/isodoc/word_function/lists.rb', line 96 def dl_parse_table_notes(node, out) remainder = node.elements.reject do |n| dt_dd?(n) || n.name == "fmt-name" end remainder.empty? and return out.tr do |tr| tr.td colspan: 2 do |td| remainder.each { |n| parse(n, td) } end end end |
#dl_table_attrs(node) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/isodoc/word_function/lists.rb', line 64 def dl_table_attrs(node) key = node.parent.name == "key" && node.parent["class"] == "formula_dl" klass = key ? node.parent["class"] : nil { id: node["id"], style: key ? "text-align:left;" : nil, class: klass || node["class"] || "dl" } end |
#dt_parse(dterm, term) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/isodoc/word_function/lists.rb', line 10 def dt_parse(dterm, term) term.p(**attr_code(WORD_DT_ATTRS)) do |p| if dterm.elements.empty? p << dterm.text else dterm.children.each { |n| parse(n, p) } end end end |
#emf_attributes(node) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/isodoc/word_function/inline.rb', line 52 def emf_attributes(node) if emf = node.at(ns("./emf")) node["src"] = emf["src"] node["height"] ||= emf["height"] node["width"] ||= emf["width"] node["mimetype"] = "image/x-emf" node.children.remove end end |
#example_table_attr(node) ⇒ Object
115 116 117 118 119 120 121 122 123 |
# File 'lib/isodoc/word_function/body.rb', line 115 def example_table_attr(node) super.merge( style: "mso-table-lspace:15.0cm;margin-left:423.0pt;" \ "mso-table-rspace:15.0cm;margin-right:423.0pt;" \ "mso-table-anchor-horizontal:column;" \ "mso-table-overlap:never;border-collapse:collapse;" \ "#{keep_style(node)}", ) end |
#figure_name_parse(_node, div, name) ⇒ Object
187 188 189 190 191 192 193 |
# File 'lib/isodoc/word_function/body.rb', line 187 def figure_name_parse(_node, div, name) name.nil? and return div.p class: "FigureTitle", style: "text-align:center;" do |p| name.children.each { |n| parse(n, p) } end end |
#figure_parse1(node, out) ⇒ Object
178 179 180 181 182 183 184 185 |
# File 'lib/isodoc/word_function/body.rb', line 178 def figure_parse1(node, out) out.div(**figure_attrs(node)) do |div| node.children.each do |n| parse(n, div) unless n.name == "fmt-name" end figure_name_parse(node, div, node.at(ns("./fmt-name"))) end end |
#formula_parse1(node, out) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/isodoc/word_function/body.rb', line 125 def formula_parse1(node, out) out.div(**attr_code(class: "formula")) do |div| div.p do |_p| parse(node.at(ns("./fmt-stem")), div) insert_tab(div, 1) if lbl = node&.at(ns("./fmt-name"))&.text div << lbl end end end end |
#image_parse(node, out) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/isodoc/word_function/inline.rb', line 44 def image_parse(node, out) emf_attributes(node) attrs = { src: imgsrc(node), height: node["height"], alt: node["alt"], title: node["title"], width: node["width"] } image_body_parse(node, attrs, out) end |
#imgsrc(node) ⇒ Object
38 39 40 41 42 |
# File 'lib/isodoc/word_function/inline.rb', line 38 def imgsrc(node) return node["src"] unless %r{^data:}.match? node["src"] save_dataimage(node["src"]) end |
#info(xml, out) ⇒ Object
148 149 150 151 152 153 154 155 156 |
# File 'lib/isodoc/word_function/body.rb', line 148 def info(xml, out) toc_info(xml) super if logos = @meta.get[:copublisher_logos] # may be DataURI logos.map! { |l| datauri_word(l) } @meta.set(:copublisher_logos, logos) end @meta.get end |
#insert_tab(out, count) ⇒ Object
4 5 6 7 8 |
# File 'lib/isodoc/word_function/inline.rb', line 4 def insert_tab(out, count) out.span(**attr_code(style: "mso-tab-count:#{count}")) do |span| [1..count].each { span << "  " } end end |
#keep_rows_together(_cell, rowmax, totalrows, opt) ⇒ Object
51 52 53 54 55 |
# File 'lib/isodoc/word_function/table.rb', line 51 def keep_rows_together(_cell, rowmax, totalrows, opt) opt[:header] and return true @table_line_count > 15 and return false totalrows <= 10 && rowmax < totalrows end |
#li_checkbox(node) ⇒ Object
108 109 110 111 112 113 114 115 |
# File 'lib/isodoc/word_function/lists.rb', line 108 def li_checkbox(node) if node["uncheckedcheckbox"] == "true" '<span class="zzMoveToFollowing">☐ </span>' elsif node["checkedcheckbox"] == "true" '<span class="zzMoveToFollowing">☑ </span>' else "" end end |
#make_body1(body, _docxml) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/isodoc/word_function/body.rb', line 40 def make_body1(body, _docxml) body.div class: "WordSection1" do |div1| div1.p { |p| p << " " } # placeholder end section_break(body) end |
#make_body2(body, docxml) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/isodoc/word_function/body.rb', line 47 def make_body2(body, docxml) body.div class: "WordSection2" do |div2| boilerplate docxml, div2 content(div2, docxml, ns("//preface/*[@displayorder]")) div2.p { |p| p << " " } # placeholder end section_break(body) end |
#make_body3(body, docxml) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/isodoc/word_function/body.rb', line 61 def make_body3(body, docxml) body.div class: "WordSection3" do |div3| content(div3, docxml, ns(self.class::MAIN_ELEMENTS)) footnotes docxml, div3 comments docxml, div3 end end |
#make_tr_attr(cell, row, totalrows, header, bordered) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/isodoc/word_function/table.rb', line 28 def make_tr_attr(cell, row, totalrows, header, bordered) style = cell.name == "th" ? "font-weight:bold;" : "" cell["style"] and style += "#{cell['style']};" rowmax = cell["rowspan"] ? row + cell["rowspan"].to_i - 1 : row style += make_tr_attr_style(cell, row, rowmax, totalrows, { header: header, bordered: bordered }) { rowspan: cell["rowspan"], colspan: cell["colspan"], valign: cell["valign"], align: cell["align"], style: style, class: cell["class"] } end |
#make_tr_attr_style(cell, row, rowmax, totalrows, opt) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/isodoc/word_function/table.rb', line 39 def make_tr_attr_style(cell, row, rowmax, totalrows, opt) top = row.zero? ? "#{SW1} 1.5pt;" : "none;" bottom = "#{SW1} #{rowmax >= totalrows ? '1.5' : '1.0'}pt;" ret = <<~STYLE.delete("\n") border-top:#{top}mso-border-top-alt:#{top} border-bottom:#{bottom}mso-border-bottom-alt:#{bottom} STYLE (opt[:bordered] && !cell["style"]) or ret = "" pb = keep_rows_together(cell, rowmax, totalrows, opt) ? "avoid" : "auto" "#{ret}page-break-after:#{pb};" end |
#new_fullcolspan_row(table, tfoot) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/isodoc/word_function/table.rb', line 15 def new_fullcolspan_row(table, tfoot) # how many columns in the table? cols = 0 table.at(".//tr").xpath("./td | ./th").each do |td| cols += (td["colspan"] ? td["colspan"].to_i : 1) end table["plain"] == "true" or s = "style='border-top:0pt;mso-border-top-alt:0pt;" \ "border-bottom:#{SW1} 1.5pt;mso-border-bottom-alt:#{SW1} 1.5pt;'" tfoot.add_child("<tr><td colspan='#{cols}' #{s}/></tr>") tfoot.xpath(".//td").last end |
#note_p_class ⇒ Object
92 93 94 |
# File 'lib/isodoc/word_function/body.rb', line 92 def note_p_class "Note" end |
#page_break(out) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/isodoc/word_function/inline.rb', line 21 def page_break(out) out.p class: "page-break" do |p| p.br clear: "all", style: "mso-special-character:line-break;" \ "page-break-before:always" end end |
#pagebreak_parse(node, out) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/isodoc/word_function/inline.rb', line 29 def pagebreak_parse(node, out) return page_break(out) if node["orientation"].nil? out.p do |p| p.br clear: "all", class: "section", orientation: node["orientation"] end end |
#para_attrs(node) ⇒ Object
104 105 106 107 108 109 110 111 112 113 |
# File 'lib/isodoc/word_function/body.rb', line 104 def para_attrs(node) attrs = { class: para_class(node), id: node["id"], style: "" } unless node["align"].nil? attrs[:align] = node["align"] unless node["align"] == "justify" attrs[:style] += "text-align:#{node['align']};" end attrs[:style] += keep_style(node).to_s attrs[:style] = nil if attrs[:style].empty? attrs end |
#para_class(node) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/isodoc/word_function/body.rb', line 69 def para_class(node) return "Sourcecode" if @annotation return "MsoCommentText" if @in_comment return "Note" if @note if node["type"] == "floating-title" return "h#{node['depth']}" end n = node["class"] and return n nil end |
#para_parse(node, out) ⇒ Object
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/isodoc/word_function/body.rb', line 81 def para_parse(node, out) out.p(**attr_code(para_attrs(node))) do |p| unless @termdomain.empty? p << "<#{@termdomain}> " @termdomain = "" end node.children.each { |n| parse(n, p) unless n.name == "note" } end node.xpath(ns("./note")).each { |n| parse(n, out) } end |
#remove_bottom_border(cell) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/isodoc/word_function/table.rb', line 4 def remove_bottom_border(cell) # [^;]* (not +): the preceding property name is the unambiguous # delimiter, so zero-or-more is equivalent and avoids polynomial # backtracking on the value portion. cell["style"] = cell["style"].gsub(/border-bottom:[^;]*;/, "border-bottom:0pt;") .gsub(/mso-border-bottom-alt:[^;]*;/, "mso-border-bottom-alt:0pt;") end |
#rt_parse(node, out) ⇒ Object
91 92 93 94 95 |
# File 'lib/isodoc/word_function/inline.rb', line 91 def rt_parse(node, out) out.rt(**{ style: "font-size: 6pt;" }) do |e| children_parse(node, e) end end |
#ruby_parse(node, out) ⇒ Object
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/isodoc/word_function/inline.rb', line 80 def ruby_parse(node, out) if r = node.at(ns("./rb[ruby]")) double_ruby = r.at(ns("./ruby/rt")).remove r.replace(r.at(ns("./ruby/rb"))) end out.ruby do |e| children_parse(node, e) end double_ruby and out << "(#{double_ruby.text})" end |
#section_break(body, continuous: false) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/isodoc/word_function/inline.rb', line 10 def section_break(body, continuous: false) body.p class: "section-break" do |p| if continuous p.br clear: "all", style: "page-break-before:auto;" \ "mso-break-type:section-break" else p.br clear: "all", class: "section" end end end |
#suffix_url(url) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/isodoc/word_function/inline.rb', line 73 def suffix_url(url) return url if url.nil? || %r{^https?://|^#}.match?(url) return url unless File.extname(url).empty? url.sub(/#{File.extname(url)}$/, ".doc") end |
#table_attrs(node) ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'lib/isodoc/word_function/table.rb', line 77 def table_attrs(node) style = table_border_css(node) ret = { summary: node["summary"], width: node["width"], class: table_class(node), style: "mso-table-anchor-horizontal:column;" \ "mso-table-overlap:never;#{style}#{keep_style(node)}" } style or ret.delete(:class) super.merge(attr_code(ret)) end |
#table_border_css(node) ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'lib/isodoc/word_function/table.rb', line 87 def table_border_css(node) c = node["class"] style = "border-spacing:0;border-width:1px;" node["style"] || node["plain"] == "true" and style = "" (%w(modspec).include?(c) || !c) or style = nil node["plain"] == "true" and style = "" style end |
#table_class(node) ⇒ Object
96 97 98 99 |
# File 'lib/isodoc/word_function/table.rb', line 96 def table_class(node) node["plain"] == "true" and return "MsoNormalTable" node.text.length > 4000 ? "MsoISOTableBig" : "MsoISOTable" end |
#table_line_count(tbody) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/isodoc/word_function/table.rb', line 63 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 end sum += i end sum end |
#table_of_contents(clause, out) ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/isodoc/word_function/body.rb', line 166 def table_of_contents(clause, out) page_break(out) out.div(**attr_code(preface_attrs(clause))) do |div| div.p class: "zzContents" do |p| clause.at(ns("./fmt-title"))&.children&.each { |c| parse(c, p) } end clause.elements.each do |e| parse(e, div) unless e.name == "fmt-title" end end end |
#table_parse(node, out) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/isodoc/word_function/table.rb', line 117 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, t) table_parse_tail(node, t) end end @in_table = false end |
#table_title_parse(node, out) ⇒ Object
110 111 112 113 114 115 |
# File 'lib/isodoc/word_function/table.rb', line 110 def table_title_parse(node, out) name = node.at(ns("./fmt-name")) or return out.p class: "TableTitle", style: "text-align:center;" do |p| name&.children&.each { |n| parse(n, p) } end end |
#tbody_parse(node, table) ⇒ Object
57 58 59 60 61 |
# File 'lib/isodoc/word_function/table.rb', line 57 def tbody_parse(node, table) tbody = node.at(ns("./tbody")) or return @table_line_count = table_line_count(tbody) super end |
#termnote_p_class ⇒ Object
96 97 98 |
# File 'lib/isodoc/word_function/body.rb', line 96 def termnote_p_class "Note" end |
#toc_info(xml) ⇒ Object
158 159 160 161 162 163 164 |
# File 'lib/isodoc/word_function/body.rb', line 158 def toc_info(xml) toc = "metanorma-extension/toc" @tocfigurestitle = xml.at(ns("//#{toc}[@type = 'figure']/title"))&.text @toctablestitle = xml.at(ns("//#{toc}[@type = 'table']/title"))&.text @tocrecommendationstitle = xml.at(ns("//#{toc}[@type = 'recommendation']/title"))&.text end |
#xref_parse(node, out) ⇒ Object
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/isodoc/word_function/inline.rb', line 62 def xref_parse(node, out) target = if node["target"].include?("#") node["target"].sub("#", ".doc#") else "##{node['target']}" end out.a(href: target) do |l| children_parse(node, l) end end |