metanorma-iso 2.0.6.1 → 2.0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/asciidoctor/iso/base.rb +0 -1
  3. data/lib/asciidoctor/iso/cleanup.rb +0 -1
  4. data/lib/asciidoctor/iso/converter.rb +0 -1
  5. data/lib/asciidoctor/iso/deprecated.rb +4 -2
  6. data/lib/asciidoctor/iso/front.rb +0 -1
  7. data/lib/asciidoctor/iso/front_id.rb +0 -1
  8. data/lib/asciidoctor/iso/section.rb +0 -1
  9. data/lib/asciidoctor/iso/validate.rb +0 -1
  10. data/lib/asciidoctor/iso/validate_image.rb +0 -1
  11. data/lib/asciidoctor/iso/validate_requirements.rb +0 -1
  12. data/lib/asciidoctor/iso/validate_section.rb +0 -1
  13. data/lib/asciidoctor/iso/validate_style.rb +0 -1
  14. data/lib/asciidoctor/iso/validate_title.rb +0 -1
  15. data/lib/isodoc/iso/base_convert.rb +3 -3
  16. data/lib/isodoc/iso/html/header-dis.html +391 -0
  17. data/lib/isodoc/iso/html/html_iso_titlepage.html +2 -2
  18. data/lib/isodoc/iso/html/isodoc-dis.css +4524 -0
  19. data/lib/isodoc/iso/html/isodoc-dis.scss +4289 -0
  20. data/lib/isodoc/iso/html/word_iso_intro-dis.html +7 -0
  21. data/lib/isodoc/iso/html/word_iso_titlepage-dis.html +50 -0
  22. data/lib/isodoc/iso/html/word_iso_titlepage.html +2 -2
  23. data/lib/isodoc/iso/html/wordstyle-dis.css +2160 -0
  24. data/lib/isodoc/iso/html/wordstyle-dis.scss +2011 -0
  25. data/lib/isodoc/iso/i18n-en.yaml +1 -1
  26. data/lib/isodoc/iso/index.rb +7 -4
  27. data/lib/isodoc/iso/iso.amendment.xsl +310 -130
  28. data/lib/isodoc/iso/iso.international-standard.xsl +310 -130
  29. data/lib/isodoc/iso/metadata.rb +75 -64
  30. data/lib/isodoc/iso/presentation_xml_convert.rb +0 -2
  31. data/lib/isodoc/iso/sts_convert.rb +8 -3
  32. data/lib/isodoc/iso/word_cleanup.rb +2 -2
  33. data/lib/isodoc/iso/word_convert.rb +12 -0
  34. data/lib/isodoc/iso/xref.rb +4 -5
  35. data/lib/metanorma/iso/biblio.rng +25 -2
  36. data/lib/metanorma/iso/cleanup.rb +5 -5
  37. data/lib/metanorma/iso/front_id.rb +28 -11
  38. data/lib/metanorma/iso/version.rb +1 -1
  39. data/spec/isodoc/i18n_spec.rb +111 -114
  40. data/spec/isodoc/iso_spec.rb +42 -26
  41. data/spec/isodoc/ref_spec.rb +11 -7
  42. data/spec/metanorma/amd_spec.rb +45 -23
  43. data/spec/metanorma/base_spec.rb +8 -0
  44. data/spec/metanorma/blocks_spec.rb +4 -4
  45. data/spec/metanorma/cleanup_spec.rb +11 -11
  46. data/spec/metanorma/section_spec.rb +3 -3
  47. data/spec/spec_helper.rb +1 -1
  48. data/spec/vcr_cassettes/docrels.yml +35 -43
  49. data/spec/vcr_cassettes/withdrawn_iso.yml +26 -32
  50. metadata +9 -2
@@ -56,14 +56,14 @@ module IsoDoc
56
56
  end
57
57
 
58
58
  def docid(isoxml, _out)
