metanorma-iso 2.1.4 → 2.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/lib/isodoc/iso/html/isodoc-dis.css +1 -10
  3. data/lib/isodoc/iso/html/isodoc-dis.scss +1 -13
  4. data/lib/isodoc/iso/html/isodoc.css +4 -11
  5. data/lib/isodoc/iso/html/isodoc.scss +5 -15
  6. data/lib/isodoc/iso/html/style-human.css +3 -0
  7. data/lib/isodoc/iso/html/style-human.scss +4 -0
  8. data/lib/isodoc/iso/html/style-iso.css +3 -0
  9. data/lib/isodoc/iso/html/style-iso.scss +4 -0
  10. data/lib/isodoc/iso/i18n-en.yaml +1 -1
  11. data/lib/isodoc/iso/iso.amendment.xsl +3618 -2934
  12. data/lib/isodoc/iso/iso.international-standard.xsl +3618 -2934
  13. data/lib/isodoc/iso/presentation_xml_convert.rb +8 -6
  14. data/lib/isodoc/iso/word_cleanup.rb +50 -19
  15. data/lib/isodoc/iso/word_dis_cleanup.rb +2 -14
  16. data/lib/isodoc/iso/word_dis_convert.rb +1 -1
  17. data/lib/metanorma/iso/boilerplate-fr.xml +1 -1
  18. data/lib/metanorma/iso/boilerplate-ru.xml +1 -1
  19. data/lib/metanorma/iso/boilerplate.xml +1 -1
  20. data/lib/metanorma/iso/cleanup.rb +0 -1
  21. data/lib/metanorma/iso/front_id.rb +20 -1
  22. data/lib/metanorma/iso/isodoc.rng +16 -1
  23. data/lib/metanorma/iso/reqt.rng +1 -1
  24. data/lib/metanorma/iso/version.rb +1 -1
  25. data/metanorma-iso.gemspec +2 -1
  26. data/spec/isodoc/postproc_spec.rb +8 -75
  27. data/spec/isodoc/ref_spec.rb +123 -76
  28. data/spec/isodoc/terms_spec.rb +62 -0
  29. data/spec/isodoc/word_dis_spec.rb +133 -15
  30. data/spec/metanorma/base_spec.rb +19 -17
  31. data/spec/metanorma/cleanup_spec.rb +5 -5
  32. data/spec/metanorma/processor_spec.rb +1 -2
  33. data/spec/metanorma/refs_spec.rb +5 -3
  34. data/spec/metanorma/section_spec.rb +8 -8
  35. data/spec/spec_helper.rb +1 -1
  36. data/spec/vcr_cassettes/withdrawn_iso.yml +33 -33
  37. metadata +18 -4
@@ -178,12 +178,10 @@ module IsoDoc
178
178
  i18nhash: @i18n.get)
179
179
  end
180
180
 
181
- def bibrender(xml)
182
- unless xml.at(ns("./formattedref"))
183
- xml.children =
184
- "#{bibrenderer.render(xml.to_xml)}"\
185
- "#{xml.xpath(ns('./docidentifier | ./uri | ./note')).to_xml}"
186
- end
181
+ def bibrender_formattedref(formattedref, xml)
182
+ return if %w(techreport standard).include? xml["type"]
183
+
184
+ super
187
185
  end
188
186
 
189
187
  def ol_depth(node)
@@ -196,6 +194,10 @@ module IsoDoc
196
194
  type
197
195
  end
198
196
 
197
+ def related1(node)
198
+ node.remove
199
+ end
200
+
199
201
  include Init
200
202
  end
201
203
  end
@@ -11,11 +11,10 @@ module IsoDoc
11
11
  end
12
12
  end
13
13
 
14
- # force Annex h2 down to be p.h2Annex, so it is not picked up by ToC
15
14
  def word_annex_cleanup1(docxml, lvl)
16
15
  docxml.xpath("//h#{lvl}[ancestor::*[@class = 'Section3']]").each do |h2|
17
16
  h2.name = "p"
18
- h2["class"] = "h#{lvl}Annex"
17
+ h2["class"] = "a#{lvl}"
19
18
  end
20
19
  end
21
20
 
@@ -37,40 +36,72 @@ module IsoDoc
37
36
 
38
37
  def style_cleanup(docxml)
39
38
  word_annex_cleanup_h1(docxml)
