metanorma-iec 1.1.2 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/lib/asciidoctor/iec/basicdoc.rng +31 -1
  3. data/lib/asciidoctor/iec/converter.rb +6 -15
  4. data/lib/asciidoctor/iec/front.rb +4 -4
  5. data/lib/asciidoctor/iec/isodoc.rng +124 -15
  6. data/lib/isodoc/iec/base_convert.rb +6 -58
  7. data/lib/isodoc/iec/html/htmlstyle.css +962 -0
  8. data/lib/isodoc/iec/html/isodoc.css +857 -0
  9. data/lib/isodoc/iec/html/isodoc.scss +19 -4
  10. data/lib/isodoc/iec/html/wordstyle.css +2013 -0
  11. data/lib/isodoc/iec/html/wordstyle.scss +15 -10
  12. data/lib/isodoc/iec/html_convert.rb +2 -0
  13. data/lib/isodoc/iec/i18n-en.yaml +13 -0
  14. data/lib/isodoc/iec/i18n-fr.yaml +13 -0
  15. data/lib/isodoc/iec/i18n-zh-Hans.yaml +11 -0
  16. data/lib/isodoc/iec/i18n.rb +19 -0
  17. data/lib/isodoc/iec/iec.international-standard.xsl +1997 -1480
  18. data/lib/isodoc/iec/init.rb +29 -0
  19. data/lib/isodoc/iec/presentation_xml_convert.rb +26 -1
  20. data/lib/isodoc/iec/word_convert.rb +3 -1
  21. data/lib/isodoc/iec/xref.rb +1 -1
  22. data/lib/metanorma/iec/version.rb +1 -1
  23. data/metanorma-iec.gemspec +2 -2
  24. data/spec/asciidoctor-iec/blocks_spec.rb +1 -1
  25. data/spec/asciidoctor-iec/cleanup_spec.rb +32 -8
  26. data/spec/asciidoctor-iec/iev_spec.rb +74 -1
  27. data/spec/asciidoctor-iec/inline_spec.rb +8 -2
  28. data/spec/asciidoctor-iec/section_spec.rb +17 -15
  29. data/spec/isodoc/blocks_spec.rb +66 -1
  30. data/spec/isodoc/i18n_spec.rb +296 -244
  31. data/spec/isodoc/iev_spec.rb +221 -18
  32. data/spec/isodoc/inline_spec.rb +97 -73
  33. data/spec/isodoc/iso_spec.rb +6 -0
  34. data/spec/isodoc/postproc_spec.rb +15 -29
  35. data/spec/isodoc/ref_spec.rb +141 -14
  36. data/spec/isodoc/section_spec.rb +112 -102
  37. data/spec/isodoc/terms_spec.rb +67 -53
  38. data/spec/metanorma/processor_spec.rb +2 -1
  39. metadata +11 -9
  40. data/lib/asciidoctor/iec/i18n-en.yaml +0 -12
  41. data/lib/asciidoctor/iec/i18n-fr.yaml +0 -11
  42. data/lib/asciidoctor/iec/i18n-zh-Hans.yaml +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a03790c16ae55ccf7da30ce41dfe6545ccf0da95ad4d4df47bdd4195df78c1fe
4
- data.tar.gz: 35343d7963ac64e990d2745982d8973d5e73877a1185a6c6b63793db33ee99fb
3
+ metadata.gz: 9b5b65151b0f1bdda67f0206c9e02f13dbbadefe58e8a63ccbafea9bf61af540
4
+ data.tar.gz: a37b42bed9ac34b9a52b34f49742f0e37d2cf640517dc99ea991fef86b0b4b9e
5
5
  SHA512:
6
- metadata.gz: a99840caae5508f6568548c9b9786027c883872ec659384498c46f42a7e5ed3d7976cd4a8505c4e1382306ed8d7a7ef29dd6e704107e675e36b5a2a11991d945
7
- data.tar.gz: 2d31918fd1515324b6614518999a5a9575c8426ffedb84076fbd4adcfd7ed7f12708adef7ed196276b8168ab1390abeca2c11c49d28a1df1ccf78c465caba867
6
+ metadata.gz: 6f38bd62a85f6ad02553c35af8cba7c77d65d484f114d7a7b5090b1562765164e91f06109ba48f3ec5a1953e166d22a947061bfa26865b9ff27bee83fa170cff
7
+ data.tar.gz: 276a2c079699f9cfb02bad08dfcf5825a4e11b48cfc66c0c54256b1fa76089c8bb7039e2334a7656c21e84a10b6b535421ec9213df4f7b92d7de7e4fd44a3e81
@@ -158,7 +158,17 @@
158
158
  <data type="ID"/>
