metanorma-iso 1.7.1 → 1.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +11 -41
  3. data/.gitignore +2 -0
  4. data/.rubocop.yml +6 -2
  5. data/lib/asciidoctor/iso/base.rb +18 -16
  6. data/lib/asciidoctor/iso/biblio.rng +4 -6
  7. data/lib/asciidoctor/iso/cleanup.rb +28 -24
  8. data/lib/asciidoctor/iso/front.rb +26 -16
  9. data/lib/asciidoctor/iso/front_id.rb +30 -25
  10. data/lib/asciidoctor/iso/isodoc.rng +172 -3
  11. data/lib/asciidoctor/iso/isostandard-amd.rng +3 -0
  12. data/lib/asciidoctor/iso/isostandard.rng +17 -97
  13. data/lib/asciidoctor/iso/validate.rb +22 -109
  14. data/lib/asciidoctor/iso/validate_image.rb +97 -0
  15. data/lib/asciidoctor/iso/validate_requirements.rb +26 -20
  16. data/lib/asciidoctor/iso/validate_section.rb +39 -20
  17. data/lib/asciidoctor/iso/validate_style.rb +36 -24
  18. data/lib/asciidoctor/iso/validate_title.rb +23 -17
  19. data/lib/isodoc/iso/base_convert.rb +19 -2
  20. data/lib/isodoc/iso/html/style-human.css +7 -0
  21. data/lib/isodoc/iso/html/style-iso.css +7 -0
  22. data/lib/isodoc/iso/html_convert.rb +0 -1
  23. data/lib/isodoc/iso/i18n-en.yaml +4 -0
  24. data/lib/isodoc/iso/i18n-fr.yaml +4 -0
  25. data/lib/isodoc/iso/i18n-zh-Hans.yaml +4 -0
  26. data/lib/isodoc/iso/index.rb +140 -0
  27. data/lib/isodoc/iso/iso.amendment.xsl +1092 -208
  28. data/lib/isodoc/iso/iso.international-standard.xsl +1092 -208
  29. data/lib/isodoc/iso/presentation_xml_convert.rb +45 -37
  30. data/lib/isodoc/iso/word_convert.rb +0 -1
  31. data/lib/isodoc/iso/xref.rb +15 -7
  32. data/lib/metanorma/iso/processor.rb +1 -0
  33. data/lib/metanorma/iso/version.rb +1 -1
  34. data/metanorma-iso.gemspec +8 -8
  35. data/spec/asciidoctor/amd_spec.rb +696 -0
  36. data/spec/asciidoctor/base_spec.rb +733 -0
  37. data/spec/asciidoctor/blocks_spec.rb +527 -0
  38. data/spec/asciidoctor/cleanup_spec.rb +1134 -0
  39. data/spec/asciidoctor/inline_spec.rb +195 -0
  40. data/spec/asciidoctor/lists_spec.rb +197 -0
  41. data/spec/asciidoctor/refs_spec.rb +375 -0
  42. data/spec/asciidoctor/section_spec.rb +393 -0
  43. data/spec/asciidoctor/table_spec.rb +329 -0
  44. data/spec/asciidoctor/validate_spec.rb +1627 -0
  45. data/spec/isodoc/amd_spec.rb +967 -946
  46. data/spec/isodoc/blocks_spec.rb +530 -507
  47. data/spec/isodoc/i18n_spec.rb +953 -911
  48. data/spec/isodoc/inline_spec.rb +355 -293
  49. data/spec/isodoc/iso_spec.rb +338 -314
  50. data/spec/isodoc/metadata_spec.rb +392 -382
  51. data/spec/isodoc/postproc_spec.rb +836 -657
  52. data/spec/isodoc/ref_spec.rb +374 -331
  53. data/spec/isodoc/section_spec.rb +821 -519
  54. data/spec/isodoc/table_spec.rb +472 -411
  55. data/spec/isodoc/terms_spec.rb +209 -185
  56. data/spec/isodoc/xref_spec.rb +1370 -1236
  57. data/spec/metanorma/processor_spec.rb +28 -26
  58. data/spec/spec_helper.rb +178 -193
  59. metadata +65 -66
  60. data/.rubocop.ribose.yml +0 -66
  61. data/lib/isodoc/iso/html/scripts.html +0 -178
  62. data/spec/asciidoctor-iso/amd_spec.rb +0 -694
  63. data/spec/asciidoctor-iso/base_spec.rb +0 -713
  64. data/spec/asciidoctor-iso/blocks_spec.rb +0 -482
  65. data/spec/asciidoctor-iso/cleanup_spec.rb +0 -1025
  66. data/spec/asciidoctor-iso/inline_spec.rb +0 -170
  67. data/spec/asciidoctor-iso/lists_spec.rb +0 -190
  68. data/spec/asciidoctor-iso/refs_spec.rb +0 -317
  69. data/spec/asciidoctor-iso/section_spec.rb +0 -362
  70. data/spec/asciidoctor-iso/table_spec.rb +0 -313
  71. data/spec/asciidoctor-iso/validate_spec.rb +0 -1621
  72. data/spec/assets/xref_error.adoc +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9af9da09f9e17f25423843c284ed66d9f2206535631b334263bea9f80211acf6