40
- style_cleanup1(docxml)
39
+ figure_style(docxml)
40
+ new_styles(docxml)
41
41
  end
42
42
 
43
- def style_cleanup1(docxml)
44
- docxml.xpath("//*[@class = 'example']").each do |p|
45
- p["class"] = "Example"
43
+ def figure_style(docxml)
44
+ docxml.xpath("//div[@class = 'figure']").each do |f|
45
+ f["style"] ||= ""
46
+ f["style"] += "text-align:center;"
46
47
  end
48
+ end
49
+
50
+ def quote_style(docxml)
51
+ docxml.xpath("//div[@class = 'Quote' or @class = 'Note' or "\
52
+ "@class = 'Example' or @class = 'Admonition']").each do |d|
53
+ quote_style1(d)
54
+ end
55
+ end
56
+
57
+ def quote_style1(div)
58
+ div.xpath(".//li").each do |p|
59
+ p["style"] ||= ""
60
+ p["style"] += "font-size:#{default_fonts({})[:smallerfontsize]};"
61
+ end
62
+ end
63
+
64
+ STYLESMAP = {
65
+ example: "Example",
66
+ note: "Note",
67
+ Sourcecode: "Code",
68
+ tabletitle: "Tabletitle",
69
+ Biblio: "MsoNormal",
70
+ figure: "MsoNormal",
71
+ SourceTitle: "FigureTitle",
72
+ }.freeze
73
+
74
+ def new_styles(docxml)
75
+ STYLESMAP.each do |k, v|
76
+ docxml.xpath("//*[@class = '#{k}']").each { |s| s["class"] = v }
77
+ end
78
+ docxml.xpath("//div[@class = 'Section3']//p[@class = 'Tabletitle']")
79
+ .each { |t| t["class"] = "AnnexTableTitle" }
47
80
  docxml.xpath("//*[@class = 'zzHelp']/p[not(@class)]").each do |p|
48
81
  p["class"] = "zzHelp"
49
82
  end
83
+ quote_style(docxml)
50
84
  end
51
85
 
52
86
  def authority_hdr_cleanup(docxml)
53
- docxml&.xpath("//div[@class = 'boilerplate-license']")&.each do |d|
54
- d.xpath(".//h1").each do |p|
55
- p.name = "p"
56
- p["class"] = "zzWarningHdr"
87
+ { "boilerplate-license": "zzWarningHdr",
88
+ "boilerplate-copyright": "zzCopyrightHdr" }.each do |k, v|
89
+ docxml.xpath("//div[@class = '#{k}']").each do |d|
90
+ d.xpath(".//h1").each do |p|
91
+ p.name = "p"
92
+ p["class"] = v
93
+ end
94
+ end
57
95
  end
58
- end
59
- docxml&.xpath("//div[@class = 'boilerplate-copyright']")&.each do |d|
60
- d.xpath(".//h1").each do |p|
61
- p.name = "p"
62
- p["class"] = "zzCopyrightHdr"
63
- end
64
- end
65
96
  end
66
97
 
67
98
  def authority_cleanup(docxml)
68
99
  insert = docxml.at("//div[@id = 'boilerplate-license-destination']")
69
- auth = docxml&.at("//div[@class = 'boilerplate-license']")&.remove
100
+ auth = docxml.at("//div[@class = 'boilerplate-license']")&.remove
70
101
  auth&.xpath(".//p[not(@class)]")&.each { |p| p["class"] = "zzWarning" }
71
102
  auth and insert and insert.children = auth
72
103
  insert = docxml.at("//div[@id = 'boilerplate-copyright-destination']")
73
- auth = docxml&.at("//div[@class = 'boilerplate-copyright']")&.remove
104
+ auth = docxml.at("//div[@class = 'boilerplate-copyright']")&.remove
74
105
  auth&.xpath(".//p[not(@class)]")&.each do |p|
75
106
  p["class"] = "zzCopyright"
76
107
  end
@@ -1,11 +1,6 @@
1
1
  module IsoDoc
2
2
  module Iso
3
3
  class WordDISConvert < WordConvert
4
- def style_cleanup(docxml)
5
- super
6
- dis_styles(docxml)
7
- end
8
-
9
4
  STYLESMAP = {
10
5
  AltTerms: "AdmittedTerm",
11
6
  TableFootnote: "Tablefootnote",
@@ -30,7 +25,7 @@ module IsoDoc
30
25
  zzCopyright1: "zzCopyright",
31
26
  }.freeze
