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



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

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

#admonition_p_parse(node, div, name) ⇒ Object



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

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



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

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

#admonition_parse1(node, div, name) ⇒ Object



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

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

#cleanup(docxml) ⇒ Object



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

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



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

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



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

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



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

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



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

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



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

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

#figure_name_parse(node, div, name) ⇒ Object



150
151
152
153
154
# File 'lib/isodoc/iso/base_convert.rb', line 150

def figure_name_parse(node, div, name)
  div.p **{ class: "FigureTitle", style: "text-align:center;" } do |p|
    name and name.children.each { |n| parse(n, div) }
  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(dl, out) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/isodoc/iso/base_convert.rb', line 108

def formula_where(dl, out)
  return if dl.nil?
  return super unless (dl&.xpath(ns("./dt"))&.size == 1 && 
                       dl&.at(ns("./dd"))&.elements&.size == 1 &&
                       dl&.at(ns("./dd/p")))
  out.span **{ class: "zzMoveToFollowing" } do |s|
    s << "#{@i18n.where} "
    dl.at(ns("./dt")).children.each { |n| parse(n, s) }
    s << " "
  end
  parse(dl.at(ns("./dd/p")), out)
end

#implicit_reference(b) ⇒ Object



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

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

#insertall_after_here(node, insert, name) ⇒ Object



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

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



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

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



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

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



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

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

#termexamples_before_termnotes(node) ⇒ Object



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

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")
  insert = insertall_after_here(node, insert, "termnote")
end