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

TODO: To Presentation XML



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

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



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

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("./fmt-title")), div, nil)
    clause.elements.each do |e|
      parse(e, div) unless %w{fmt-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



180
181
182
183
# File 'lib/isodoc/iso/base_convert.rb', line 180

def convert_i18n_init(docxml)
  super
  update_i18n(docxml)
end

#error_parse(node, out) ⇒ Object

terms not defined in standoc KILL



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

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

#example_p_classObject



33
34
35
# File 'lib/isodoc/iso/base_convert.rb', line 33

def example_p_class
  nil
end

#example_p_parse(node, div) ⇒ Object



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

def example_p_parse(node, div)
  name = node.at(ns("./fmt-name"))
  para = node.at(ns("./p"))
  div.p **attr_code(class: example_p_class) do |p|
    name and p.span class: "example_label" do |s|
      name.children.each { |n| parse(n, s) }
    end
    insert_tab(p, 1) # TODO to Presentation XML
    children_parse(para, p)
  end
  para.xpath("./following-sibling::*").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 starts_with_para?(node)
      example_p_parse(node, div)
    else
      example_parse1(node, div)
    end
  end
end

#example_parse1(node, div) ⇒ Object



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

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

#example_span_label(_node, div, name) ⇒ Object



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

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



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

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



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

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 == "fmt-name"
    end
    figure_name_parse(node, div, node.at(ns("./fmt-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("./fmt-title")), s,
                { class: "ForewordTitle" })
    clause.elements.each { |e| parse(e, s) unless e.name == "fmt-title" }
  end
  @foreword = false
end

#measurement_units(node, out) ⇒ Object



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

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

#ol_attrs(node) ⇒ Object



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

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

#span_parse(node, out) ⇒ Object



185
186
187
188
189
# File 'lib/isodoc/iso/base_convert.rb', line 185

def span_parse(node, out)
  node["class"] == "fmt-obligation" and
    node["class"] = "obligation"
  super
end

#table_cleanup(docxml) ⇒ Object



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

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



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

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



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

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
  node.xpath(ns("./fmt-footnote-container/fmt-fn-body"))
    .each { |n| parse(n, out) }
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



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

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