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_name_parse(_node, div, name) ⇒ Object



154
155
156
157
# File 'lib/isodoc/iso/base_convert.rb', line 154

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

#admonition_p_parse(node, div, name) ⇒ Object



146
147
148
149
150
151
152
# File 'lib/isodoc/iso/base_convert.rb', line 146

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



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

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



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

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



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

def clause_etc(isoxml, out, num)
  isoxml.xpath(ns("//sections/clause[not(@type = 'scope')] | "\
                  "//sections/terms | //sections/definitions")).each do |f|
    out.div **attr_code(id: f["id"],
                        class: f.name == "definitions" ? "Symbols" : nil) do |div|
      num = num + 1
      clause_name(num, f&.at(ns("./title")), div, nil)
      f.elements.each do |e|
        parse(e, div) unless %w{title source}.include? e.name
      end
    end
  end
end

#cleanup(docxml) ⇒ Object



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

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
47
# File 'lib/isodoc/iso/base_convert.rb', line 39

def example_p_parse(node, div)
  name = node&.at(ns("./name"))&.remove
  div.p do |p|
    example_span_label(node, p, name)
    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



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

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



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

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



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

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

#foreword(isoxml, out) ⇒ Object



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

def foreword(isoxml, out)
  f = isoxml.at(ns("//foreword")) || return
  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
end

#formula_where(dlist, out) ⇒ Object



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

def formula_where(dlist, out)
  return if dlist.nil?
  return super unless dlist&.xpath(ns("./dt"))&.size == 1 &&
    dlist&.at(ns("./dd"))&.elements&.size == 1 &&
    dlist&.at(ns("./dd/p"))

  out.span **{ class: "zzMoveToFollowing" } do |s|
    s << "#{@i18n.where} "
    dlist.at(ns("./dt")).children.each { |n| parse(n, s) }
    s << " "
  end
  parse(dlist.at(ns("./dd/p")), out)
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



192
193
194
195
196
# File 'lib/isodoc/iso/base_convert.rb', line 192

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

#insertall_after_here(node, insert, name) ⇒ Object



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

def insertall_after_here(node, insert, name)
  node.children.each do |n|
    next unless n.name == name

    insert.next = n.remove
    insert = n
  end
  insert
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(nil, f.at(ns("./title")), div, title_attr)
    f.elements.each do |e|
      parse(e, div) unless e.name == "title"
    end
  end
end

#middle(isoxml, out) ⇒ Object



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

def middle(isoxml, out)
  middle_title(isoxml, out)
  middle_admonitions(isoxml, out)
  i = scope isoxml, out, 0
  i = norm_ref isoxml, out, i
  # i = terms_defs isoxml, out, i
  # symbols_abbrevs isoxml, out, i
  clause_etc isoxml, out, i
  annex isoxml, out
  bibliography isoxml, out
  indexsect 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 << " &mdash; " if @meta.get[:doctitleintro] && @meta.get[:doctitlemain]
    p << @meta.get[:doctitlemain]
    p << " &mdash; " 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



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

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

#table_th_center(docxml) ⇒ Object



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

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

#termdef_parse(node, out) ⇒ Object



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

def termdef_parse(node, out)
  termexamples_before_termnotes(node)
  super
end

#termexamples_before_termnotes(node) ⇒ Object



87
88
89
90
91
92
93
# File 'lib/isodoc/iso/base_convert.rb', line 87

def termexamples_before_termnotes(node)
  return unless node.at(ns("./termnote")) && node.at(ns("./termexample"))
  return unless insert = node.at(ns("./definition"))

  insert = insertall_after_here(node, insert, "termexample")
  insertall_after_here(node, insert, "termnote")
end