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



101
102
103
104
105
# File 'lib/isodoc/iso/base_convert.rb', line 101

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

#admonition_name_parse(_node, div, name) ⇒ Object



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

def admonition_name_parse(_node, div, name)
  name.children.each { |n| parse(n, div) }
  div << " &#x2014; "
end

#admonition_p_parse(node, div, name) ⇒ Object



114
115
116
117
118
119
120
# File 'lib/isodoc/iso/base_convert.rb', line 114

def admonition_p_parse(node, div, name)
  div.p do |p|
    admonition_name_parse(node, p, name) if name
    node.first_element_child.children.each { |n| parse(n, p) }
  end
  node.element_children[1..-1].each { |n| parse(n, div) }
end

#admonition_parse(node, out) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/isodoc/iso/base_convert.rb', line 89

def admonition_parse(node, out)
  type = node["type"]
  name = admonition_name(node, type)
  out.div id: node["id"], class: admonition_class(node) do |div|
    if node.first_element_child.name == "p"
      admonition_p_parse(node, div, name)
    else
      admonition_parse1(node, div, name)
    end
  end
end

#admonition_parse1(node, div, name) ⇒ Object



107
108
109
110
111
112
# File 'lib/isodoc/iso/base_convert.rb', line 107

def admonition_parse1(node, div, name)
  div.p do |p|
    admonition_name_parse(node, p, name) if name
  end
  node.children.each { |n| parse(n, div) unless n.name == "name" }
end

#annex(isoxml, out) ⇒ Object



32
33
34
35
36
# File 'lib/isodoc/iso/sections.rb', line 32

def annex(isoxml, out)
  amd(isoxml) and @suppressheadingnumbers = @oldsuppressheadingnumbers
  super
  amd(isoxml) and @suppressheadingnumbers = true
end

#clause_etc(isoxml, out, num) ⇒ Object



143
144
145
146
147
148
149
# File 'lib/isodoc/iso/base_convert.rb', line 143

def clause_etc(isoxml, out, num)
  isoxml.xpath(ns("//sections/clause[not(@type = 'scope')] | " \
                  "//sections/terms | //sections/definitions"))
    .each do |f|
      clause_etc1(f, out, num)
    end
end

#clause_etc1(clause, out, num) ⇒ Object



151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/isodoc/iso/base_convert.rb', line 151

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



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

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

#error_parse(node, out) ⇒ Object

terms not defined in standoc



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

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



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

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..-1].each { |n| parse(n, div) }
end

#example_parse(node, out) ⇒ Object



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

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



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

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



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

def example_span_label(_node, div, name)
  return if name.nil?

  div.span class: "example_label" do |p|
    name.children.each { |n| parse(n, p) }
  end
end

#figure_name_parse(_node, div, name) ⇒ Object



127
128
129
130
131
# File 'lib/isodoc/iso/base_convert.rb', line 127

def figure_name_parse(_node, div, name)
  div.p class: "FigureTitle", style: "text-align:center;" do |p|
    name&.children&.each { |n| parse(n, p) }
  end
end

#figure_parse1(node, out) ⇒ Object



193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/isodoc/iso/base_convert.rb', line 193

def figure_parse1(node, out)
  measurement_units(node, out)
  out.div **figure_attrs(node) do |div|
    node.children.each do |n|
      figure_key(out) if n.name == "dl"
      next if n.name == "note" && n["type"] == "units"

      parse(n, div) unless n.name == "name"
    end
    figure_name_parse(node, div, node.at(ns("./name")))
  end
end

#foreword(isoxml, out) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/isodoc/iso/sections.rb', line 50

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

#implicit_reference(bib) ⇒ Object



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

def implicit_reference(bib)
  return true if bib&.at(ns("./docidentifier"))&.text == "IEV"

  super
end

#indexsect(isoxml, out) ⇒ Object



164
165
166
167
168
# File 'lib/isodoc/iso/base_convert.rb', line 164

def indexsect(isoxml, out)
  isoxml.xpath(ns("//indexsect")).each do |i|
    clause_parse(i, out)
  end
end

#introduction(isoxml, out) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/isodoc/iso/sections.rb', line 38

def introduction(isoxml, out)
  f = isoxml.at(ns("//introduction")) || return
  title_attr = { class: "IntroTitle" }
  page_break(out)
  out.div class: "Section3", id: f["id"] do |div|
    clause_name(f, f.at(ns("./title")), div, title_attr)
    f.elements.each do |e|
      parse(e, div) unless e.name == "title"
    end
  end
end

#measurement_units(node, out) ⇒ Object



206
207
208
209
210
211
212
213
214
# File 'lib/isodoc/iso/base_convert.rb', line 206

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

#middle(isoxml, out) ⇒ Object



133
134
135
136
137
138
139
140
141
# File 'lib/isodoc/iso/base_convert.rb', line 133

def middle(isoxml, out)
  middle_title(isoxml, out)
  middle_admonitions(isoxml, out)
  i = scope isoxml, out, 0
  i = norm_ref isoxml, out, i
  clause_etc isoxml, out, i
  annex isoxml, out
  bibliography isoxml, out
end

#middle_title(_isoxml, out) ⇒ Object



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

def middle_title(_isoxml, out)
  middle_title_main(out)
  middle_title_amd(out)
end

#middle_title_amd(out) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/isodoc/iso/sections.rb', line 22

def middle_title_amd(out)
  a = @meta.get[:doctitleamdlabel] and out.p(class: "zzSTDTitle2") do |p|
    p << a
    a = @meta.get[:doctitleamd] and p << ": #{a}"
  end
  a = @meta.get[:doctitlecorrlabel] and out.p(class: "zzSTDTitle2") do |p|
    p << a
  end
end

#middle_title_main(out) ⇒ Object



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

def middle_title_main(out)
  out.p(class: "zzSTDTitle1") do |p|
    p << @meta.get[:doctitleintro]
    p << " &#x2014; " if @meta.get[:doctitleintro] && @meta.get[:doctitlemain]
    p << @meta.get[:doctitlemain]
    p << " &#x2014; " if @meta.get[:doctitlemain] && @meta.get[:doctitlepart]
  end
  a = @meta.get[:doctitlepart] and out.p(class: "zzSTDTitle2") do |p|
    b = @meta.get[:doctitlepartlabel] and p << "#{b}: "
    p << "<br/><b>#{a}</b>"
  end
end

#node_begins_with_para(node) ⇒ Object



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

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

    return false
  end
  false
end

#ol_attrs(node) ⇒ Object



170
171
172
# File 'lib/isodoc/iso/base_convert.rb', line 170

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

#render_identifier(ident) ⇒ Object



174
175
176
177
178
# File 'lib/isodoc/iso/base_convert.rb', line 174

def render_identifier(ident)
  ret = super
  ret[:sdo] = std_docid_semantic(ret[:sdo])
  ret
end

#table_parse(node, out) ⇒ Object



180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/isodoc/iso/base_convert.rb', line 180

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)
    (dl = node.at(ns("./dl"))) && parse(dl, out)
    node.xpath(ns("./note[not(@type = 'units')]"))
      .each { |n| parse(n, out) }
  end
  @in_table = false
end

#table_th_center(docxml) ⇒ Object



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

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