4
- data.tar.gz: 9987c2fcb45025dee73bc95fd21939104495dbf3e07e79afac877b7b9fcf81f4
3
+ metadata.gz: 9d170797212efc1050755714c1c875246a5b1b07ca8c4c1b6562b51ab2ee44a9
4
+ data.tar.gz: a6deb053bf737183c275a1f93a110d89f8fa42a093bafd514c7d672b5e16f427
5
5
  SHA512:
6
- metadata.gz: f947d939ce553a170f712c09c903bf5d8c1192c7de45063d9407b4a7c300d31ee325cb269db9046d917a0184a18c78f654377922e23b2eca33add015139e5af9
7
- data.tar.gz: c5d5d07e2c558293c926c3f4a4be46ff96659670082f2c09951f58dada582f6d93a3d8ccaeba15016bc0548dceda5c5f32d664a8cb05110d69e25179c67f1c4d
6
+ metadata.gz: 63752e6b4a75cba612fca7cacf5c0ccd7a4553f51b9743e667d7a2891737dff68deace61efcab395be2f22e8b4d6559ee8eee6c50ad84e3f13e627af1ca98a68
7
+ data.tar.gz: 401f42f155a7424266d3bf62cb6fca9a67ad1adeddf01145c55de95397a91de22847b56fa92563d64045eb6dc2682511eab3925d60f74b1ca737f8ecefacee63
@@ -16,17 +16,17 @@ jobs:
16
16
  strategy:
17
17
  fail-fast: false
18
18
  matrix:
19
- ruby: [ '2.6', '2.5', '2.4' ]
19
+ ruby: [ '2.7', '2.6', '2.5', '2.4' ]
20
20
  os: [ ubuntu-latest, windows-latest, macos-latest ]
21
21
  experimental: [ false ]
22
22
  include:
23
- - ruby: '2.7'
23
+ - ruby: '3.0'
24
24
  os: 'ubuntu-latest'
25
25
  experimental: true
26
- - ruby: '2.7'
26
+ - ruby: '3.0'
27
27
  os: 'windows-latest'
28
28
  experimental: true
29
- - ruby: '2.7'
29
+ - ruby: '3.0'
30
30
  os: 'macos-latest'
31
31
  experimental: true
32
32
  steps:
@@ -35,49 +35,19 @@ jobs:
35
35
  - uses: ruby/setup-ruby@v1
36
36
  with:
37
37
  ruby-version: ${{ matrix.ruby }}
38
+ bundler-cache: true
38
39
 
