metanorma-iec 1.1.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 771cadd9f9bf1460c635f15452e434e54daef0e326527745cd7813369385da96
4
- data.tar.gz: 46d1d213d84f937c7346cb2e9d33c92b9dae13544cec218a04a4d7b30638845c
3
+ metadata.gz: e72099c93ed3258ff5f342d7e2904b9e5a4d34e00a0546a0f77e0993f2bf824f
4
+ data.tar.gz: d12c6b7259b187bf5718140ad47addf83b19281bcd34e1f1bcb80b8f695e39ef
5
5
  SHA512:
6
- metadata.gz: d4166a09b5768d7ec0bdeb4527764af193dac81ef3cc99ac728224fffc9120833d1bd8063c0cb82922d263b473349e279ef8a95a59774e4750185bb0d2eef1c2
7
- data.tar.gz: 5278271ffad07995fc3fdba9715371091d1bbc2743b94f7903d2cfe4e706c046c48de8f06901d70680bf04d878b1af291a8fa37a716ab8e8697ea88fcf112693
6
+ metadata.gz: 86a009528de61d607c417a99ca4090a829c26e86e2f91c9ab513b3800456d68a544c7fc18eaaeaac0fe0b85474c0fdd1f34d9aaf653ddc54a263ad98dae1e10d
7
+ data.tar.gz: 19fb4b433da961438c84da0cc0fbc697a7a7d684f37725a6b4f6ad2c193b5e38cefc524405c9071fcfa376e10f85f30101bb3060f2a742db9ecea3ea29c6e518
@@ -38,20 +38,6 @@ module Asciidoctor
38
38
  File.join(File.dirname(__FILE__), "iec.rng"))
39
39
  end
40
40
 
41
- def load_yaml(lang, script)
42
- y = if @i18nyaml then YAML.load_file(@i18nyaml)
43
- elsif lang == "en"
44
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
45
- elsif lang == "fr"
46
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-fr.yaml"))
47
- elsif lang == "zh" && script == "Hans"
48
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-zh-Hans.yaml"))
49
- else
50
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
51
- end
52
- super.merge(y)
53
- end
54
-
55
41
  def html_converter(node)
56
42
  node.nil? ? IsoDoc::Iec::HtmlConvert.new({}) :
57
43
  IsoDoc::Iec::HtmlConvert.new(html_extract_attributes(node))
@@ -75,7 +61,7 @@ module Asciidoctor
75
61
  def norm_ref_preface(f)
76
62
  return super unless @is_iev
77
63
  f.at("./title").next =
78
- "<p>#{@norm_empty_pref}</p>"
64
+ "<p>#{@i18n.norm_empty_pref}</p>"
79
65
  end
80
66
 
81
67
  def term_defs_boilerplate(div, source, term, preface, isodoc)
@@ -84,6 +70,11 @@ module Asciidoctor
84
70
 
85
71
  def sts_converter(node)
86
72
  end
73
+
74
+ def sections_names_cleanup(x)
75
+ super
76
+ @is_iev and replace_title(x, "//introduction", @i18n&.introduction_iev)
77
+ end
87
78
  end
88
79
  end
89
80
  end
@@ -922,6 +922,9 @@
922
922
  <optional>
923
923
  <attribute name="script"/>
924
924
  </optional>
925
+ <optional>
926
+ <attribute name="type"/>
927
+ </optional>
925
928
  <optional>
926
929
  <attribute name="obligation">
927
930
  <choice>
@@ -961,9 +964,6 @@
961
964
  </define>
962
965
  <define name="content-subsection">
963
966
  <element name="clause">
964
- <optional>
965
- <attribute name="type"/>
966
- </optional>
967
967
  <ref name="Content-Section"/>
968
968
  </element>
969
969
  </define>
@@ -992,6 +992,9 @@
992
992
  </choice>
993
993
  </attribute>
994
994
  </optional>
995
+ <optional>
996
+ <attribute name="type"/>
997
+ </optional>
995
998
  <optional>
