Module: IsoDoc::Iso::BaseConvert

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

Instance Method Summary collapse

Instance Method Details

#admonition_class(node) ⇒ Object



81
82
83
84
85
# File 'lib/isodoc/iso/base_convert.rb', line 81

def admonition_class(node)
  if node["type"] == "editorial" then "zzHelp"
  else super
  end
end

#admonition_name_para_delim(para) ⇒ Object



91
92
93
# File 'lib/isodoc/iso/base_convert.rb', line 91

def admonition_name_para_delim(para)
  para << " "
end

#admonition_p_parse(node, div) ⇒ Object



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

def admonition_p_parse(node, div)
  admonition_name_in_first_para(node, div)
end

#annex(node, out) ⇒ Object



4
5
6
7
8
9
# File 'lib/isodoc/iso/sections.rb', line 4

def annex(node, out)
  amd?(node.document) and
    @suppressheadingnumbers = @oldsuppressheadingnumbers
  super
  amd?(node.document) and @suppressheadingnumbers = true
end

#clause_etc1(clause, out, num) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/isodoc/iso/base_convert.rb', line 111

def clause_etc1(clause, out, num)
  out.div **attr_code(
    id: clause["id"],
    class: clause.name == "definitions" ? "Symbols" : nil,
  ) do |div|
    num = num + 1
    clause_name(clause, clause&.at(ns("./title")), div, nil)
    clause.elements.each do |e|
      parse(e, div) unless %w{title source}.include? e.name
    end
  end
end

#cleanup(docxml) ⇒ Object



68
69
70
71
72
# File 'lib/isodoc/iso/base_convert.rb', line 68

def cleanup(docxml)
  super
  table_th_center(docxml)
  docxml
end

#convert1(docxml, filename, dir) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/isodoc/iso/base_convert.rb', line 8

def convert1(docxml, filename, dir)
  if amd?(docxml)
    @oldsuppressheadingnumbers = @suppressheadingnumbers
    @suppressheadingnumbers = true
  end
  super
end

#convert_i18n_init(docxml) ⇒ Object



177
178
179
180
# File 'lib/isodoc/iso/base_convert.rb', line 177

def convert_i18n_init(docxml)
  super
  update_i18n(docxml)
end

#error_parse(node, out) ⇒ Object

terms not defined in standoc



17
18
19
20
21
22
23
# File 'lib/isodoc/iso/base_convert.rb', line 17

def error_parse(node, out)
  case node.name
  when "appendix" then clause_parse(node, out)
  else
    super
  end
end

#example_p_parse(node, div) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/isodoc/iso/base_convert.rb', line 32

def example_p_parse(node, div)
  div.p do |p|
    example_span_label(node, p, node&.at(ns("./name"))&.remove)
    insert_tab(p, 1)
    node.first_element_child.children.each { |n| parse(n, p) }
  end
  node.element_children[1..].each { |n| parse(n, div) }
end

#example_parse(node, out) ⇒ Object



58
59
60
61
62
63
64
65
66
# File 'lib/isodoc/iso/base_convert.rb', line 58

def example_parse(node, out)
  out.div id: node["id"], class: "example" do |div|
    if node_begins_with_para(node)
      example_p_parse(node, div)
    else
      example_parse1(node, div)
    end
  end
end

#example_parse1(node, div) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/isodoc/iso/base_convert.rb', line 41

def example_parse1(node, div)
  div.p do |p|
    example_span_label(node, p, node.at(ns("./name")))
    insert_tab(p, 1)
  end
  node.children.each { |n| parse(n, div) unless n.name == "name" }
end

#example_span_label(_node, div, name) ⇒ Object



25
26
27
28
29
30
# File 'lib/isodoc/iso/base_convert.rb', line 25

def example_span_label(_node, div, name)
  name.nil? and return
  div.span class: "example_label" do |p|
    name.children.each { |n| parse(n, p) }
  end
end

#figure_name_parse(_node, div, name) ⇒ Object



95
96
97
98
99
100
# File 'lib/isodoc/iso/base_convert.rb', line 95

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



147
148
149
150
151
152
153
154
155
156
# File 'lib/isodoc/iso/base_convert.rb', line 147

def figure_parse1(node, out)
  measurement_units(node, out)
  out.div **figure_attrs(node) do |div|
    node.children.each do |n|
      n.name == "note" && n["type"] == "units" and next
      parse(n, div) unless n.name == "name"
    end
    figure_name_parse(node, div, node.at(ns("./name")))
  end
end

#foreword(clause, out) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/isodoc/iso/sections.rb', line 11

def foreword(clause, out)
  @foreword = true
  page_break(out)
  out.div **attr_code(id: clause["id"]) do |s|
    clause_name(nil, clause.at(ns("./title")), s,
                { class: "ForewordTitle" })
    clause.elements.each { |e| parse(e, s) unless e.name == "title" }
  end
  @foreword = false
end

#measurement_units(node, out) ⇒ Object



158
159
160
161
162
163
164
165
166
# File 'lib/isodoc/iso/base_convert.rb', line 158

def measurement_units(node, out)
  node.xpath(ns("./note[@type = 'units']")).each do |n|
    out.div align: "right" do |p|
      p.b do |b|
        n.children.each { |e| parse(e, b) }
      end
    end
  end
end

#node_begins_with_para(node) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/isodoc/iso/base_convert.rb', line 49

def node_begins_with_para(node)
  node.elements.each do |e|
    e.name == "name" and next
    e.name == "p" and return true
    return false
  end
  false
end

#ol_attrs(node) ⇒ Object



124
125
126
# File 'lib/isodoc/iso/base_convert.rb', line 124

def ol_attrs(node)
  super.merge(start: node["start"]).compact
end

#table_cleanup(docxml) ⇒ Object



168
169
170
171
172
173
174
175
# File 'lib/isodoc/iso/base_convert.rb', line 168

def table_cleanup(docxml)
  super
  docxml.xpath("//tfoot/div[@class = 'figdl']/p[@class = 'ListTitle']")
    .each do |p|
    p["align"] = "left"
  end
  docxml
end

#table_parse(node, out) ⇒ Object



128
129
130
131
132
133
134
135
136
137
# File 'lib/isodoc/iso/base_convert.rb', line 128

def table_parse(node, out)
  @in_table = true
  table_title_parse(node, out)
  measurement_units(node, out)
  out.table **table_attrs(node) do |t|
    table_parse_core(node, t)
    table_parse_tail(node, t)
  end
  @in_table = false
end

#table_parse_tail(node, out) ⇒ Object



139
140
141
142
143
144
145
# File 'lib/isodoc/iso/base_convert.rb', line 139

def table_parse_tail(node, out)
  (dl = node.at(ns("./dl"))) && parse(dl, out)
  node.xpath(ns("./source")).each { |n| parse(n, out) }
  node.xpath(ns("./note[not(@type = 'units')]")).each do |n|
    parse(n, out)
  end
end

#table_th_center(docxml) ⇒ Object



74
75
76
77
78
79
# File 'lib/isodoc/iso/base_convert.rb', line 74

def table_th_center(docxml)
  docxml.xpath("//thead//th | //thead//td").each do |th|
    th["align"] = "center"
    th["valign"] = "middle"
  end
end

#top_element_render(elem, out) ⇒ Object



102
103
104
105
106
107
108
109
# File 'lib/isodoc/iso/base_convert.rb', line 102

def top_element_render(elem, out)
  if %w(clause terms definitions).include?(elem.name) &&
      elem.parent.name == "sections" &&
      elem["type"] != "scope"
    clause_etc1(elem, out, 0)
  else super
  end
end