39
- - if: matrix.os == 'macos-latest'
40
- run: brew install autoconf automake libtool
41
-
42
- - uses: actions/cache@v2
43
- with:
44
- path: vendor/bundle
45
- key: bundle-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}
46
- restore-keys: bundle-${{ matrix.os }}-${{ matrix.ruby }}
47
-
48
- - run: bundle config set path 'vendor/bundle'
49
-
50
- - run: bundle install --jobs 4 --retry 3
51
-
52
- - name: install plantuml ubuntu
53
- if: matrix.os == 'ubuntu-latest'
54
- uses: nick-invision/retry@v1
55
- with:
56
- polling_interval_seconds: 5
57
- timeout_minutes: 5
58
- max_attempts: 3
59
- command: >
60
- sudo apt-get update -y && sudo bash -c
61
- "curl -L https://github.com/metanorma/plantuml-install/raw/master/ubuntu.sh | bash"
62
-
63
- - if: matrix.os == 'macos-latest'
64
- run: brew install plantuml
65
-
66
- - if: matrix.os == 'windows-latest'
67
- run: cinst -y plantuml
40
+ - uses: metanorma/metanorma-build-scripts/plantuml-setup-action@master
68
41
 
69
42
  - run: bundle exec rake
70
43
 
71
44
  tests-passed:
72
45
  needs: rake
73
46
  runs-on: ubuntu-latest
74
- continue-on-error: true
75
47
  steps:
76
- - name: Trigger tests passed event
77
- uses: Sibz/github-status-action@v1
48
+ - uses: peter-evans/repository-dispatch@v1
78
49
  with:
79
- authToken: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
80
- context: 'tests-passed-successfully'
81
- description: 'Tests passed successfully'
82
- state: 'success'
83
- sha: ${{ github.event.pull_request.head.sha || github.sha }}
50
+ token: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
51
+ repository: ${{ github.repository }}
52
+ event-type: notify
53
+ client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
data/.gitignore CHANGED
@@ -9,3 +9,5 @@ spec/examples/rice.doc
9
9
  spec/examples/rice.html
10
10
  spec/examples/rice.xml
11
11
  spec/examples/rice_files/
12
+
13
+ .rubocop-https--*
data/.rubocop.yml CHANGED
@@ -1,10 +1,14 @@
1
1
  # This project follows the Ribose OSS style guide.
2
2
  # https://github.com/riboseinc/oss-guides
3
3
  # All project-specific additions and overrides should be specified in this file.
4
-
5
4
  inherit_from:
6
5
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
6
+
7
+ # local repo-specific modifications
8
+
7
9
  AllCops:
8
- TargetRubyVersion: 2.3
10
+ DisplayCopNames: false
11
+ StyleGuideCopsOnly: false
12
+ TargetRubyVersion: 2.4
9
13
  Rails:
10
14
  Enabled: true
@@ -17,8 +17,8 @@ module Asciidoctor
17
17
  end
18
18
 
19
19
  def html_converter_alt(node)
20
- IsoDoc::Iso::HtmlConvert.new(html_extract_attributes(node).
21
- merge(alt: true))
20
+ IsoDoc::Iso::HtmlConvert.new(html_extract_attributes(node)
21
+ .merge(alt: true))
22
22
  end
23
23
 
24
24
  def doc_converter(node)
@@ -27,11 +27,13 @@ module Asciidoctor
27
27
 
28
28
  def pdf_converter(node)
29
29
  return nil if node.attr("no-pdf")
30
+
30
31
  IsoDoc::Iso::PdfConvert.new(doc_extract_attributes(node))
31
32
  end
32
33
 
33
34
  def sts_converter(node)
34
35
  return nil if node.attr("no-pdf")
36
+
35
37
  IsoDoc::Iso::StsConvert.new(html_extract_attributes(node))
36
38
  end
37
39
 
@@ -44,23 +46,23 @@ module Asciidoctor
44
46
  @amd = %w(amendment technical-corrigendum).include? doctype(node)
45
47
  end
46
48
 