59
- dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'ISO']"))
60
- set(:docnumber, dn&.text)
61
- tcdn = isoxml.xpath(ns("//bibdata/docidentifier[@type = 'iso-tc']"))
62
- set(:tc_docnumber, tcdn.map(&:text))
63
- dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'iso-with-lang']"))
64
- set(:docnumber_lang, dn&.text)
65
- dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'iso-reference']"))
66
- set(:docnumber_reference, dn&.text)
59
+ set(:tc_docnumber, isoxml
60
+ .xpath(ns("//bibdata/docidentifier[@type = 'iso-tc']")).map(&:text))
61
+ { docnumber: "ISO", docnumber_lang: "iso-with-lang",
62
+ docnumber_reference: "iso-reference",
63
+ docnumber_undated: "iso-undated" }.each do |k, v|
64
+ set(k,
65
+ isoxml&.at(ns("//bibdata/docidentifier[@type = '#{v}']"))&.text)
66
+ end
67
67
  end
68
68
 
69
69
  # we don't leave this to i18n.rb, because we have both English and
@@ -91,55 +91,63 @@ module IsoDoc
91
91
  end
92
92
  end
93
93
 
94
- def part_title(part, partnum, subpartnum, lang)
94
+ def part_title(part, titlenums, lang)
95
95
  return "" unless part
96
96
 
97
97
  suffix = @c.encode(part.text, :hexadecimal)
98
- partnum = "#{partnum}–#{subpartnum}" if partnum && subpartnum
99
- suffix = "#{part_label(lang)} #{partnum}: " + suffix if partnum
98
+ p = titlenums[:part]
99
+ titlenums[:part] && titlenums[:subpart] and
100
+ p = "#{titlenums[:part]}–#{titlenums[:subpart]}"
101
+ titlenums[:part] and
102
+ suffix = "#{part_label(lang)} #{p}: " + suffix
100
103
  suffix
101
104
  end
102
105
 
103
- def part_prefix(partnum, subpartnum, lang)
104
- partnum = "#{partnum}–#{subpartnum}" if partnum && subpartnum
105
- "#{part_label(lang)} #{partnum}"
106
+ def part_prefix(titlenums, lang)
107
+ p = titlenums[:part]
108
+ titlenums[:part] && titlenums[:subpart] and
109
+ p = "#{titlenums[:part]}–#{titlenums[:subpart]}"
110
+ "#{part_label(lang)} #{p}"
106
111
  end
107
112
 
108
- def amd_prefix(num, lang)
109
- "#{amd_label(lang)} #{num}"
113
+ def amd_prefix(titlenums, lang)
114
+ "#{amd_label(lang)} #{titlenums[:amd]}"
110
115
  end
111
116
 
112
- def corr_prefix(num, lang)
113
- "#{corr_label(lang)} #{num}"
117
+ def corr_prefix(titlenums, lang)
118
+ "#{corr_label(lang)} #{titlenums[:corr]}"
114
119
  end
115
120
 
116
- def compose_title(main, intro, part, partnum, subpartnum, lang)
117
- main = main.nil? ? "" : @c.encode(main.text, :hexadecimal)
118
- intro &&
119
- main = "#{@c.encode(intro.text, :hexadecimal)} — #{main}"
120
- if part
121
- suffix = part_title(part, partnum, subpartnum, lang)
121
+ def compose_title(tparts, tnums, lang)
122
+ main = ""
123
+ tparts[:main].nil? or
124
+ main = @c.encode(tparts[:main].text, :hexadecimal)
125
+ tparts[:intro] &&
126
+ main = "#{@c.encode(tparts[:intro].text,
127
+ :hexadecimal)} — #{main}"
128
+ if tparts[:part]
129
+ suffix = part_title(tparts[:part], tnums, lang)
122
130
  main = "#{main} — #{suffix}"
123
131
  end
124
132
  main
125
133
  end
126
134
 
127
135
  def title_nums(isoxml)
