Module: IsoDoc::JIS::BaseConvert
- Included in:
- HtmlConvert, WordConvert
- Defined in:
- lib/isodoc/jis/base_convert.rb
Instance Method Summary collapse
- #admonition_name_parse(_node, div, name) ⇒ Object
- #annex(node, out) ⇒ Object
- #commentary(node, out) ⇒ Object
- #full_row(cols, elem) ⇒ Object
- #make_tr_attr(cell, row, totalrows, header, bordered) ⇒ Object
- #table_cols_count(node) ⇒ Object
- #table_name(name, thead, cols) ⇒ Object
- #table_parse(node, out) ⇒ Object
- #table_thead_pt(node, name) ⇒ Object
- #termnote_parse(node, out) ⇒ Object
Instance Method Details
#admonition_name_parse(_node, div, name) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/isodoc/jis/base_convert.rb', line 22 def admonition_name_parse(_node, div, name) div.span class: "note_label" do |s| name.children.each { |n| parse(n, s) } s << " — " end end |
#annex(node, out) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/isodoc/jis/base_convert.rb', line 34 def annex(node, out) node["commentary"] = "true" and return commentary(node, out) amd?(isoxml) and @suppressheadingnumbers = @oldsuppressheadingnumbers page_break(out) out.div **attr_code(annex_attrs(node)) do |s| node.elements.each do |c1| if c1.name == "title" then annex_name(node, c1, s) else parse(c1, s) end end end amd?(isoxml) and @suppressheadingnumbers = true end |
#commentary(node, out) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/isodoc/jis/base_convert.rb', line 47 def commentary(node, out) page_break(out) out.div **attr_code(annex_attrs(node)) do |s| node.elements.each do |c1| if c1.name == "title" then annex_name(node, c1, s) else parse(c1, s) end end end end |
#full_row(cols, elem) ⇒ Object
80 81 82 |
# File 'lib/isodoc/jis/base_convert.rb', line 80 def full_row(cols, elem) "<tr><td border='0' colspan='#{cols}'>#{elem}</td></tr>" end |
#make_tr_attr(cell, row, totalrows, header, bordered) ⇒ Object
29 30 31 32 |
# File 'lib/isodoc/jis/base_convert.rb', line 29 def make_tr_attr(cell, row, totalrows, header, bordered) cell["border"] == "0" and bordered = false super end |
#table_cols_count(node) ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/isodoc/jis/base_convert.rb', line 72 def table_cols_count(node) cols = 0 node.at(ns(".//tr")).xpath(ns("./td | ./th")).each do |x| cols += x["colspan"]&.to_i || 1 end cols end |
#table_name(name, thead, cols) ⇒ Object
84 85 86 87 88 89 |
# File 'lib/isodoc/jis/base_convert.rb', line 84 def table_name(name, thead, cols) name or return thead.children.first.previous = full_row(cols, "<p class='TableTitle' style='text-align:center;'> " \ "#{name.remove.children.to_xml}</p>") end |
#table_parse(node, out) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/isodoc/jis/base_convert.rb', line 58 def table_parse(node, out) cols = table_cols_count(node) name = node.at(ns("./name")) thead = table_thead_pt(node, name) table_name(name, thead, cols) super end |
#table_thead_pt(node, name) ⇒ Object
66 67 68 69 70 |
# File 'lib/isodoc/jis/base_convert.rb', line 66 def table_thead_pt(node, name) node.at(ns("./thead")) || name&.after("<thead> </thead>")&.next || node.elements.first.before("<thead> </thead>").previous end |
#termnote_parse(node, out) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/isodoc/jis/base_convert.rb', line 7 def termnote_parse(node, out) name = node.at(ns("./name"))&.remove out.div **note_attrs(node) do |div| div.p do |p| if name p.span class: "note_label" do |s| name.children.each { |n| parse(n, s) } end p << termnote_delim end para_then_remainder(node.first_element_child, node, p, div) end end end |