47
- def ol_attrs(node)
48
- attr_code(keep_attrs(node).
49
- merge(id: ::Metanorma::Utils::anchor_or_uuid(node)))
49
+ def ol_attrs(node)
50
+ attr_code(keep_attrs(node)
51
+ .merge(id: ::Metanorma::Utils::anchor_or_uuid(node)))
50
52
  end
51
53
 
52
54
  def outputs(node, ret)
53
- File.open(@filename + ".xml", "w:UTF-8") { |f| f.write(ret) }
54
- presentation_xml_converter(node).convert(@filename + ".xml")
55
- html_converter_alt(node).convert(@filename + ".presentation.xml",
56
- nil, false, "#{@filename}_alt.html")
57
- html_converter(node).convert(@filename + ".presentation.xml",
58
- nil, false, "#{@filename}.html")
59
- doc_converter(node).convert(@filename + ".presentation.xml",
60
- nil, false, "#{@filename}.doc")
61
- pdf_converter(node)&.convert(@filename + ".presentation.xml",
62
- nil, false, "#{@filename}.pdf")
63
- #sts_converter(node)&.convert(@filename + ".xml")
55
+ File.open("#{@filename}.xml", "w:UTF-8") { |f| f.write(ret) }
56
+ presentation_xml_converter(node).convert("#{@filename}.xml")
57
+ html_converter_alt(node).convert("#{@filename}.presentation.xml",
58
+ nil, false, "#{@filename}_alt.html")
59
+ html_converter(node).convert("#{@filename}.presentation.xml",
60
+ nil, false, "#{@filename}.html")
61
+ doc_converter(node).convert("#{@filename}.presentation.xml",
62
+ nil, false, "#{@filename}.doc")
63
+ pdf_converter(node)&.convert("#{@filename}.presentation.xml",
64
+ nil, false, "#{@filename}.pdf")
65
+ # sts_converter(node)&.convert(@filename + ".xml")
64
66
  end
65
67
  end
66
68
  end
@@ -124,7 +124,7 @@
124
124
  <value>application/tei+xml</value>
125
125
  <value>text/x-asciidoc</value>
126
126
  <value>text/markdown</value>
127
- <value>application/x-isodoc+xml</value>
127
+ <value>application/x-metanorma+xml</value>
128
128
  <text/>
129
129
  </choice>
130
130
  </attribute>
@@ -452,6 +452,7 @@
452
452
  <attribute name="type">
453
453
  <choice>
454
454
  <value>isni</value>
455
+ <value>orcid</value>
455
456
  <value>uri</value>
456
457
  </choice>
457
458
  </attribute>
@@ -461,10 +462,7 @@
461
462
  <define name="org-identifier">
462
463
  <element name="identifier">
463
464
  <attribute name="type">
464
- <choice>
465
- <value>orcid</value>
466
- <value>uri</value>
467
- </choice>
465
+ <data type="string" datatypeLibrary=""/>
468
466
  </attribute>
469
467
  <text/>
470
468
  </element>
@@ -1106,7 +1104,7 @@
1106
1104
  <value>complementOf</value>
1107
1105
  <value>obsoletes</value>
1108
1106
  <value>obsoletedBy</value>
1109
- <value>cited</value>
1107
+ <value>cites</value>
1110
1108
  <value>isCitedIn</value>
1111
1109
  </choice>
1112
1110
  </define>
@@ -22,20 +22,19 @@ module Asciidoctor
22
22
  def other_footnote_renumber(xmldoc)
23
23
  seen = {}
24
24
  i = 0