996
999
  <ref name="section-title"/>
997
1000
  </optional>
@@ -1011,9 +1014,6 @@
1011
1014
  </define>
1012
1015
  <define name="clause">
1013
1016
  <element name="clause">
1014
- <optional>
1015
- <attribute name="type"/>
1016
- </optional>
1017
1017
  <ref name="Clause-Section"/>
1018
1018
  </element>
1019
1019
  </define>
@@ -1042,6 +1042,9 @@
1042
1042
  </choice>
1043
1043
  </attribute>
1044
1044
  </optional>
1045
+ <optional>
1046
+ <attribute name="type"/>
1047
+ </optional>
1045
1048
  <optional>
1046
1049
  <ref name="section-title"/>
1047
1050
  </optional>
@@ -1180,6 +1183,9 @@
1180
1183
  <optional>
1181
1184
  <attribute name="script"/>
1182
1185
  </optional>
1186
+ <optional>
1187
+ <attribute name="type"/>
1188
+ </optional>
1183
1189
  <optional>
1184
1190
  <attribute name="obligation">
1185
1191
  <choice>
@@ -4,14 +4,6 @@ require "metanorma-iso"
4
4
  module IsoDoc
5
5
  module Iec
6
6
  module BaseConvert
7
- def metadata_init(lang, script, labels)
8
- @meta = Metadata.new(lang, script, labels)
9
- end
10
-
11
- def xref_init(lang, script, klass, labels, options)
12
- @xrefs = Xref.new(lang, script, klass, labels, options)
13
- end
14
-
15
7
  def boilerplate(node, out)
16
8
  # processed in foreword instead
17
9
  end
@@ -23,7 +15,7 @@ module IsoDoc
23
15
  iec_orgname(out)
24
16
  middle_title(out)
25
17
  out.div **attr_code(id: f ? f["id"] : "") do |s|
26
- s.h1(**{ class: "ForewordTitle" }) { |h1| h1 << @foreword_lbl }
18
+ s.h1(**{ class: "ForewordTitle" }) { |h1| h1 << @i18n.foreword }
27
19
  @meta.get[:doctype] == "Amendment" or
28
20
  s.div **attr_code(class: "boilerplate_legal") do |s1|
29
21
  b&.elements&.each { |e| parse(e, s1) }
@@ -33,7 +25,7 @@ module IsoDoc
33
25
  end
34
26
 
35
27
  def iec_orgname(out)
36
- out.p(**{ class: "zzSTDTitle1" }) { |p| p << @labels["IEC"] }
28
+ out.p(**{ class: "zzSTDTitle1" }) { |p| p << @i18n.get["IEC"] }
37
29
  out.p(**{ class: "zzSTDTitle1" }) { |p| p << "____________" }
38
30
  out.p(**{ class: "zzSTDTitle1" }) { |p| p << "&nbsp;" }
39
31
  end
@@ -60,39 +52,20 @@ module IsoDoc
60
52
  out.p(**{ class: "zzSTDTitle1" }) { |p| p << "&nbsp;" }
61
53
  end
62
54
 
63
- def load_yaml(lang, script)
64
- y = if @i18nyaml then YAML.load_file(@i18nyaml)
65
- elsif lang == "en"
66
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
67
- elsif lang == "fr"
68
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-fr.yaml"))
69
- elsif lang == "zh" && script == "Hans"
70
- YAML.load_file(File.join(File.dirname(__FILE__),
71
- "i18n-zh-Hans.yaml"))
72
- else
73
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
74
- end
75
- super.merge(y)
76
- end
77
-
78
- def convert1(docxml, filename, dir)
79
- id = docxml&.at(ns("//bibdata/docnumber"))&.text
80
- @is_iev = id == "60050"
81
- super
82
- end
83
-
55
+ =begin
84
56
  def introduction(isoxml, out)
85
57
  return super unless @is_iev
86
58
  f = isoxml.at(ns("//introduction")) || return