32
27
 
33
- def dis_styles(docxml)
28
+ def new_styles(docxml)
34
29
  STYLESMAP.each do |k, v|
35
30
  docxml.xpath("//*[@class = '#{k}']").each { |s| s["class"] = v }
36
31
  end
@@ -46,8 +41,8 @@ module IsoDoc
46
41
  figure_style(docxml)
47
42
  note_style(docxml)
48
43
  example_style(docxml)
49
- quote_style(docxml)
50
44
  dis_style_interactions(docxml)
45
+ quote_style(docxml)
51
46
  end
52
47
 
53
48
  def dis_style_interactions(docxml)
@@ -68,13 +63,6 @@ module IsoDoc
68
63
  end
69
64
  end
70
65
 
71
- def quote_style(docxml)
72
- docxml.xpath("//div[@class = 'Quote' or @class = 'Note' or "\
73
- "@class = 'Example' or @class = 'Admonition']").each do |d|
74
- quote_style1(d)
75
- end
76
- end
77
-
78
66
  def para_style_change(div, class1, class2)
79
67
  s = class1 ? "@class = '#{class1}'" : "not(@class)"
80
68
  div.xpath(".//p[#{s}]").each do |p|
@@ -98,7 +98,7 @@ module IsoDoc
98
98
  @meta.get[:doctitlemain] && @meta.get[:doctitlepart] and p << " &#x2014; "
99
99
  if @meta.get[:doctitlepart]
100
100
  b = @meta.get[:doctitlepartlabel] and
101
- p << "<span style='font-weight:normal'>#{b}</span> "
101
+ p << "<span style='font-weight:normal'>#{b}:</span> "
102
102
  p << " #{@meta.get[:doctitlepart]}"
103
103
  end
104
104
  @meta.get[:doctitleamdlabel] || @meta.get[:doctitleamd] ||
@@ -19,7 +19,7 @@ l’adresse ci-après ou au comité membre de l’ISO dans le pays du demandeur.
19
19
  ISO copyright office<br/>
20
20
  CP 401 &#x2022; Ch. de Blandonnet 8<br/>
21
21
  CH-1214 Vernier, Geneva<br/>
22
- Tél.&#xa0;&#xa0;+ 41 22 749 01 11<br/>
22
+ Tél: +41 22 749 01 11<br/>
23
23
  Email: copyright@iso.org<br/>
24
24
  Website: www.iso.org
25
25
  </p>
@@ -14,7 +14,7 @@
14
14
  Бюро ISO по охране авторских прав<br/>
15
15
  CP 401 &#x2022; Ch. de Blandonnet 8<br/>
16
16
  CH-1214 Vernier, Geneva<br/>
17
- Тел.&#xa0;&#xa0;+ 41 22 749 01 11<br/>
17
+ Тел: +41 22 749 01 11<br/>
18
18
  Электронная почта: copyright@iso.org<br/>
19
19
  Сайт: www.iso.org
20
20
  </p>
@@ -20,7 +20,7 @@ at the address below or ISO's member body in the country of the requester.
20
20
  ISO copyright office<br/>
21
21
  CP 401 &#x2022; Ch. de Blandonnet 8<br/>
22
22
  CH-1214 Vernier, Geneva<br/>
23
- Phone:&#xa0;&#xa0;+ 41 22 749 01 11<br/>
23
+ Phone: +41 22 749 01 11<br/>
24
24
  Email: copyright@iso.org<br/>
25
25
  Website: www.iso.org
26
26
  </p>
@@ -88,7 +88,6 @@ module Metanorma
88
88
  end
89
89
  end
90
90
 
91
- # TODO sort by authors
92
91
  # sort by: doc class (ISO, IEC, other standard (not DOI &c), other
93
92
  # then standard class (docid class other than DOI &c)
94
93
  # then docnumber if present, numeric sort
@@ -5,6 +5,7 @@ require "json"
5
5
  require "pathname"
6
6
  require "open-uri"
7
7
  require "twitter_cldr"
8
+ require "pubid-iso"
8
9
 
9
10
  module Metanorma
10
11
  module ISO
@@ -72,7 +73,6 @@ module Metanorma
72
73
  def iso_id(node, xml)