25
- xmldoc.xpath(PRE_NORMREF_FOOTNOTES).each do |fn|
26
- i, seen = other_footnote_renumber1(fn, i, seen)
27
- end
28
- xmldoc.xpath(NORMREF_FOOTNOTES).each do |fn|
29
- i, seen = other_footnote_renumber1(fn, i, seen)
30
- end
31
- xmldoc.xpath(POST_NORMREF_FOOTNOTES).each do |fn|
32
- i, seen = other_footnote_renumber1(fn, i, seen)
25
+ [PRE_NORMREF_FOOTNOTES, NORMREF_FOOTNOTES,
26
+ POST_NORMREF_FOOTNOTES].each do |xpath|
27
+ xmldoc.xpath(xpath).each do |fn|
28
+ i, seen = other_footnote_renumber1(fn, i, seen)
29
+ end
33
30
  end
34
31
  end
35
32
 
36
33
  def id_prefix(prefix, id)
37
- return id.text if @amd # we're just inheriting the prefixes from parent doc
38
- prefix.join("/") + ( id.text.match(%{^/}) ? "" : " " ) + id.text
34
+ # we're just inheriting the prefixes from parent doc
35
+ return id.text if @amd
36
+
37
+ prefix.join("/") + (id.text.match?(%{^/}) ? "" : " ") + id.text
39
38
  end
40
39
 
41
40
  def get_id_prefix(xmldoc)
@@ -61,7 +60,7 @@ module Asciidoctor
61
60
  id.content = id_prefix(prefix, id)
62
61
  end
63
62
 
64
- def format_ref(ref, type, isopub)
63
+ def format_ref(ref, type)
65
64
  ref = ref.sub(/ \(All Parts\)/i, "")
66
65
  super
67
66
  end
@@ -79,6 +78,7 @@ module Asciidoctor
79
78
  return 2 if bib.at("#{PUBLISHER}[name = 'International "\
80
79
  "Electrotechnical Commission']")
81
80
  return 3 if bib.at("./docidentifier[@type][not(#{OTHERIDS})]")
81
+
82
82
  4
83
83
  end
84
84
 
@@ -101,25 +101,26 @@ module Asciidoctor
101
101
  num = bib&.at("./docnumber")&.text
102
102
  id = bib&.at("./docidentifier[not(#{OTHERIDS})]")
103
103
  metaid = bib&.at("./docidentifier[@type = 'metanorma']")&.text
104
- abbrid = metaid unless /^\[\d+\]$/.match(metaid)
104
+ abbrid = metaid unless /^\[\d+\]$/.match?(metaid)
105
105
  /\d-(?<partid>\d+)/ =~ id&.text
106
- type = id['type'] if id
106
+ type = id["type"] if id
107
107
  title = bib&.at("./title[@type = 'main']")&.text ||
108
108
  bib&.at("./title")&.text || bib&.at("./formattedref")&.text
109
109
  "#{pubclass} :: #{type} :: "\
110
- "#{num.nil? ? abbrid : sprintf("%09d", num.to_i)} :: "\
110
+ "#{num.nil? ? abbrid : sprintf('%09d', num.to_i)} :: "\
111
111
  "#{partid} :: #{id&.text} :: #{title}"
112
112
  end
113
113
 
114
- def sections_cleanup(x)
114
+ def sections_cleanup(xml)
115
115
  super
116
116
  return unless @amd
117
- x.xpath("//*[@inline-header]").each do |h|
118
- h.delete('inline-header')
117
+
118
+ xml.xpath("//*[@inline-header]").each do |h|
119
+ h.delete("inline-header")
119
120
  end
120
121
  end
121
122
 
122
- def boilerplate_file(xmldoc)
123
+ def boilerplate_file(_xmldoc)
123
124
  file = @lang == "fr" ? "boilerplate-fr.xml" : "boilerplate.xml"
124
125
  File.join(@libdir, file)
125
126
  end
@@ -146,14 +147,17 @@ module Asciidoctor
146
147
  end
147
148
 
148
149
  def unpublished_note(xmldoc)
149
- xmldoc.xpath("//bibitem[not(note[@type = 'Unpublished-Status'])]").each do |b|
150
+ xmldoc.xpath("//bibitem[not(note[@type = 'Unpublished-Status'])]")
151
+ .each do |b|
150
152
  next if pub_class(b) > 2
