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



130
131
132
133
# File 'lib/isodoc/iso/base_convert.rb', line 130

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

#admonition_p_parse(node, div, name) ⇒ Object



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

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



103
104
105
106
107
108
109
110
111
112
113
# File 'lib/isodoc/iso/base_convert.rb', line 103

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



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

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



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

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



162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/isodoc/iso/base_convert.rb', line 162

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(num, 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



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

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
59
60
# File 'lib/isodoc/iso/sections.rb', line 50

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

#formula_where(dlist, out) ⇒ Object



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

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



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

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(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



141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/isodoc/iso/base_convert.rb', line 141

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 << " &#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

#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