128
- [isoxml.at(ns("//bibdata//project-number/@part")),
129
- isoxml.at(ns("//bibdata//project-number/@subpart")),
130
- isoxml.at(ns("//bibdata//project-number/@amendment")),
131
- isoxml.at(ns("//bibdata//project-number/@corrigendum"))]
136
+ { part: isoxml.at(ns("//bibdata//project-number/@part")),
137
+ subpart: isoxml.at(ns("//bibdata//project-number/@subpart")),
138
+ amd: isoxml.at(ns("//bibdata//project-number/@amendment")),
139
+ corr: isoxml.at(ns("//bibdata//project-number/@corrigendum")) }
132
140
  end
133
141
 
134
142
  def title_parts(isoxml, lang)
135
- [isoxml.at(ns("//bibdata//title[@type='title-intro' and "\
136
- "@language='#{lang}']")),
137
- isoxml.at(ns("//bibdata//title[@type='title-main' and "\
138
- "@language='#{lang}']")),
139
- isoxml.at(ns("//bibdata//title[@type='title-part' and "\
140
- "@language='#{lang}']")),
141
- isoxml.at(ns("//bibdata//title[@type='title-amd' and "\
142
- "@language='#{lang}']"))]
143
+ { intro: isoxml.at(ns("//bibdata//title[@type='title-intro' and "\
144
+ "@language='#{lang}']")),
145
+ main: isoxml.at(ns("//bibdata//title[@type='title-main' and "\
146
+ "@language='#{lang}']")),
147
+ part: isoxml.at(ns("//bibdata//title[@type='title-part' and "\
148
+ "@language='#{lang}']")),
149
+ amd: isoxml.at(ns("//bibdata//title[@type='title-amd' and "\
150
+ "@language='#{lang}']")) }
143
151
  end
144
152
 
145
153
  def title(isoxml, _out)
@@ -148,43 +156,46 @@ module IsoDoc
148
156
  when "ru" then "ru"
149
157
  else "en"
150
158
  end
151
- intro, main, part, amd = title_parts(isoxml, lang)
152
- partnumber, subpartnumber, amdnumber, corrnumber = title_nums(isoxml)
159
+ # intro, main, part, amd = title_parts(isoxml, lang)
160
+ tp = title_parts(isoxml, lang)
161
+ tn = title_nums(isoxml)
153
162
 
154
- set(:doctitlemain, @c.encode(main ? main.text : "", :hexadecimal))
155
- main = compose_title(main, intro, part, partnumber, subpartnumber, lang)
163
+ set(:doctitlemain,
164
+ @c.encode(tp[:main] ? tp[:main].text : "", :hexadecimal))
165
+ main = compose_title(tp, tn, lang)
156
166
  set(:doctitle, main)
157
- if intro
167
+ if tp[:intro]
158
168
  set(:doctitleintro,
159
- @c.encode(intro ? intro.text : "", :hexadecimal))
169
+ @c.encode(tp[:intro] ? tp[:intro].text : "", :hexadecimal))
160
170
  end
161
- set(:doctitlepartlabel, part_prefix(partnumber, subpartnumber, lang))
162
- set(:doctitlepart, @c.encode(part.text, :hexadecimal)) if part
163
- set(:doctitleamdlabel, amd_prefix(amdnumber, lang)) if amdnumber
164
- set(:doctitleamd, @c.encode(amd.text, :hexadecimal)) if amd
165
- set(:doctitlecorrlabel, corr_prefix(corrnumber, lang)) if corrnumber
171
+ set(:doctitlepartlabel, part_prefix(tn, lang))
172
+ set(:doctitlepart, @c.encode(tp[:part].text, :hexadecimal)) if tp[:part]
173
+ set(:doctitleamdlabel, amd_prefix(tn, lang)) if tn[:amd]
174
+ set(:doctitleamd, @c.encode(tp[:amd].text, :hexadecimal)) if tp[:amd]
175
+ set(:doctitlecorrlabel, corr_prefix(tn, lang)) if tn[:corr]
166
176
  end