151
- next unless s = b.at("./status/stage") and s.text.to_i < 60
153
+ next unless (s = b.at("./status/stage")) && (s.text.to_i < 60)
154
+
152
155
  id = b.at("docidentifier").text
153
- b.at("./language | ./script | ./abstract | ./status").previous = <<~NOTE
154
- <note type="Unpublished-Status">
155
- <p>#{@i18n.under_preparation.sub(/%/, id)}</p></note>
156
- NOTE
156
+ b.at("./language | ./script | ./abstract | ./status")
157
+ .previous = <<~NOTE
158
+ <note type="Unpublished-Status">
159
+ <p>#{@i18n.under_preparation.sub(/%/, id)}</p></note>
160
+ NOTE
157
161
  end
158
162
  end
159
163
  end
@@ -33,7 +33,9 @@ module Asciidoctor
33
33
  csv_split(publishers).each do |p|
34
34
  xml.contributor do |c|
35
35
  c.role **{ type: "author" }
36
- c.organization { |a| organization(a, p, node, !node.attr("publisher")) }
36
+ c.organization do |a|
37
+ organization(a, p, false, node, !node.attr("publisher"))
38
+ end
37
39
  end
38
40
  end
39
41
  end
@@ -43,20 +45,25 @@ module Asciidoctor
43
45
  csv_split(publishers).each do |p|
44
46
  xml.contributor do |c|
45
47
  c.role **{ type: "publisher" }
46
- c.organization { |a| organization(a, p, node, !node.attr("publisher")) }
48
+ c.organization do |a|
49
+ organization(a, p, true, node, !node.attr("publisher"))
50
+ end
47
51
  end
48
52
  end
49
53
  end
50
54
 
51
55
  def metadata_copyright(node, xml)
52
- publishers = node.attr("copyright-holder") || node.attr("publisher") || "ISO"
56
+ publishers = node.attr("copyright-holder") || node.attr("publisher") ||
57
+ "ISO"
53
58
  csv_split(publishers).each do |p|
54
59
  xml.copyright do |c|
55
60
  c.from (node.attr("copyright-year") || Date.today.year)
56
61
  c.owner do |owner|
57
62
  owner.organization do |o|
58
- organization(o, p, node,
59
- !(node.attr("copyright-holder") || node.attr("publisher")))
63
+ organization(
64
+ o, p, true, node,
65
+ !(node.attr("copyright-holder") || node.attr("publisher"))
66
+ )
60
67
  end
61
68
  end
62
69
  end
@@ -67,7 +74,7 @@ module Asciidoctor
67
74
  stage = get_stage(node)
68
75
  substage = get_substage(node)
69
76
  xml.status do |s|
70
- s.stage stage, **attr_code(abbreviation: stage_abbr(stage, substage, doctype(node)))
77
+ s.stage stage, **attr_code(abbreviation: cover_stage_abbr(node))
71
78
  s.substage substage
72
79
  node.attr("iteration") && (s.iteration node.attr("iteration"))
73
80
  end
@@ -82,34 +89,37 @@ module Asciidoctor
82
89
  end
83
90
  end
84
91
 
85
- def title_intro(node, t, lang, at)
92
+ def title_intro(node, xml, lang, at)
86
93
  return unless node.attr("title-intro-#{lang}")
87
- t.title(**attr_code(at.merge(type: "title-intro"))) do |t1|
94
+
95
+ xml.title(**attr_code(at.merge(type: "title-intro"))) do |t1|
88
96
  t1 << Metanorma::Utils::asciidoc_sub(node.attr("title-intro-#{lang}"))
89
97
  end
90
98
  end
91
99
 
92
- def title_main(node, t, lang, at)
93
- t.title **attr_code(at.merge(type: "title-main")) do |t1|
100
+ def title_main(node, xml, lang, at)
101
+ xml.title **attr_code(at.merge(type: "title-main")) do |t1|
94
102
  t1 << Metanorma::Utils::asciidoc_sub(node.attr("title-main-#{lang}"))