159
159
  </attribute>
160
160
  <oneOrMore>
161
- <ref name="paragraph"/>
161
+ <choice>
162
+ <ref name="formula"/>
163
+ <ref name="ul"/>
164
+ <ref name="ol"/>
165
+ <ref name="dl"/>
166
+ <ref name="quote"/>
167
+ <ref name="sourcecode"/>
168
+ <ref name="paragraph"/>
169
+ <ref name="table"/>
170
+ <ref name="figure"/>
171
+ </choice>
162
172
  </oneOrMore>
163
173
  </element>
164
174
  </define>
@@ -402,6 +412,16 @@
402
412
  </choice>
403
413
  </attribute>
404
414
  </optional>
415
+ <optional>
416
+ <attribute name="valign">
417
+ <choice>
418
+ <value>top</value>
419
+ <value>middle</value>
420
+ <value>bottom</value>
421
+ <value>baseline</value>
422
+ </choice>
423
+ </attribute>
424
+ </optional>
405
425
  <choice>
406
426
  <zeroOrMore>
407
427
  <ref name="TextElement"/>
@@ -429,6 +449,16 @@
429
449
  </choice>
430
450
  </attribute>
431
451
  </optional>
452
+ <optional>
453
+ <attribute name="valign">
454
+ <choice>
455
+ <value>top</value>
456
+ <value>middle</value>
457
+ <value>bottom</value>
458
+ <value>baseline</value>
459
+ </choice>
460
+ </attribute>
461
+ </optional>
432
462
  <choice>
433
463
  <zeroOrMore>
434
464
  <ref name="TextElement"/>
@@ -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
@@ -3,7 +3,7 @@ module Asciidoctor
3
3
  class Converter < ISO::Converter
4
4
  def metadata_author(node, xml)
5
5
  publishers = node.attr("publisher") || "IEC"
6
- publishers.split(/,[ ]?/).each do |p|
6
+ csv_split(publishers)&.each do |p|
7
7
  xml.contributor do |c|
8
8
  c.role **{ type: "author" }
9
9
  c.organization { |a| organization(a, p) }
@@ -13,7 +13,7 @@ module Asciidoctor
13
13
 
14
14
  def metadata_publisher(node, xml)
15
15
  publishers = node.attr("publisher") || "IEC"
16
- publishers.split(/,[ ]?/).each do |p|
16
+ csv_split(publishers)&.each do |p|
17
17
  xml.contributor do |c|
18
18
  c.role **{ type: "publisher" }
19
19
  c.organization { |a| organization(a, p) }
@@ -22,8 +22,8 @@ module Asciidoctor
22
22
  end
23
23
 
24
24
  def metadata_copyright(node, xml)
25
- publishers = node.attr("publisher") || "IEC"
26
- publishers.split(/,[ ]?/).each do |p|
25
+ publishers = node.attr("copyright-holder") || node.attr("publisher") || "IEC"
26
+ csv_split(publishers)&.each do |p|
27
27
  xml.copyright do |c|
28
28
  c.from (node.attr("copyright-year") || Date.today.year)
29
29
  c.owner do |owner|
@@ -42,8 +42,11 @@
42
42
  </define>
43
43
  <define name="xref">
44
44
  <element name="xref">
45
+ <!-- attribute target { xsd:IDREF }, -->
45
46
  <attribute name="target">
46
- <data type="IDREF"/>
47
+ <data type="string">
48
+ <param name="pattern">\i\c*|\c+#\c+</param>
49
+ </data>
47
50
  </attribute>
48
51
  <optional>
49
52
  <attribute name="type">
@@ -578,6 +581,8 @@
578
581
  <ref name="ol"/>
579
582
  <ref name="dl"/>
580
583
  <ref name="formula"/>
584
+ <ref name="quote"/>
585
+ <ref name="sourcecode"/>
581
586
  </choice>
582
587
  </oneOrMore>
583
588
  </element>
@@ -661,6 +666,16 @@
661
666
  </choice>
662
667
  </attribute>
663
668
  </optional>
