Module: IsoDoc::Iec::BaseConvert

Included in:
HtmlConvert, WordConvert
Defined in:
lib/isodoc/iec/base_convert.rb

Instance Method Summary collapse

Instance Method Details

#admitted_term_parse(node, out) ⇒ Object



111
112
113
114
115
116
# File 'lib/isodoc/iec/base_convert.rb', line 111

def admitted_term_parse(node, out)
  out.p **{ class: "AltTerms", style:"text-align:left;" } do |p|
    node.children.each { |c| parse(c, p) }
    term_suffix(node, p)
  end
end

#biblio_list(f, div, biblio) ⇒ Object



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

def biblio_list(f, div, biblio)
  return super unless @is_iev
  i = 0
  f.children.each do |b|
    parse(b, div) unless %w(title bibitem).include? b.name
  end
end

#bibliography(isoxml, out) ⇒ Object



55
56
57
# File 'lib/isodoc/iec/base_convert.rb', line 55

def bibliography(isoxml, out)
  return super unless @is_iev
end

#boilerplate(node, out) ⇒ Object



7
8
9
# File 'lib/isodoc/iec/base_convert.rb', line 7

def boilerplate(node, out)
  # processed in foreword instead
end

#deprecated_term_parse(node, out) ⇒ Object



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

def deprecated_term_parse(node, out)
  out.p **{ class: "DeprecatedTerms", style:"text-align:left;" } do |p|
    p << l10n("#{@i18n.deprecated}: ")
    node.children.each { |c| parse(c, p) }
    term_suffix(node, p)
  end
end

#foreword(isoxml, out) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/isodoc/iec/base_convert.rb', line 11

def foreword(isoxml, out)
  f = isoxml.at(ns("//foreword"))
  b = isoxml.at(ns("//boilerplate/legal-statement"))
  page_break(out)
  iec_orgname(out)
  middle_title(isoxml, out)
  out.div **attr_code(id: f ? f["id"] : "") do |s|
    s.h1(**{ class: "ForewordTitle" }) { |h1| h1 << @i18n.foreword }
    @meta.get[:doctype] == "Amendment" or
      s.div **attr_code(class: "boilerplate_legal") do |s1|
      b&.elements&.each { |e| parse(e, s1) }
    end
    f&.elements&.each { |e| parse(e, s) unless e.name == "title" }
  end
end

#iec_orgname(out) ⇒ Object



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

def iec_orgname(out)
  out.p(**{ class: "zzSTDTitle1" }) { |p| p << @i18n.get["IEC"] }
  out.p(**{ class: "zzSTDTitle1" }) { |p| p << "____________" }
  out.p(**{ class: "zzSTDTitle1" }) { |p| p << "&nbsp;" }
end

#middle_title(_isoxml, out) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/isodoc/iec/base_convert.rb', line 33

def middle_title(_isoxml, out)
  title1 = @meta.get[:doctitlemain]&.sub(/\s+$/, "")
  @meta.get[:doctitleintro] and
    title1 = "#{@meta.get[:doctitleintro]} &mdash; #{title1}"
  if @meta.get[:doctitlepart]
    title1 += " &mdash;"
    title2 = @meta.get[:doctitlepart]&.sub(/\s+$/, "")
    @meta.get[:doctitlepartlabel] and
      title2 = "#{@meta.get[:doctitlepartlabel]}: #{title2}"
  end
  out.p(**{ class: "zzSTDTitle1" }) do |p| 
    p.b { |b| b << title1 }
  end
  if @meta.get[:doctitlepart]
    out.p(**{ class: "zzSTDTitle1" }) { |p| p << "&nbsp;" }
    out.p(**{ class: "zzSTDTitle2" }) do |p| 
      p.b { |b| b << title2 }
    end
  end
  out.p(**{ class: "zzSTDTitle1" }) { |p| p << "&nbsp;" }
end

#set_termdomain(termdomain) ⇒ Object



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

def set_termdomain(termdomain)
  return super unless @is_iev
end

#term_parse(node, out) ⇒ Object



118
119
120
121
122
123
124
# File 'lib/isodoc/iec/base_convert.rb', line 118

def term_parse(node, out)
  return super unless @is_iev
  out.p **{ class: "Terms", style:"text-align:left;" } do |p|
    node.children.each { |c| parse(c, p) }
    term_suffix(node, p)
  end
end

#term_suffix(node, out) ⇒ Object



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

def term_suffix(node, out)
  return unless @is_iev
  domain = node&.at(ns("../domain"))&.text
  return unless domain
  out << ", &lt;#{domain}&gt;"
end

#termref_cleanup(docxml) ⇒ Object



82
83
84
85
86
87
88
89
90
# File 'lib/isodoc/iec/base_convert.rb', line 82

def termref_cleanup(docxml)
  return super unless @is_iev
  docxml.
    gsub(%r{\s*\[/TERMREF\]\s*</p>\s*<p>\s*\[TERMREF\]}, "; ").
    gsub(/\[TERMREF\]\s*/, l10n("#{@i18n.source}: ")).
    gsub(/\s*\[MODIFICATION\]\s*\[\/TERMREF\]/, l10n(", #{@i18n.modified} [/TERMREF]")).
    gsub(/\s*\[\/TERMREF\]\s*/, l10n("")).
    gsub(/\s*\[MODIFICATION\]/, l10n(", #{@i18n.modified} &mdash; "))
end

#terms_parse(node, out) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/isodoc/iec/base_convert.rb', line 67

def terms_parse(node, out)
  return super unless @is_iev
  page_break(out)
  out.div **attr_code(id: node["id"]) do |div|
    out.p(**{ class: "zzSTDTitle2" }) do |p|
      p.b do |b|
        node&.at(ns("./title"))&.children&.each { |c2| parse(c2, b) }
      end
    end
    node.children.reject { |c1| c1.name == "title" }.each do |c1|
      parse(c1, div)
    end
  end
end