87
59
  title_attr = { class: "IntroTitle" }
88
60
  page_break(out)
89
61
  out.div **{ class: "Section3", id: f["id"] } do |div|
90
- clause_name(nil, @labels["introduction_iev"], div, title_attr)
62
+ clause_name(nil, @i18n.get["introduction_iev"], div, title_attr)
91
63
  f.elements.each do |e|
92
64
  parse(e, div) unless e.name == "title"
93
65
  end
94
66
  end
95
67
  end
68
+ =end
96
69
 
97
70
  def bibliography(isoxml, out)
98
71
  return super unless @is_iev
@@ -112,7 +85,6 @@ module IsoDoc
112
85
  out.div **attr_code(id: node["id"]) do |div|
113
86
  out.p(**{ class: "zzSTDTitle2" }) do |p|
114
87
  p.b do |b|
115
- b << "#{@xrefs.anchor(node['id'], :label)} "
116
88
  node&.at(ns("./title"))&.children&.each { |c2| parse(c2, b) }
117
89
  end
118
90
  end
@@ -126,10 +98,10 @@ module IsoDoc
126
98
  return super unless @is_iev
127
99
  docxml.
128
100
  gsub(%r{\s*\[/TERMREF\]\s*</p>\s*<p>\s*\[TERMREF\]}, "; ").
129
- gsub(/\[TERMREF\]\s*/, l10n("#{@source_lbl}: ")).
130
- gsub(/\s*\[MODIFICATION\]\s*\[\/TERMREF\]/, l10n(", #{@modified_lbl} [/TERMREF]")).
101
+ gsub(/\[TERMREF\]\s*/, l10n("#{@i18n.source}: ")).
102
+ gsub(/\s*\[MODIFICATION\]\s*\[\/TERMREF\]/, l10n(", #{@i18n.modified} [/TERMREF]")).
131
103
  gsub(/\s*\[\/TERMREF\]\s*/, l10n("")).
132
- gsub(/\s*\[MODIFICATION\]/, l10n(", #{@modified_lbl} &mdash; "))
104
+ gsub(/\s*\[MODIFICATION\]/, l10n(", #{@i18n.modified} &mdash; "))
133
105
  end
134
106
 
135
107
  def set_termdomain(termdomain)
@@ -145,7 +117,7 @@ module IsoDoc
145
117
 
146
118
  def deprecated_term_parse(node, out)
147
119
  out.p **{ class: "DeprecatedTerms", style:"text-align:left;" } do |p|
148
- p << l10n("#{@deprecated_lbl}: ")
120
+ p << l10n("#{@i18n.deprecated}: ")
149
121
  node.children.each { |c| parse(c, p) }
150
122
  term_suffix(node, p)
151
123
  end
@@ -166,10 +138,6 @@ module IsoDoc
166
138
  end
167
139
  end
168
140
 
169
- def clause_parse_title(node, div, c1, out)
170
- IsoDoc::Common.instance_method(:clause_parse_title).bind(self).call(node, div, c1, out)
171
- end
172
-
173
141
  def biblio_list(f, div, biblio)
174
142
  biblio = false
175
143
  super
@@ -1,6 +1,7 @@
1
1
  require "isodoc"
2
2
  require "metanorma-iso"
3
3
  require_relative "base_convert"
4
+ require_relative "init"
4
5
 
5
6
  module IsoDoc
6
7
  module Iec
@@ -36,6 +37,7 @@ module IsoDoc
36
37
  end
37
38
 
38
39
  include BaseConvert
40
+ include Init
39
41
  end
40
42
  end
41
43
  end
@@ -2,4 +2,17 @@ introduction: INTRODUCTION
2
2
  introduction_iev: INTRODUCTION<br/>Principles and rules followed
3
3
  foreword: FOREWORD
4
4
  IEC: INTERNATIONAL ELECTROTECHNICAL COMMISSION
5
+ formula: Equation
6
+ inequality: Inequality
5
7
  section_iev: Section