669
+ <optional>
670
+ <attribute name="valign">
671
+ <choice>
672
+ <value>top</value>
673
+ <value>middle</value>
674
+ <value>bottom</value>
675
+ <value>baseline</value>
676
+ </choice>
677
+ </attribute>
678
+ </optional>
664
679
  <choice>
665
680
  <zeroOrMore>
666
681
  <choice>
@@ -697,6 +712,16 @@
697
712
  </choice>
698
713
  </attribute>
699
714
  </optional>
715
+ <optional>
716
+ <attribute name="valign">
717
+ <choice>
718
+ <value>top</value>
719
+ <value>middle</value>
720
+ <value>bottom</value>
721
+ <value>baseline</value>
722
+ </choice>
723
+ </attribute>
724
+ </optional>
700
725
  <choice>
701
726
  <zeroOrMore>
702
727
  <choice>
@@ -922,6 +947,9 @@
922
947
  <optional>
923
948
  <attribute name="script"/>
924
949
  </optional>
950
+ <optional>
951
+ <attribute name="type"/>
952
+ </optional>
925
953
  <optional>
926
954
  <attribute name="obligation">
927
955
  <choice>
@@ -961,9 +989,6 @@
961
989
  </define>
962
990
  <define name="content-subsection">
963
991
  <element name="clause">
964
- <optional>
965
- <attribute name="type"/>
966
- </optional>
967
992
  <ref name="Content-Section"/>
968
993
  </element>
969
994
  </define>
@@ -992,6 +1017,9 @@
992
1017
  </choice>
993
1018
  </attribute>
994
1019
  </optional>
1020
+ <optional>
1021
+ <attribute name="type"/>
1022
+ </optional>
995
1023
  <optional>
996
1024
  <ref name="section-title"/>
997
1025
  </optional>
@@ -1011,9 +1039,6 @@
1011
1039
  </define>
1012
1040
  <define name="clause">
1013
1041
  <element name="clause">
1014
- <optional>
1015
- <attribute name="type"/>
1016
- </optional>
1017
1042
  <ref name="Clause-Section"/>
1018
1043
  </element>
1019
1044
  </define>
@@ -1042,18 +1067,24 @@
1042
1067
  </choice>
1043
1068
  </attribute>
1044
1069
  </optional>
1070
+ <optional>
1071
+ <attribute name="type"/>
1072
+ </optional>
1045
1073
  <optional>
1046
1074
  <ref name="section-title"/>
1047
1075
  </optional>
1048
1076
  <group>
1049
- <group>
1050
- <zeroOrMore>
1051
- <ref name="BasicBlock"/>
1052
- </zeroOrMore>
1053
- <zeroOrMore>
1054
- <ref name="note"/>
1055
- </zeroOrMore>
1056
- </group>
1077
+ <choice>
1078
+ <group>
1079
+ <zeroOrMore>
1080
+ <ref name="BasicBlock"/>
1081
+ </zeroOrMore>
1082
+ <zeroOrMore>
1083
+ <ref name="note"/>
1084
+ </zeroOrMore>
1085
+ </group>
1086
+ <ref name="amend"/>
1087
+ </choice>
1057
1088
  <zeroOrMore>
1058
1089
  <choice>
1059
1090
  <ref name="clause-subsection"/>
@@ -1180,6 +1211,9 @@
1180
1211
  <optional>
1181
1212
  <attribute name="script"/>
1182
1213
  </optional>
1214
+ <optional>
1215
+ <attribute name="type"/>
1216
+ </optional>
1183
1217
  <optional>
1184
1218
  <attribute name="obligation">
1185
1219
  <choice>
@@ -1501,4 +1535,79 @@
1501
1535
  <ref name="CitationType"/>
1502
1536
  </element>
1503
1537
  </define>
