Module: IsoDoc::Jis::BaseConvert

Included in:
HtmlConvert, WordConvert
Defined in:
lib/isodoc/jis/base_convert.rb

Instance Method Summary collapse

Instance Method Details

#annex(node, out) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/isodoc/jis/base_convert.rb', line 12

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 == "fmt-title" then annex_name(node, c1, s)
      else parse(c1, s)
      end
    end
  end
  amd?(isoxml) and @suppressheadingnumbers = true
end

#commentary(node, out) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/isodoc/jis/base_convert.rb', line 26

def commentary(node, out)
  page_break(out)
  out.div **attr_code(annex_attrs(node)) do |s|
    node.elements.each do |c1|
      if c1.name == "fmt-title" then annex_name(node, c1, s)
      else parse(c1, s)
      end
    end
  end
end

#footnote_parse(node, out) ⇒ Object

table name footnote is formatted like other footnotes, since table name is a table row.



87
88
89
90
# File 'lib/isodoc/jis/base_convert.rb', line 87

def footnote_parse(node, out)
  @in_table and return table_footnote_parse(node, out)
  super
end

#full_row(cols, elem) ⇒ Object



73
74
75
# File 'lib/isodoc/jis/base_convert.rb', line 73

def full_row(cols, elem)
  "<tr><td border='0' colspan='#{cols}'>#{elem}</td></tr>"
end

#make_tr_attr(cell, row, totalrows, header, bordered) ⇒ Object



7
8
9
10
# File 'lib/isodoc/jis/base_convert.rb', line 7

def make_tr_attr(cell, row, totalrows, header, bordered)
  cell["border"] == "0" and bordered = false
  super
end

#table_cols_count(node) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/isodoc/jis/base_convert.rb', line 65

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



77
78
79
80
81
82
83
# File 'lib/isodoc/jis/base_convert.rb', line 77

def table_name(name, thead, cols)
  name or return
  thead.add_first_child full_row(
    cols, "<fmt-name><p class='TableTitle' style='text-align:center;'> " \
          "#{name.remove.children.to_xml}</p></fmt-name>"
  )
end

#table_parse(node, out) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/isodoc/jis/base_convert.rb', line 37

def table_parse(node, out)
  cols = table_cols_count(node)
  name = node.at(ns("./fmt-name"))
  thead = table_thead_pt(node, name)
  table_name(name, thead, cols)
  super
end

#table_parse_tail(node, out) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/isodoc/jis/base_convert.rb', line 45

def table_parse_tail(node, out)
  table_parse_tail?(node) or return
  tfoot = table_get_or_make_tfoot(out.parent)
  [["./key", "./fmt-source", "./note"],
   ["./fmt-footnote-container/fmt-fn-body"]].each do |e|
    e.any? { |x| node.at(ns(x)) } or next
    ins = new_fullcolspan_row(out.parent, tfoot)
    b = Nokogiri::XML::Builder.with(ins)
    e.each do |k|
      node.xpath(ns(k)).each { |n| parse(n, b) }
    end
  end
end

#table_thead_pt(node, name) ⇒ Object



59
60
61
62
63
# File 'lib/isodoc/jis/base_convert.rb', line 59

def table_thead_pt(node, name)
  node.at(ns("./thead")) ||
    name&.after("<thead> </thead>")&.next ||
    node.elements.first.before("<thead> </thead>").previous
end