167
177
 
168
178
  def subtitle(isoxml, _out)
169
- lang = case @lang
170
- when "fr", "ru" then "en"
171
- else "fr"
172
- end
173
- intro, main, part, amd = title_parts(isoxml, lang)
174
- partnumber, subpartnumber, amdnumber, corrnumber = title_nums(isoxml)
179
+ lang = @lang == "en" ? "fr" : "en"
180
+ tp = title_parts(isoxml, lang)
181
+ tn = title_nums(isoxml)
175
182
 
176
- set(:docsubtitlemain, @c.encode(main ? main.text : "", :hexadecimal))
177
- main = compose_title(main, intro, part, partnumber, subpartnumber, lang)
183
+ set(:docsubtitlemain,
184
+ @c.encode(tp[:main] ? tp[:main].text : "", :hexadecimal))
185
+ main = compose_title(tp, tn, lang)
178
186
  set(:docsubtitle, main)
179
- if intro
187
+ if tp[:intro]
180
188
  set(:docsubtitleintro,
181
- @c.encode(intro ? intro.text : "", :hexadecimal))
189
+ @c.encode(tp[:intro] ? tp[:intro].text : "", :hexadecimal))
190
+ end
191
+ set(:docsubtitlepartlabel, part_prefix(tn, lang))
192
+ if tp[:part]
193
+ set(:docsubtitlepart,
194
+ @c.encode(tp[:part].text, :hexadecimal))
182
195
  end
183
- set(:docsubtitlepartlabel, part_prefix(partnumber, subpartnumber, lang))
184
- set(:docsubtitlepart, @c.encode(part.text, :hexadecimal)) if part
185
- set(:docsubtitleamdlabel, amd_prefix(amdnumber, lang)) if amdnumber
186
- set(:docsubtitleamd, @c.encode(amd.text, :hexadecimal)) if amd
187
- set(:docsubtitlecorrlabel, corr_prefix(corrnumber, lang)) if corrnumber
196
+ set(:docsubtitleamdlabel, amd_prefix(tn, lang)) if tn[:amd]
197
+ set(:docsubtitleamd, @c.encode(tp[:amd].text, :hexadecimal)) if tp[:amd]
198
+ set(:docsubtitlecorrlabel, corr_prefix(tn, lang)) if tn[:corr]
188
199
  end
189
200
 
190
201
  def author(xml, _out)
@@ -238,8 +249,8 @@ module IsoDoc
238
249
  ics = []
239
250
  isoxml.xpath(ns("//bibdata/ext/ics/code")).each { |i| ics << i.text }
240
251
  set(:ics, ics.empty? ? nil : ics.join(", "))
241
- a = isoxml.at(ns("//bibdata/ext/horizontal")) and set(:horizontal,
242
- a.text)
252
+ a = isoxml.at(ns("//bibdata/ext/horizontal")) and
253
+ set(:horizontal, a.text)
243
254
  end
244
255
  end
245
256
  end
@@ -27,8 +27,6 @@ module IsoDoc
27
27
  end
28
28
 
29
29
  def figure1(node)
30
- return if labelled_ancestor(node) && node.ancestors("figure").empty?
31
-
32
30
  lbl = @xrefs.anchor(node["id"], :label, false) or return
33
31
  figname = node.parent.name == "figure" ? "" : "#{@i18n.figure} "
34
32
  connective = node.parent.name == "figure" ? "&nbsp; " : "&nbsp;&mdash; "
@@ -10,14 +10,19 @@ module IsoDoc
10
10
  @suffix = "sts.xml"
11
11
  end
12
12
 
13
- def convert(in_fname, file = nil, debug = false, out_fname = nil)
14
- file = File.read(in_fname, encoding: "utf-8") if file.nil?
15
- _docxml, filename, dir = convert_init(file, in_fname, debug)
13
+ def inputfile(in_fname, filename)
16
14
  /\.xml$/.match?(in_fname) or