73
74
  (!@amd && node.attr("docnumber")) || (@amd && node.attr("updates")) or
74
75
  return
75
-
76
76
  dn = id_stage_prefix(iso_id1(node), node)
77
77
  dns = [id_year(dn, node, mode: :default),
78
78
  id_year(dn, node, mode: :force),
@@ -80,6 +80,25 @@ module Metanorma
80
80
  iso_id_out(node, xml, dns)
81
81
  end
82
82
 
83
+ =begin
84
+ def iso_id(node, _xml)
85
+ (!@amd && node.attr("docnumber")) || (@amd && node.attr("updates")) or
86
+ return
87
+ params = {
88
+ number: (@amd ? node.attr("updates") : node.attr("docnumber")),
89
+ part: node.attr("partnumber"),
90
+ amendment_number: node.attr("amendment-number"),
91
+ corrigendum_number: node.attr("corrigendum-number"),
92
+ language: node.attr("language") || "en",
93
+ urn_stage: "#{get_stage(node)}.#{get_substage(node)}",
94
+ stage: id_stage_abbr(get_stage(node), get_substage(node), node, true),
95
+ type: doctype(node),
96
+ year: node.attr("copyright-year") || node.attr("updated-date")&.sub(/-.*$/, ""),
97
+ copublisher: node.attr("agency"),
98
+ }
99
+ end
100
+ =end
101
+
83
102
  def iso_id_out(node, xml, dns)
84
103
  xml.docidentifier dns[0], **attr_code(type: "ISO")
85
104
  xml.docidentifier dns[2], **attr_code(type: "iso-undated")
@@ -1285,7 +1285,12 @@
1285
1285
  </define>
1286
1286
  <define name="span">
1287
1287
  <element name="span">
1288
- <attribute name="class"/>
1288
+ <optional>
1289
+ <attribute name="class"/>
1290
+ </optional>
1291
+ <optional>
1292
+ <attribute name="style"/>
1293
+ </optional>
1289
1294
  <oneOrMore>
1290
1295
  <ref name="TextElement"/>
1291
1296
  </oneOrMore>
@@ -2504,6 +2509,16 @@
2504
2509
  <text/>
2505
2510
  </element>
2506
2511
  </optional>
2512
+ <optional>
2513
+ <element name="amendment">
2514
+ <text/>
2515
+ </element>
2516
+ </optional>
2517
+ <optional>
2518
+ <element name="corrigendum">
2519
+ <text/>
2520
+ </element>
2521
+ </optional>
2507
2522
  <optional>
2508
2523
  <element name="language">
2509
2524
  <text/>
@@ -108,7 +108,7 @@
108
108
  </element>
109
109
  </define>
110
110
  <define name="label">
111
- <element name="label">
111
+ <element name="identifier">
112
112
  <oneOrMore>
113
113
  <ref name="TextElement"/>
114
114
  </oneOrMore>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "2.1.4".freeze
3
+ VERSION = "2.1.7".freeze
4
4
  end
5
5
  end
@@ -29,11 +29,12 @@ Gem::Specification.new do |spec|
29
29
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
30
30
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
31
31
 
32
- spec.add_dependency "metanorma-standoc", "~> 2.1.0"
32
+ spec.add_dependency "metanorma-standoc", "~> 2.2.0"
33
33
  spec.add_dependency "mnconvert", "~> 1.14"
34
34
  spec.add_dependency "ruby-jing"
35
35
  spec.add_dependency "tokenizer", "~> 0.3.0"
36
36
  spec.add_dependency "twitter_cldr"
37
+ spec.add_dependency "pubid-iso"
37
38
 
38
39
  spec.add_development_dependency "debug"
39
40
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
@@ -126,66 +126,6 @@ RSpec.describe IsoDoc do
126
126
  expect(File.exist?("spec/assets/iso.pdf")).to be true
127
127
  end
128
128
 
129
- it "converts annex subheadings to h2Annex class for Word" do
130
- IsoDoc::Iso::WordConvert
131
- .new(WORD_HTML_CSS.dup)
132
- .convert("test", <<~"INPUT", false)
133
- <iso-standard xmlns="http://riboseinc.com/isoxml">
134
- <annex id="P" inline-header="false" obligation="normative">
135
- <title>Annex</title>
136
- <clause id="Q" inline-header="false" obligation="normative">
137
- <title>A.1
138
- <tab/>
139
- Annex A.1</title>
140
- </clause>
141
- <appendix id="Q2" inline-header="false" obligation="normative">
142
- <title>Appendix 1
143
- <tab/>
144
- An Appendix</title>
145
- </appendix>
146
- </annex>
147
- <bibliography>
148
- <references id="R" normative="false"><title>Bibliography</title></references>
149
- </bibliography>
150
- </iso-standard>
151
- INPUT
152
-
153
- word = File.read("test.doc", encoding: "UTF-8")
154
- .sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
155
- .sub(%r{<br[^>]*>\s*<div class="colophon".*$}m, "")
156
-
157
- expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")
158
- <div class="WordSection3">
159
- <p class="zzSTDTitle1"/>
160
- <p class="MsoNormal">
161
- <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
162
- </p>
163
- <div class="Section3">
164
- <a id="P" name="P"/>
165
- <p class="ANNEX">Annex</p>
166
- <div>
167
- <a id="Q" name="Q"/>
168
- <p class="h2Annex">A.1
169
- <span style="mso-tab-count:1">  </span>
170
- Annex A.1</p>
171
- </div>
172
- <div>
173
- <a id="Q2" name="Q2"/>
174
- <p class="h2Annex">Appendix 1
175
- <span style="mso-tab-count:1">  </span>
176
- An Appendix</p>
177
- </div>
178
- </div>
179
- <p class='MsoNormal'>
180
- <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
181
- </p>
182
- <div>
183
- <p class='BiblioTitle'>Bibliography</p>
184
- </div>
185
- </div>
186
- OUTPUT
187
- end
188
-
189
129
  it "populates Word template with terms reference labels" do
190
130
  IsoDoc::Iso::WordConvert
191
131
  .new(WORD_HTML_CSS.dup)
@@ -817,7 +757,7 @@ RSpec.describe IsoDoc do
817
757
  </p>
818
758
  <div class="Section3">
819
759
  <a id="P" name="P"/>
820
- <div class="figure">
760
+ <div class="MsoNormal" style='text-align:center;'>
821
761
  <a id="samplecode" name="samplecode"/>
822
762
  <p class="MsoNormal">Hello</p>
823
763
  <p class="MsoNormal">Key</p>
@@ -864,7 +804,7 @@ RSpec.describe IsoDoc do
864
804
  .sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
865
805
  .sub(%r{<br[^>]*>\s*<div class="colophon".*$}m, "")
866
806
  expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")
867
- <div class='WordSection3'>
807
+ <div class='WordSection3'>
868
808
  <p class='zzSTDTitle1'/>
869
809
  <p class='MsoNormal'>
870
810
  <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
@@ -904,11 +844,9 @@ RSpec.describe IsoDoc do
904
844
  <br/>
905
845
  CH-1214 Vernier, Geneva, Switzerland
906
846
  <br/>
907
- Tel. + 41 22 749 01 11
908
- <br/>
909
- Fax + 41 22 749 09 47
847
+ Phone: +41 22 749 01 11
910
848
  <br/>
911
- copyright@iso.org
849
+ Email: copyright@iso.org
912
850
  <br/>
913
851
  www.iso.org</p>
914
852
  </clause>
@@ -951,11 +889,9 @@ RSpec.describe IsoDoc do
951
889
  <br/>
952
890
  CH-1214 Vernier, Geneva, Switzerland
953
891
  <br/>
954
- Tel. + 41 22 749 01 11
955
- <br/>
956
- Fax + 41 22 749 09 47
892
+ Phone: +41 22 749 01 11
957
893
  <br/>
958
- copyright@iso.org
894
+ Email: copyright@iso.org
959
895
  <br/>
960
896
  www.iso.org</p>
961
897
  </clause>
@@ -1015,13 +951,10 @@ RSpec.describe IsoDoc do
1015
951
  CH-1214 Vernier, Geneva, Switzerland
1016
952
 
1017
953
  <br/>
1018
- Tel. + 41 22 749 01 11
1019
-
1020
- <br/>
1021
- Fax + 41 22 749 09 47
954
+ Phone: +41 22 749 01 11
1022
955
 
1023
956
  <br/>
1024
- copyright@iso.org
957
+ Email: copyright@iso.org
1025
958
 
1026
959
  <br/>
1027
960
  www.iso.org#{' '}</p>