95
103
  end
96
104
  end
97
105
 
98
- def title_part(node, t, lang, at)
106
+ def title_part(node, xml, lang, at)
99
107
  return unless node.attr("title-part-#{lang}")
100
- t.title(**attr_code(at.merge(type: "title-part"))) do |t1|
108
+
109
+ xml.title(**attr_code(at.merge(type: "title-part"))) do |t1|
101
110
  t1 << Metanorma::Utils::asciidoc_sub(node.attr("title-part-#{lang}"))
102
111
  end
103
112
  end
104
113
 
105
- def title_amd(node, t, lang, at)
114
+ def title_amd(node, xml, lang, at)
106
115
  return unless node.attr("title-amendment-#{lang}")
107
- t.title(**attr_code(at.merge(type: "title-amd"))) do |t1|
116
+
117
+ xml.title(**attr_code(at.merge(type: "title-amd"))) do |t1|
108
118
  t1 << Metanorma::Utils::asciidoc_sub(node.attr("title-amendment-#{lang}"))
109
119
  end
110
120
  end
111
121
 
112
- def title_full(node, t, lang, at)
122
+ def title_full(node, xml, lang, at)
113
123
  title = node.attr("title-main-#{lang}")
114
124
  intro = node.attr("title-intro-#{lang}")
115
125
  part = node.attr("title-part-#{lang}")
@@ -117,7 +127,7 @@ module Asciidoctor
117
127
  title = "#{intro} -- #{title}" if intro
118
128
  title = "#{title} -- #{part}" if part
119
129
  title = "#{title} -- #{amd}" if amd && @amd
120
- t.title **attr_code(at.merge(type: "main")) do |t1|
130
+ xml.title **attr_code(at.merge(type: "main")) do |t1|
121
131
  t1 << Metanorma::Utils::asciidoc_sub(title)
122
132
  end
123
133
  end
@@ -11,7 +11,7 @@ module Asciidoctor
11
11
  class Converter < Standoc::Converter