1538
+ <define name="amend">
1539
+ <element name="amend">
1540
+ <optional>
1541
+ <attribute name="id">
1542
+ <data type="ID"/>
1543
+ </attribute>
1544
+ </optional>
1545
+ <attribute name="change">
1546
+ <choice>
1547
+ <value>add</value>
1548
+ <value>modify</value>
1549
+ <value>delete</value>
1550
+ </choice>
1551
+ </attribute>
1552
+ <optional>
1553
+ <attribute name="path"/>
1554
+ </optional>
1555
+ <optional>
1556
+ <attribute name="path_end"/>
1557
+ </optional>
1558
+ <optional>
1559
+ <attribute name="title"/>
1560
+ </optional>
1561
+ <optional>
1562
+ <element name="location">
1563
+ <zeroOrMore>
1564
+ <ref name="locality"/>
1565
+ </zeroOrMore>
1566
+ </element>
1567
+ </optional>
1568
+ <zeroOrMore>
1569
+ <ref name="autonumber"/>
1570
+ </zeroOrMore>
1571
+ <optional>
1572
+ <element name="description">
1573
+ <zeroOrMore>
1574
+ <ref name="BasicBlock"/>
1575
+ </zeroOrMore>
1576
+ </element>
1577
+ </optional>
1578
+ <optional>
1579
+ <element name="newcontent">
1580
+ <zeroOrMore>
1581
+ <ref name="BasicBlock"/>
1582
+ </zeroOrMore>
1583
+ </element>
1584
+ </optional>
1585
+ <optional>
1586
+ <element name="description">
1587
+ <zeroOrMore>
1588
+ <ref name="BasicBlock"/>
1589
+ </zeroOrMore>
1590
+ </element>
1591
+ </optional>
1592
+ </element>
1593
+ </define>
1594
+ <define name="autonumber">
1595
+ <element name="autonumber">
1596
+ <attribute name="type">
1597
+ <choice>
1598
+ <value>requirement</value>
1599
+ <value>recommendation</value>
1600
+ <value>permission</value>
1601
+ <value>table</value>
1602
+ <value>figure</value>
1603
+ <value>admonition</value>
1604
+ <value>formula</value>
1605
+ <value>sourcecode</value>
1606
+ <value>example</value>
1607
+ <value>note</value>
1608
+ </choice>
1609
+ </attribute>
1610
+ <text/>
1611
+ </element>
1612
+ </define>
1504
1613
  </grammar>
@@ -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,40 +52,6 @@ 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
-
84
- def introduction(isoxml, out)
85
- return super unless @is_iev
86
- f = isoxml.at(ns("//introduction")) || return
87
- title_attr = { class: "IntroTitle" }
88
- page_break(out)
89
- out.div **{ class: "Section3", id: f["id"] } do |div|
90
- clause_name(nil, @labels["introduction_iev"], div, title_attr)
91
- f.elements.each do |e|
92
- parse(e, div) unless e.name == "title"
93
- end
94
- end
95
- end
96
-
97
55
  def bibliography(isoxml, out)
98
56
  return super unless @is_iev
99
57
  end
@@ -112,7 +70,6 @@ module IsoDoc
112
70
  out.div **attr_code(id: node["id"]) do |div|
113
71
  out.p(**{ class: "zzSTDTitle2" }) do |p|
114
72
  p.b do |b|
115
- b << "#{@xrefs.anchor(node['id'], :label)} "
116
73
  node&.at(ns("./title"))&.children&.each { |c2| parse(c2, b) }
117
74
  end
118
75
  end
@@ -126,10 +83,10 @@ module IsoDoc
126
83
  return super unless @is_iev
127
84
  docxml.
128
85
  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]")).
86
+ gsub(/\[TERMREF\]\s*/, l10n("#{@i18n.source}: ")).
87
+ gsub(/\s*\[MODIFICATION\]\s*\[\/TERMREF\]/, l10n(", #{@i18n.modified} [/TERMREF]")).
131
88
  gsub(/\s*\[\/TERMREF\]\s*/, l10n("")).
132
- gsub(/\s*\[MODIFICATION\]/, l10n(", #{@modified_lbl} &mdash; "))
89
+ gsub(/\s*\[MODIFICATION\]/, l10n(", #{@i18n.modified} &mdash; "))
133
90
  end
134
91
 
135
92
  def set_termdomain(termdomain)
@@ -145,7 +102,7 @@ module IsoDoc
145
102
 
146
103
  def deprecated_term_parse(node, out)
147
104
  out.p **{ class: "DeprecatedTerms", style:"text-align:left;" } do |p|
148
- p << l10n("#{@deprecated_lbl}: ")
105
+ p << l10n("#{@i18n.deprecated}: ")
149
106
  node.children.each { |c| parse(c, p) }
150
107
  term_suffix(node, p)
151
108
  end
@@ -165,15 +122,6 @@ module IsoDoc
165
122
  term_suffix(node, p)
166
123
  end
167
124
  end
168
-
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
- def biblio_list(f, div, biblio)
174
- biblio = false
175
- super
176
- end
177
125
  end
178
126
  end
179
127
  end