metanorma-iec 1.4.4 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +4 -32
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/lib/isodoc/iec/base_convert.rb +25 -14
- data/lib/isodoc/iec/html/htmlstyle.css +36 -21
- data/lib/isodoc/iec/html/htmlstyle.scss +13 -7
- data/lib/isodoc/iec/html/wordstyle.css +13 -11
- data/lib/isodoc/iec/html/wordstyle.scss +13 -11
- data/lib/isodoc/iec/html_convert.rb +2 -1
- data/lib/isodoc/iec/i18n-fr.yaml +1 -1
- data/lib/isodoc/iec/iec.international-standard.xsl +1637 -1280
- data/lib/isodoc/iec/presentation_xml_convert.rb +37 -7
- data/lib/isodoc/iec/word_convert.rb +2 -0
- data/lib/isodoc/iec/xref.rb +9 -8
- data/lib/{asciidoctor → metanorma}/iec/basicdoc.rng +0 -0
- data/lib/{asciidoctor → metanorma}/iec/biblio.rng +2 -2
- data/lib/{asciidoctor → metanorma}/iec/converter.rb +22 -8
- data/lib/{asciidoctor → metanorma}/iec/front.rb +1 -1
- data/lib/{asciidoctor → metanorma}/iec/iec.rng +48 -0
- data/lib/{asciidoctor → metanorma}/iec/iec_intro_en.xml +0 -0
- data/lib/{asciidoctor → metanorma}/iec/iec_intro_fr.xml +0 -0
- data/lib/{asciidoctor → metanorma}/iec/isodoc.rng +104 -3
- data/lib/{asciidoctor → metanorma}/iec/isostandard.rng +0 -0
- data/lib/{asciidoctor → metanorma}/iec/reqt.rng +0 -0
- data/lib/metanorma/iec/version.rb +1 -1
- data/lib/metanorma-iec.rb +1 -1
- data/metanorma-iec.gemspec +1 -1
- data/spec/isodoc/i18n_spec.rb +2 -2
- data/spec/isodoc/iev_spec.rb +67 -57
- data/spec/isodoc/ref_spec.rb +359 -353
- data/spec/{asciidoctor → metanorma}/base_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/blocks_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/cleanup_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/iev_spec.rb +10 -2
- data/spec/{asciidoctor → metanorma}/inline_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/lists_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/section_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/validate_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- metadata +22 -22
@@ -63,7 +63,7 @@ module IsoDoc
|
|
63
63
|
end
|
64
64
|
docpart = docxml&.at(ns("//bibdata/ext/structuredidentifier/"\
|
65
65
|
"project-number/@part"))&.text or return
|
66
|
-
docxml.xpath(ns("//
|
66
|
+
docxml.xpath(ns("//termref[@base = 'IEV']")).each do |t|
|
67
67
|
concept_iev1(t, docpart, labels)
|
68
68
|
end
|
69
69
|
end
|
@@ -120,36 +120,66 @@ module IsoDoc
|
|
120
120
|
p = d.parent
|
121
121
|
designation_annotate(p, d.at(ns("./name")))
|
122
122
|
m << { lang: lg, script: Metanorma::Utils.default_script(lg),
|
123
|
-
designation: l10n_recursive(p.remove, lg) }
|
123
|
+
designation: l10n_recursive(p.remove, lg).to_xml.strip }
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
127
|
def l10n_recursive(xml, lang)
|
128
128
|
script = Metanorma::Utils.default_script(lang)
|
129
|
+
c = HTMLEntities.new
|
129
130
|
xml.traverse do |x|
|
130
131
|
next unless x.text?
|
131
132
|
|
132
|
-
|
133
|
+
text = c.encode(c.decode(x.text), :hexadecimal)
|
134
|
+
x.replace(cleanup_entities(l10n(text, lang, script), is_xml: false))
|
133
135
|
end
|
134
136
|
xml
|
135
137
|
end
|
136
138
|
|
139
|
+
def merge_otherlang_designations(desgn)
|
140
|
+
h = desgn.each_with_object({}) do |e, m|
|
141
|
+
if m[e[:lang]]
|
142
|
+
m[e[:lang]][:designation] += e[:designation]
|
143
|
+
else m[e[:lang]] = e
|
144
|
+
end
|
145
|
+
end
|
146
|
+
h.keys.sort.each_with_object([]) { |k, m| m << h[k] }
|
147
|
+
end
|
148
|
+
|
137
149
|
def otherlang_designations1(term, lgs)
|
138
|
-
pr =
|
150
|
+
pr = merge_otherlang_designations(
|
151
|
+
extract_otherlang_designations(term, lgs),
|
152
|
+
)
|
139
153
|
return if pr.empty?
|
140
154
|
|
141
155
|
prefs = pr.map do |p|
|
142
156
|
"<dt>#{p[:lang]}</dt>"\
|
143
157
|
"<dd language='#{p[:lang]}' script='#{p[:script]}'>"\
|
144
|
-
"#{p[:designation]
|
158
|
+
"#{cleanup_entities(p[:designation])}</dd>"
|
145
159
|
end
|
146
160
|
term << "<dl type='other-lang'>#{prefs.join}</dl>"
|
147
161
|
end
|
148
162
|
|
163
|
+
def related(docxml)
|
164
|
+
docxml.xpath(ns("//term[related]")).each { |f| move_related(f) }
|
165
|
+
super
|
166
|
+
end
|
167
|
+
|
168
|
+
def move_related(term)
|
169
|
+
defn = term.at(ns("./definition")) or return
|
170
|
+
term.xpath(ns("./related")).reverse.each do |r|
|
171
|
+
defn.next = r.remove
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
149
175
|
def related1(node)
|
150
176
|
lg = node&.at("./ancestor::xmlns:term/@language")&.text
|
151
177
|
@i18n = @i18n_lg[lg] if lg && @i18n_lg[lg]
|
152
|
-
|
178
|
+
p = node.at(ns("./preferred"))
|
179
|
+
ref = node.at(ns("./xref | ./eref | ./termref"))
|
180
|
+
label = @i18n.relatedterms[node["type"]].upcase
|
181
|
+
node.replace(l10n("<p>#{label}: "\
|
182
|
+
"#{p.children.to_xml} (#{ref.to_xml})</p>"))
|
153
183
|
@i18n = @i18n_lg["default"]
|
154
184
|
end
|
155
185
|
|
@@ -171,7 +201,7 @@ module IsoDoc
|
|
171
201
|
|
172
202
|
def termsource1_iev(elem)
|
173
203
|
while elem&.next_element&.name == "termsource"
|
174
|
-
elem << "; #{elem.next_element.remove.children.to_xml}"
|
204
|
+
elem << l10n("; #{elem.next_element.remove.children.to_xml}")
|
175
205
|
end
|
176
206
|
elem.children = l10n("#{@i18n.source}: #{elem.children.to_xml.strip}")
|
177
207
|
end
|
@@ -221,10 +221,12 @@ module IsoDoc
|
|
221
221
|
end
|
222
222
|
|
223
223
|
def annex_name(_annex, name, div)
|
224
|
+
preceding_floating_titles(name, div)
|
224
225
|
return if name.nil?
|
225
226
|
|
226
227
|
div.h1 **{ class: "Annex" } do |t|
|
227
228
|
name.children.each { |c2| parse(c2, t) }
|
229
|
+
clause_parse_subtitle(name, t)
|
228
230
|
end
|
229
231
|
end
|
230
232
|
|
data/lib/isodoc/iec/xref.rb
CHANGED
@@ -16,6 +16,7 @@ module IsoDoc
|
|
16
16
|
def initial_anchor_names(d)
|
17
17
|
super
|
18
18
|
return unless @is_iev
|
19
|
+
|
19
20
|
terms_iev_names(d)
|
20
21
|
middle_section_asset_names(d)
|
21
22
|
termnote_anchor_names(d)
|
@@ -24,21 +25,21 @@ module IsoDoc
|
|
24
25
|
|
25
26
|
def terms_iev_names(d)
|
26
27
|
d.xpath(ns("//sections/clause/terms")).each_with_index do |t, i|
|
27
|
-
num = "#{@iev_part}-%02d" % [i+1]
|
28
|
+
num = "#{@iev_part}-%02d" % [i + 1]
|
28
29
|
@anchors[t["id"]] =
|
29
|
-
{ label: num, xref: l10n("#{@labels[
|
30
|
-
type: "clause" }
|
31
|
-
t.xpath(ns("./term")).each_with_index do |c,
|
32
|
-
num2 = "%02d" % [
|
30
|
+
{ label: num, xref: l10n("#{@labels['section_iev']} #{num}"),
|
31
|
+
level: 2, type: "clause" }
|
32
|
+
t.xpath(ns("./term")).each_with_index do |c, j|
|
33
|
+
num2 = "%02d" % [j + 1]
|
33
34
|
section_names1(c, "#{num}-#{num2}", 3)
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
38
39
|
def annex_name_lbl(clause, num)
|
39
|
-
obl = l10n("(#{@labels[
|
40
|
-
obl = l10n("(#{@labels[
|
41
|
-
l10n("<strong>#{@labels[
|
40
|
+
obl = l10n("(#{@labels['inform_annex']})")
|
41
|
+
obl = l10n("(#{@labels['norm_annex']})") if clause["obligation"] == "normative"
|
42
|
+
l10n("<strong>#{@labels['annex']} #{num}</strong><br/>#{obl}")
|
42
43
|
end
|
43
44
|
end
|
44
45
|
end
|
File without changes
|
@@ -1,8 +1,9 @@
|
|
1
1
|
require "asciidoctor"
|
2
2
|
require "metanorma-iso"
|
3
|
+
require "metanorma/iso/converter"
|
3
4
|
require_relative "./front"
|
4
5
|
|
5
|
-
module
|
6
|
+
module Metanorma
|
6
7
|
module Iec
|
7
8
|
class Converter < ISO::Converter
|
8
9
|
XML_ROOT_TAG = "iec-standard".freeze
|
@@ -81,13 +82,6 @@ module Asciidoctor
|
|
81
82
|
end
|
82
83
|
end
|
83
84
|
|
84
|
-
def norm_ref_preface(node)
|
85
|
-
return super unless @is_iev
|
86
|
-
|
87
|
-
node.at("./title").next =
|
88
|
-
"<p>#{@i18n.norm_empty_pref}</p>"
|
89
|
-
end
|
90
|
-
|
91
85
|
def term_defs_boilerplate(div, source, term, preface, isodoc)
|
92
86
|
return super unless @is_iev
|
93
87
|
end
|
@@ -117,6 +111,26 @@ module Asciidoctor
|
|
117
111
|
end
|
118
112
|
|
119
113
|
def image_name_validate(xmldoc); end
|
114
|
+
|
115
|
+
def toc_cleanup(xmldoc)
|
116
|
+
toc_iev_cleanup(xmldoc) if @is_iev
|
117
|
+
super
|
118
|
+
end
|
119
|
+
|
120
|
+
def toc_iev_cleanup(xmldoc)
|
121
|
+
iev_variant_titles(xmldoc)
|
122
|
+
end
|
123
|
+
|
124
|
+
def iev_variant_titles(xmldoc)
|
125
|
+
id = xmldoc&.at("//bibdata/docidentifier[@type = 'ISO']")&.text
|
126
|
+
m = /60050-(\d+)/.match(id) or return
|
127
|
+
xmldoc.xpath("//sections/clause/terms/title").each_with_index do |t, i|
|
128
|
+
num = "%02d" % [i + 1]
|
129
|
+
t.next = "<variant-title type='toc'>"\
|
130
|
+
"#{@i18n.section_iev} #{m[1]}-#{num} – "\
|
131
|
+
"#{t.children.to_xml}</variant-title>"
|
132
|
+
end
|
133
|
+
end
|
120
134
|
end
|
121
135
|
end
|
122
136
|
end
|
@@ -57,6 +57,54 @@
|
|
57
57
|
<ref name="tc-sc-officers-note"/>
|
58
58
|
</optional>
|
59
59
|
</define>
|
60
|
+
<define name="term">
|
61
|
+
<element name="term">
|
62
|
+
<optional>
|
63
|
+
<attribute name="id">
|
64
|
+
<data type="ID"/>
|
65
|
+
</attribute>
|
66
|
+
</optional>
|
67
|
+
<optional>
|
68
|
+
<attribute name="language"/>
|
69
|
+
</optional>
|
70
|
+
<optional>
|
71
|
+
<attribute name="script"/>
|
72
|
+
</optional>
|
73
|
+
<optional>
|
74
|
+
<attribute name="tag"/>
|
75
|
+
</optional>
|
76
|
+
<optional>
|
77
|
+
<attribute name="multilingual-rendering">
|
78
|
+
<ref name="MultilingualRenderingType"/>
|
79
|
+
</attribute>
|
80
|
+
</optional>
|
81
|
+
<oneOrMore>
|
82
|
+
<ref name="preferred"/>
|
83
|
+
</oneOrMore>
|
84
|
+
<zeroOrMore>
|
85
|
+
<ref name="admitted"/>
|
86
|
+
</zeroOrMore>
|
87
|
+
<zeroOrMore>
|
88
|
+
<ref name="deprecates"/>
|
89
|
+
</zeroOrMore>
|
90
|
+
<optional>
|
91
|
+
<ref name="termdomain"/>
|
92
|
+
</optional>
|
93
|
+
<ref name="termdefinition"/>
|
94
|
+
<zeroOrMore>
|
95
|
+
<ref name="termnote"/>
|
96
|
+
</zeroOrMore>
|
97
|
+
<zeroOrMore>
|
98
|
+
<ref name="termexample"/>
|
99
|
+
</zeroOrMore>
|
100
|
+
<zeroOrMore>
|
101
|
+
<ref name="termsource"/>
|
102
|
+
</zeroOrMore>
|
103
|
+
<zeroOrMore>
|
104
|
+
<ref name="term"/>
|
105
|
+
</zeroOrMore>
|
106
|
+
</element>
|
107
|
+
</define>
|
60
108
|
</include>
|
61
109
|
<!-- end overrides -->
|
62
110
|
<define name="function">
|
File without changes
|
File without changes
|
@@ -32,6 +32,56 @@
|
|
32
32
|
<ref name="DocumentType"/>
|
33
33
|
</element>
|
34
34
|
</define>
|
35
|
+
<define name="index">
|
36
|
+
<element name="index">
|
37
|
+
<optional>
|
38
|
+
<attribute name="to">
|
39
|
+
<data type="IDREF"/>
|
40
|
+
</attribute>
|
41
|
+
</optional>
|
42
|
+
<element name="primary">
|
43
|
+
<oneOrMore>
|
44
|
+
<choice>
|
45
|
+
<ref name="PureTextElement"/>
|
46
|
+
<ref name="stem"/>
|
47
|
+
</choice>
|
48
|
+
</oneOrMore>
|
49
|
+
</element>
|
50
|
+
<optional>
|
51
|
+
<element name="secondary">
|
52
|
+
<oneOrMore>
|
53
|
+
<choice>
|
54
|
+
<ref name="PureTextElement"/>
|
55
|
+
<ref name="stem"/>
|
56
|
+
</choice>
|
57
|
+
</oneOrMore>
|
58
|
+
</element>
|
59
|
+
</optional>
|
60
|
+
<optional>
|
61
|
+
<element name="tertiary">
|
62
|
+
<oneOrMore>
|
63
|
+
<choice>
|
64
|
+
<ref name="PureTextElement"/>
|
65
|
+
<ref name="stem"/>
|
66
|
+
</choice>
|
67
|
+
</oneOrMore>
|
68
|
+
</element>
|
69
|
+
</optional>
|
70
|
+
</element>
|
71
|
+
</define>
|
72
|
+
<define name="bibitem">
|
73
|
+
<element name="bibitem">
|
74
|
+
<attribute name="id">
|
75
|
+
<data type="ID"/>
|
76
|
+
</attribute>
|
77
|
+
<optional>
|
78
|
+
<attribute name="hidden">
|
79
|
+
<data type="boolean"/>
|
80
|
+
</attribute>
|
81
|
+
</optional>
|
82
|
+
<ref name="BibliographicItem"/>
|
83
|
+
</element>
|
84
|
+
</define>
|
35
85
|
<define name="section-title">
|
36
86
|
<element name="title">
|
37
87
|
<zeroOrMore>
|
@@ -690,6 +740,7 @@
|
|
690
740
|
<ref name="terms"/>
|
691
741
|
<ref name="term-clause"/>
|
692
742
|
<ref name="definitions"/>
|
743
|
+
<ref name="floating-title"/>
|
693
744
|
</choice>
|
694
745
|
</oneOrMore>
|
695
746
|
</element>
|
@@ -1013,6 +1064,26 @@
|
|
1013
1064
|
</zeroOrMore>
|
1014
1065
|
</element>
|
1015
1066
|
</define>
|
1067
|
+
<define name="sub">
|
1068
|
+
<element name="sub">
|
1069
|
+
<zeroOrMore>
|
1070
|
+
<choice>
|
1071
|
+
<ref name="PureTextElement"/>
|
1072
|
+
<ref name="stem"/>
|
1073
|
+
</choice>
|
1074
|
+
</zeroOrMore>
|
1075
|
+
</element>
|
1076
|
+
</define>
|
1077
|
+
<define name="sup">
|
1078
|
+
<element name="sup">
|
1079
|
+
<zeroOrMore>
|
1080
|
+
<choice>
|
1081
|
+
<ref name="PureTextElement"/>
|
1082
|
+
<ref name="stem"/>
|
1083
|
+
</choice>
|
1084
|
+
</zeroOrMore>
|
1085
|
+
</element>
|
1086
|
+
</define>
|
1016
1087
|
<define name="pagebreak">
|
1017
1088
|
<element name="pagebreak">
|
1018
1089
|
<optional>
|
@@ -1680,6 +1751,7 @@
|
|
1680
1751
|
<ref name="clause-subsection"/>
|
1681
1752
|
<ref name="terms"/>
|
1682
1753
|
<ref name="definitions"/>
|
1754
|
+
<ref name="floating-title"/>
|
1683
1755
|
</choice>
|
1684
1756
|
</oneOrMore>
|
1685
1757
|
</choice>
|
@@ -1722,6 +1794,7 @@
|
|
1722
1794
|
<ref name="terms"/>
|
1723
1795
|
<ref name="definitions"/>
|
1724
1796
|
<ref name="references"/>
|
1797
|
+
<ref name="floating-title"/>
|
1725
1798
|
</choice>
|
1726
1799
|
</zeroOrMore>
|
1727
1800
|
</group>
|
@@ -1973,7 +2046,11 @@
|
|
1973
2046
|
</optional>
|
1974
2047
|
<element name="name">
|
1975
2048
|
<zeroOrMore>
|
1976
|
-
<
|
2049
|
+
<choice>
|
2050
|
+
<ref name="PureTextElement"/>
|
2051
|
+
<ref name="stem"/>
|
2052
|
+
<ref name="index"/>
|
2053
|
+
</choice>
|
1977
2054
|
</zeroOrMore>
|
1978
2055
|
</element>
|
1979
2056
|
<optional>
|
@@ -1987,7 +2064,7 @@
|
|
1987
2064
|
</element>
|
1988
2065
|
</optional>
|
1989
2066
|
<optional>
|
1990
|
-
<element name="grammar
|
2067
|
+
<element name="grammar">
|
1991
2068
|
<ref name="Grammar"/>
|
1992
2069
|
</element>
|
1993
2070
|
</optional>
|
@@ -2196,7 +2273,18 @@
|
|
2196
2273
|
<ref name="MultilingualRenderingType"/>
|
2197
2274
|
</attribute>
|
2198
2275
|
</optional>
|
2199
|
-
<
|
2276
|
+
<oneOrMore>
|
2277
|
+
<choice>
|
2278
|
+
<ref name="formula"/>
|
2279
|
+
<ref name="ul"/>
|
2280
|
+
<ref name="ol"/>
|
2281
|
+
<ref name="dl"/>
|
2282
|
+
<ref name="quote"/>
|
2283
|
+
<ref name="sourcecode"/>
|
2284
|
+
<ref name="paragraph"/>
|
2285
|
+
<ref name="figure"/>
|
2286
|
+
</choice>
|
2287
|
+
</oneOrMore>
|
2200
2288
|
</element>
|
2201
2289
|
</define>
|
2202
2290
|
<define name="termsource">
|
@@ -2530,4 +2618,17 @@
|
|
2530
2618
|
</oneOrMore>
|
2531
2619
|
</element>
|
2532
2620
|
</define>
|
2621
|
+
<define name="floating-title">
|
2622
|
+
<element name="floating-title">
|
2623
|
+
<attribute name="id">
|
2624
|
+
<data type="ID"/>
|
2625
|
+
</attribute>
|
2626
|
+
<attribute name="depth">
|
2627
|
+
<data type="int"/>
|
2628
|
+
</attribute>
|
2629
|
+
<zeroOrMore>
|
2630
|
+
<ref name="TextElement"/>
|
2631
|
+
</zeroOrMore>
|
2632
|
+
</element>
|
2633
|
+
</define>
|
2533
2634
|
</grammar>
|
File without changes
|
File without changes
|
data/lib/metanorma-iec.rb
CHANGED
data/metanorma-iec.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.test_files = `git ls-files -- {spec}/*`.split("\n")
|
28
28
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
29
29
|
|
30
|
-
spec.add_dependency "metanorma-iso", "~>
|
30
|
+
spec.add_dependency "metanorma-iso", "~> 2.0.0"
|
31
31
|
spec.add_dependency "ruby-jing"
|
32
32
|
|
33
33
|
spec.add_development_dependency "debug"
|
data/spec/isodoc/i18n_spec.rb
CHANGED
@@ -83,7 +83,7 @@ RSpec.describe IsoDoc do
|
|
83
83
|
<docnumber>1</docnumber>
|
84
84
|
<language current="true">en</language>
|
85
85
|
<ext>
|
86
|
-
<doctype language="">international-standard</doctype><doctype language="fr">Norme
|
86
|
+
<doctype language="">international-standard</doctype><doctype language="fr">Norme internationale</doctype><doctype language="en">International Standard</doctype>
|
87
87
|
<horizontal language="">true</horizontal><horizontal language="fr">Norme horizontale</horizontal><horizontal language="en">Horizontal Standard</horizontal>
|
88
88
|
<function language="">emc</function><function language="fr">Publication fondamentale en CEM</function><function language="en">Basic EMC Publication</function>
|
89
89
|
</ext>
|
@@ -444,7 +444,7 @@ RSpec.describe IsoDoc do
|
|
444
444
|
<bibdata>
|
445
445
|
<language current="true">fr</language>
|
446
446
|
<ext>
|
447
|
-
<doctype language="">international-standard</doctype><doctype language="fr">Norme
|
447
|
+
<doctype language="">international-standard</doctype><doctype language="fr">Norme internationale</doctype><doctype language="en">International Standard</doctype>
|
448
448
|
<horizontal language="">false</horizontal>
|
449
449
|
<function language="">emc</function><function language="fr">Publication fondamentale en CEM</function><function language="en">Basic EMC Publication</function>
|
450
450
|
</ext>
|