12
12
  STAGE_ABBRS = {
13
13
  "00": "PWI",
14
- "10": "NWIP",
14
+ "10": "NP",
15
15
  "20": "WD",
16
16
  "30": "CD",
17
17
  "40": "DIS",
@@ -37,15 +37,11 @@ module Asciidoctor
37
37
  return nil if stage.to_i > 60
38
38
  ret = STAGE_ABBRS[stage.to_sym]
39
39
  ret = "PRF" if stage == "60" && substage == "00"
40
+ ret = "AWI" if stage == "10" && substage == "99"
40
41
  if %w(amendment technical-corrigendum technical-report
41
42
  technical-specification).include?(doctype)
42
- ret = "NP" if stage == "10"
43
- ret = "AWI" if stage == "10" && substage == "99"
44
- ret = "D" if stage == "40" and doctype == "amendment"
45
- ret = "FD" if stage == "50" and
46
- %w(amendment technical-corrigendum).include?(doctype)
47
- ret = "D" if stage == "50" and
48
- %w(technical-report technical-specification).include?(doctype)
43
+ ret = "D" if stage == "40" && doctype == "amendment"
44
+ ret = "FD" if stage == "50" && %w(amendment technical-corrigendum).include?(doctype)
49
45
  end
50
46
  ret
51
47
  end
@@ -54,8 +50,7 @@ module Asciidoctor
54
50
  return "Proof" if stage == "60" && substage == "00"
55
51
  ret = STAGE_NAMES[stage.to_sym]
56
52
  if iteration && %w(20 30).include?(stage)
57
- prefix = iteration.to_i.localize(@lang.to_sym).
58
- to_rbnf_s("SpelloutRules", "spellout-ordinal")
53
+ prefix = iteration.to_i.localize(@lang.to_sym).to_rbnf_s("SpelloutRules", "spellout-ordinal")
59
54
  ret = "#{prefix.capitalize} #{ret.downcase}"
60
55
  end
61
56
  ret
@@ -70,16 +65,13 @@ module Asciidoctor
70
65
  end
71
66
 
72
67
  def iso_id(node, xml)
73
- return unless !@amd && node.attr("docnumber") ||
74
- @amd && node.attr("updates")
68
+ return unless !@amd && node.attr("docnumber") || @amd && node.attr("updates")
75
69
  dn = iso_id1(node)
76
70
  dn1 = id_stage_prefix(dn, node, false)
77
71
  dn2 = id_stage_prefix(dn, node, true)
78
72
  xml.docidentifier dn1, **attr_code(type: "ISO")
79
- xml.docidentifier id_langsuffix(dn1, node),
80
- **attr_code(type: "iso-with-lang")
81
- xml.docidentifier id_langsuffix(dn2, node),
82
- **attr_code(type: "iso-reference")
73
+ xml.docidentifier id_langsuffix(dn1, node), **attr_code(type: "iso-with-lang")
74
+ xml.docidentifier id_langsuffix(dn2, node), **attr_code(type: "iso-reference")
83
75
  end
84
76
 
85
77
  def iso_id1(node)
@@ -132,18 +124,29 @@ module Asciidoctor
132
124
  dn
133
125
  end
134
126
 
135
- def id_stage_abbr(stage, substage, node)
136
- ret = IsoDoc::Iso::Metadata.new("en", "Latn", @i18n).
137
- status_abbrev(stage_abbr(stage, substage, doctype(node)),
138
- substage, node.attr("iteration"),
139
- node.attr("draft"), doctype(node))
140
- if %w(amendment technical-corrigendum amendment
141
- technical-corrigendum).include?(doctype(node))
142
- ret = ret + " " unless %w(40 50).include?(stage)
127
+ def id_stage_abbr(stage, substage, node, bare = false)
128
+ ret = bare ?
129
+ IsoDoc::Iso::Metadata.new("en", "Latn", @i18n)
130
+ .status_abbrev(stage_abbr(stage, substage, doctype(node)),
131
+ substage, nil, nil, doctype(node)) :
132
+ IsoDoc::Iso::Metadata.new("en", "Latn", @i18n)
133
+ .status_abbrev(stage_abbr(stage, substage, doctype(node)),
134
+ substage, node.attr("iteration"),
135
+ node.attr("draft"), doctype(node))
136
+ if %w(amendment technical-corrigendum technical-report technical-specification).include?(doctype(node))
137
+ ret = ret + " " unless %w(D FD).include?(ret)
143
138
  end
144
139
  ret
145
140
  end
146
141
 
142
+ def cover_stage_abbr(node)
143
+ stage = get_stage(node)
144
+ abbr = id_stage_abbr(get_stage(node), get_substage(node), node, true)
145
+ typeabbr = get_typeabbr(node, true)
146
+ typeabbr = "" if stage.to_i > 50 || stage.to_i == 60 && get_substage(node).to_i < 60
147
+ "#{abbr}#{typeabbr}".strip
148
+ end
149
+
147
150
  def id_stage_prefix(dn, node, force_year)
148
151
  stage = get_stage(node)
149
152
  typeabbr = get_typeabbr(node)
@@ -183,10 +186,12 @@ module Asciidoctor
183
186
  node.attr("docsubstage") || ( stage == "60" ? "60" : "00" )
184
187
  end
185
188
 
186
- def get_typeabbr(node)
189
+ def get_typeabbr(node, amd = false)
187
190
  case doctype(node)
188
191
  when "technical-report" then "TR "
189
192
  when "technical-specification" then "TS "
193
+ when "amendment" then (amd ? "Amd " : "")
194
+ when "technical-corrigendum" then (amd ? "Cor " : "")
190
195
  else
191
196
  nil
192
197
  end