8
+ term_def_boilerplate: |
9
+ <p>ISO and IEC maintain terminological databases for use in
10
+ standardization at the following addresses:</p>
11
+
12
+ <ul>
13
+ <li> <p>IEC Electropedia: available at
14
+ <link target="http://www.electropedia.org"/>
15
+ </p> </li>
16
+ <li> <p>ISO Online browsing platform: available at
17
+ <link target="http://www.iso.org/obp"/></p> </li>
18
+ </ul>
@@ -1,5 +1,18 @@
1
1
  introduction: INTRODUCTION
2
2
  introduction_iev: INTRODUCTION<br/>Principes d’établissement et règles suivies
3
3
  foreword: AVANT-PROPOS
4
+ formula: Equation
5
+ inequality: Inégalité
4
6
  IEC: COMMISSION ELECTROTECHNIQUE INTERNATIONALE
5
7
  section_iev: Section
8
+ term_def_boilerplate: |
9
+ <p>L'ISO et l'IEC tiennent à jour des bases de données terminologiques
10
+ destinées à être utilisées en normalisation, consultables aux adresses
11
+ suivantes:</p>
12
+ <ul>
13
+ <li> <p>IEC Electropedia: disponible à l'adresse
14
+ <link target="http://www.electropedia.org"/>
15
+ </p> </li>
16
+ <li> <p>ISO Online browsing platform: disponible à l'adresse
17
+ <link target="http://www.iso.org/obp"/></p> </li>
18
+ </ul>
@@ -1,3 +1,14 @@
1
1
  introduction: 引言
2
2
  foreword: 前言
3
3
  IEC: 国际电工委员会
4
+ formula: 方程式
5
+ inequality: 不等式
6
+ term_def_boilerplate: |
7
+ <p>ISO和IEC用于标准化的术语数据库地址如下:</p>
8
+ <ul>
9
+ <li> <p>IEC Electropedia:
10
+ 位于<link target="http://www.electropedia.org"/>
11
+ </p> </li>
12
+ <li> <p>ISO在线浏览平台:
13
+ 位于<link target="http://www.iso.org/obp"/></p></li>
14
+ </ul>
@@ -0,0 +1,19 @@
1
+ module IsoDoc
2
+ module Iec
3
+ class I18n < IsoDoc::Iso::I18n
4
+ def load_yaml1(lang, script)
5
+ y = if lang == "en"
6
+ YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
7
+ elsif lang == "fr"
8
+ YAML.load_file(File.join(File.dirname(__FILE__), "i18n-fr.yaml"))
9
+ elsif lang == "zh" && script == "Hans"
10
+ YAML.load_file(File.join(File.dirname(__FILE__), "i18n-zh-Hans.yaml"))
11
+ else
12
+ YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
13
+ end
14
+ super.merge(y)
15
+ end
16
+ end
17
+ end
18
+ end
19
+
@@ -0,0 +1,29 @@
1
+ require "isodoc"
2
+ require_relative "metadata"
3
+ require_relative "xref"
4
+ require_relative "i18n"
5
+
6
+ module IsoDoc
7
+ module Iec
8
+ module Init
9
+ def metadata_init(lang, script, labels)
10
+ @meta = Metadata.new(lang, script, labels)
11
+ end
12
+
13
+ def xref_init(lang, script, klass, labels, options)
14
+ @xrefs = Xref.new(lang, script, HtmlConvert.new(language: lang, script: script), labels, options)
15
+ end
16
+
17
+ def i18n_init(lang, script, i18nyaml = nil)
18
+ @i18n = I18n.new(lang, script, i18nyaml || @i18nyaml)
19
+ end
20
+
21
+ def convert1(docxml, filename, dir)
22
+ id = docxml&.at(ns("//bibdata/docnumber"))&.text
23
+ @is_iev = id == "60050"
24
+ super
25
+ end
26
+ end
27
+ end
28
+ end
29
+
@@ -1,9 +1,34 @@
1
- require_relative "base_convert"
1
+ require_relative "init"
2
2
  require "isodoc"