17
15
  in_fname = Tempfile.open([filename, ".xml"], encoding: "utf-8") do |f|
18
16
  f.write file
19
17
  f.path
20
18
  end
19
+ in_fname
20
+ end
21
+
22
+ def convert(in_fname, file = nil, debug = false, out_fname = nil)
23
+ file = File.read(in_fname, encoding: "utf-8") if file.nil?
24
+ _docxml, filename, dir = convert_init(file, in_fname, debug)
25
+ in_fname = inputfile(in_fname, filename)
21
26
  FileUtils.rm_rf dir
22
27
  MnConvert.convert(in_fname,
23
28
  { input_format: MnConvert::InputFormat::MN,
@@ -65,7 +65,7 @@ module IsoDoc
65
65
  insert = docxml.at("//div[@id = 'boilerplate-license-destination']")
66
66
  auth = docxml&.at("//div[@class = 'boilerplate-license']")&.remove
67
67
  auth&.xpath(".//p[not(@class)]")&.each { |p| p["class"] = "zzWarning" }
68
- auth and insert.children = auth
68
+ auth and insert and insert.children = auth
69
69
  insert = docxml.at("//div[@id = 'boilerplate-copyright-destination']")
70
70
  auth = docxml&.at("//div[@class = 'boilerplate-copyright']")&.remove
71
71
  auth&.xpath(".//p[not(@class)]")&.each do |p|
@@ -80,7 +80,7 @@ module IsoDoc
80
80
  auth&.xpath(".//p[@id = 'boilerplate-place']")&.each do |p|
81
81
  p["class"] = "zzCopyright1"
82
82
  end
83
- auth and insert.children = auth
83
+ auth and insert and insert.children = auth
84
84
  end
85
85
 
86
86
  def word_cleanup(docxml)
@@ -45,6 +45,18 @@ module IsoDoc
45
45
  olstyle: "l2" }
46
46
  end
47
47
 
48
+ def convert1(docxml, filename, dir)
49
+ @dis = /^[45].$/.match?(docxml&.at(ns("//bibdata/status/stage"))&.text)
50
+ if @dis
51
+ @wordstylesheet_name = html_doc_path("wordstyle-dis.scss")
52
+ @standardstylesheet_name = html_doc_path("isodoc-dis.scss")
53
+ @wordcoverpage = html_doc_path("word_iso_titlepage-dis.html")
54
+ @wordintropage = html_doc_path("word_iso_intro-dis.html")
55
+ @header = html_doc_path("header-dis.html")
56
+ end
57
+ super
58
+ end
59
+
48
60
  def make_body(xml, docxml)
49
61
  body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72" }
50
62
  xml.body **body_attr do |body|
@@ -113,7 +113,7 @@ module IsoDoc
113
113
  def hierarchical_formula_names(clause, num)
114
114
  c = IsoDoc::XrefGen::Counter.new
115
115
  clause.xpath(ns(".//formula")).each do |t|
116
- next if t["id"].nil? || t["id"].empty?
116
+ next if blank?(t["id"])
117
117
 
118
118
  @anchors[t["id"]] = anchor_struct(
119
119
  "#{num}#{hiersep}#{c.increment(t).print}", t,
@@ -133,13 +133,12 @@ module IsoDoc
133
133
  end
134
134
 
135
135
  def sequential_figure_names(clause)
136
- c = IsoDoc::XrefGen::Counter.new
137
136
  j = 0
138
137
  clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
139
- .each do |t|
138
+ .each_with_object(IsoDoc::XrefGen::Counter.new) do |t, c|
140
139
  j = subfigure_increment(j, c, t)
141
140
  sublabel = j.zero? ? nil : "#{(j + 96).chr})"
142
- next if t["id"].nil? || t["id"].empty?
141
+ next if blank?(t["id"])
143
142
 
144
143
  figure_anchor(t, sublabel, c.print)
145
144
  end
@@ -153,7 +152,7 @@ module IsoDoc
153
152
  j = subfigure_increment(j, c, t)
154
153
  label = "#{num}#{hiersep}#{c.print}"
155
154
  sublabel = j.zero? ? nil : "#{(j + 96).chr})"
156
- next if t["id"].nil? || t["id"].empty?
155
+ next if blank?(t["id"])
157
156
 
158
157
  figure_anchor(t, sublabel, label)
159
158
  end
@@ -527,7 +527,7 @@
527
527
  </define>
528
528
  <define name="LocalityType">
529
529
  <data type="string">
530
- <param name="pattern">section|clause|part|paragraph|chapter|page|whole|table|annex|figure|note|list|example|volume|issue|time|anchor|locality:[a-zA-Z0-9_]+</param>
530
+ <param name="pattern">section|clause|part|paragraph|chapter|page|title|line|whole|table|annex|figure|note|list|example|volume|issue|time|anchor|locality:[a-zA-Z0-9_]+</param>
531
531
  </data>
532
532
  </define>
533
533
  <define name="referenceFrom">
@@ -677,6 +677,9 @@
677
677
  <zeroOrMore>
678
678
  <ref name="extent"/>
679
679
  </zeroOrMore>
680
+ <optional>
681
+ <ref name="bibliographic_size"/>
682
+ </optional>
680
683
  <zeroOrMore>
681
684
  <ref name="accesslocation"/>
682
685
  </zeroOrMore>
@@ -922,9 +925,29 @@
922
925
  <text/>
923
926
  </element>
924
927
  </define>
928
+ <define name="sizevalue">
929
+ <element name="value">
930
+ <attribute name="type"/>
931
+ <text/>
932
+ </element>
933
+ </define>
934
+ <define name="bibliographic_size">
935
+ <element name="size">
936
+ <oneOrMore>
937
+ <ref name="sizevalue"/>
938
+ </oneOrMore>
939
+ </element>
940
+ </define>
925
941
  <define name="extent">
926
942
  <element name="extent">
927
- <ref name="BibItemLocality"/>
943
+ <choice>
944
+ <zeroOrMore>
945
+ <ref name="locality"/>
946
+ </zeroOrMore>
947
+ <zeroOrMore>
948
+ <ref name="localityStack"/>
949
+ </zeroOrMore>
950
+ </choice>
928
951
  </element>
929
952
  </define>
930
953
  <define name="series">
@@ -51,10 +51,10 @@ module Metanorma
51
51
  id.content = id_prefix(prefix, id)
52
52
  id = xmldoc.at("//bibdata/ext/structuredidentifier/project-number") and
53
53
  id.content = id_prefix(prefix, id)
54
- id = xmldoc.at("//bibdata/docidentifier[@type = 'iso-with-lang']") and
55
- id.content = id_prefix(prefix, id)
56
- id = xmldoc.at("//bibdata/docidentifier[@type = 'iso-reference']") and
57
- id.content = id_prefix(prefix, id)
54
+ %w(iso-with-lang iso-reference iso-undated).each do |t|
55
+ id = xmldoc.at("//bibdata/docidentifier[@type = '#{t}']") and
56
+ id.content = id_prefix(prefix, id)
57
+ end
58
58
  end
59
59
 
60
60
  def format_ref(ref, type)
@@ -140,7 +140,7 @@ module Metanorma
140
140
  xmldoc.xpath("//bibitem/note[@type = 'Unpublished-Status']").each do |n|
141
141
  e = xmldoc.at("//eref[@bibitemid = '#{n.parent['id']}']") or next
142
142
  fn = n.children.to_xml
143
- n&.elements&.first&.name == "p" or fn = "<p>#{fn}</p>"
143
+ n.elements&.first&.name == "p" or fn = "<p>#{fn}</p>"
144
144
  e.next = "<fn>#{fn}</fn>"
145
145
  end
146
146
  end
@@ -73,13 +73,19 @@ module Metanorma
73
73
  (!@amd && node.attr("docnumber")) || (@amd && node.attr("updates")) or
74
74
  return
75
75
 
76
- dn = iso_id1(node)
77
- dn1 = id_stage_prefix(dn, node, false)
78
- dn2 = id_stage_prefix(dn, node, true)
79
- xml.docidentifier dn1, **attr_code(type: "ISO")
80
- xml.docidentifier(id_langsuffix(dn1, node),
76
+ dn = id_stage_prefix(iso_id1(node), node)
77
+ dns = [id_year(dn, node, mode: :default),
78
+ id_year(dn, node, mode: :force),
79
+ id_year(dn, node, mode: :strip)]
80
+ iso_id_out(node, xml, dns)
81
+ end
82
+
83
+ def iso_id_out(node, xml, dns)
84
+ xml.docidentifier dns[0], **attr_code(type: "ISO")
85
+ xml.docidentifier dns[2], **attr_code(type: "iso-undated")
86
+ xml.docidentifier(id_langsuffix(dns[0], node),
81
87
  **attr_code(type: "iso-with-lang"))
82
- xml.docidentifier(id_langsuffix(dn2, node),
88
+ xml.docidentifier(id_langsuffix(dns[1], node),
83
89
  **attr_code(type: "iso-reference"))
84
90
  end
85
91
 
@@ -160,14 +166,14 @@ module Metanorma
160
166
  def cover_stage_abbr(node)
161
167
  stage = get_stage(node)
162
168
  abbr = id_stage_abbr(get_stage(node), get_substage(node), node, true)
163
- typeabbr = get_typeabbr(node, true)
169
+ typeabbr = get_typeabbr(node, amd: true)
164
170
  if stage.to_i > 50 || (stage.to_i == 60 && get_substage(node).to_i < 60)
165
171
  typeabbr = ""
166
172
  end
167
173
  "#{abbr}#{typeabbr}".strip
168
174
  end
169
175
 
170
- def id_stage_prefix(docnum, node, force_year)
176
+ def id_stage_prefix(docnum, node)
171
177
  stage = get_stage(node)
172
178
  typeabbr = get_typeabbr(node)
173
179
  if stage && (stage.to_i < 60)
@@ -175,11 +181,22 @@ module Metanorma
175
181
  elsif typeabbr == "DIR " then docnum = "#{typeabbr}#{docnum}"
176
182
  elsif typeabbr && !@amd then docnum = "/#{typeabbr}#{docnum}"
177
183
  end
178
- (force_year || !(stage && (stage.to_i < 60))) and
179
- docnum = id_add_year(docnum, node)
180
184
  docnum
181
185
  end
182
186
 
187
+ def id_year(docnum, node, mode: :default)
188
+ case mode
189
+ when :strip then docnum.sub(/:(19|20)\d\d(?!\d)/, "")
190
+ when :force then id_add_year(docnum, node)
191
+ else
192
+ stage = get_stage(node)
193
+ if stage && (stage.to_i < 60)
194
+ docnum
195
+ else id_add_year(docnum, node)
196
+ end
197
+ end
198
+ end
199
+
183
200
  def unpub_stage_prefix(docnum, stage, typeabbr, node)
184
201
  abbr = id_stage_abbr(stage, get_substage(node), node)
185
202
  %w(40 50).include?(stage) && i = node.attr("iteration") and
@@ -213,7 +230,7 @@ module Metanorma
213
230
  ret
214
231
  end
215
232
 
216
- def get_typeabbr(node, amd = false)
233
+ def get_typeabbr(node, amd: false)
217
234
  case doctype(node)
218
235
  when "directive" then "DIR "
219
236
  when "technical-report" then "TR "
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "2.0.6.1".freeze
3
+ VERSION = "2.0.8.1".freeze
4
4
  end
5
5
  end