3
3
 
4
4
  module IsoDoc
5
5
  module Iec
6
6
  class PresentationXMLConvert < IsoDoc::Iso::PresentationXMLConvert
7
+ def clause(docxml)
8
+ docxml.xpath(ns("//clause[not(ancestor::annex)] | "\
9
+ "//definitions | //references | "\
10
+ "//preface/introduction[clause]")).
11
+ each do |f|
12
+ clause1(f)
13
+ end
14
+ docxml.xpath(ns("//terms")).each do |f|
15
+ termclause1(f)
16
+ end
17
+ end
18
+
19
+ def termclause1(f)
20
+ return clause1(f) unless @is_iev
21
+ return if @suppressheadingnumbers || f["unnumbered"]
22
+ lbl = @xrefs.anchor(f['id'], :label, true) or return
23
+ prefix_name(f, " ", "#{lbl}#{clausedelim}", "title")
24
+ end
25
+
26
+ def clause1(f)
27
+ IsoDoc::PresentationXMLConvert.instance_method(:clause1).bind(self).
28
+ call(f)
29
+ end
30
+
31
+ include Init
7
32
  end
8
33
  end
9
34
  end
@@ -1,6 +1,7 @@
1
1
  require "isodoc"
2
2
  require "metanorma-iso"
3
3
  require_relative "base_convert"
4
+ require_relative "init"
4
5
 
5
6
  module IsoDoc
6
7
  module Iec
@@ -171,7 +172,7 @@ module IsoDoc
171
172
  div.p **attr_code(class: "formula") do |p|
172
173
  insert_tab(div, 1)
173
174
  parse(node.at(ns("./stem")), div)
174
- lbl = @xrefs.anchor(node['id'], :label, false)
175
+ lbl = node&.at(ns("./name"))&.text
175
176
  unless lbl.nil?
176
177
  insert_tab(div, 1)
177
178
  div << "(#{lbl})"
@@ -181,6 +182,7 @@ module IsoDoc
181
182
  end
182
183
 
183
184
  include BaseConvert
185
+ include Init
184
186
  end
185
187
  end
186
188
  end
@@ -38,7 +38,7 @@ module IsoDoc
38
38
  def annex_name_lbl(clause, num)
39
39
  obl = l10n("(#{@labels["inform_annex"]})")
40
40
  obl = l10n("(#{@labels["norm_annex"]})") if clause["obligation"] == "normative"
41
- l10n("<b>#{@labels["annex"]} #{num}</b><br/><br/>#{obl}")
41
+ l10n("<strong>#{@labels["annex"]} #{num}</strong><br/>#{obl}")
42
42
  end
43
43
  end
44
44
  end
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  module Iec
3
- VERSION = "1.1.3"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
6
6
 
@@ -28,8 +28,8 @@ Gem::Specification.new do |spec|
28
28
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
29
29
 
30
30
  spec.add_dependency "ruby-jing"
31
- spec.add_dependency "isodoc", "~> 1.1.0"
32
- spec.add_dependency "metanorma-iso", "~> 1.4.0"
31
+ spec.add_dependency "isodoc", "~> 1.2.0"
32
+ spec.add_dependency "metanorma-iso", "~> 1.5.0"
33
33
 
34
34
  spec.add_development_dependency "byebug"
35
35
  spec.add_development_dependency "sassc", "2.4.0"
@@ -265,7 +265,7 @@ RSpec.describe Asciidoctor::Iec do
265
265
  INPUT
266
266
  #{BLANK_HDR}
267
267
  <preface><foreword id="_" obligation="informative">
268
- <title>Foreword</title>
268
+ <title>FOREWORD</title>
269
269
  <p id="_">This is a preamble</p>
270
270
  </foreword></preface><sections>
271
271
  <clause id="_" inline-header="false" obligation="normative">