metanorma-iso 1.3.24 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +8 -1
  3. data/.github/workflows/ubuntu.yml +14 -3
  4. data/.github/workflows/windows.yml +8 -1
  5. data/lib/asciidoctor/iso/base.rb +21 -13
  6. data/lib/asciidoctor/iso/biblio.rng +36 -6
  7. data/lib/asciidoctor/iso/cleanup.rb +10 -1
  8. data/lib/asciidoctor/iso/front.rb +16 -110
  9. data/lib/asciidoctor/iso/front_id.rb +196 -0
  10. data/lib/asciidoctor/iso/isodoc.rng +444 -1
  11. data/lib/asciidoctor/iso/isostandard-amd.rng +98 -0
  12. data/lib/asciidoctor/iso/isostandard.rng +12 -1
  13. data/lib/asciidoctor/iso/reqt.rng +23 -0
  14. data/lib/asciidoctor/iso/section.rb +12 -0
  15. data/lib/asciidoctor/iso/term_lookup_cleanup.rb +7 -10
  16. data/lib/asciidoctor/iso/validate.rb +40 -23
  17. data/lib/asciidoctor/iso/validate_requirements.rb +1 -1
  18. data/lib/asciidoctor/iso/validate_style.rb +6 -5
  19. data/lib/asciidoctor/iso/validate_title.rb +1 -1
  20. data/lib/isodoc/iso/base_convert.rb +68 -87
  21. data/lib/isodoc/iso/html/header.html +5 -1
  22. data/lib/isodoc/iso/html/html_iso_titlepage.html +25 -16
  23. data/lib/isodoc/iso/html/isodoc.scss +25 -0
  24. data/lib/isodoc/iso/html/scripts.html +18 -0
  25. data/lib/isodoc/iso/html/style-human.scss +23 -0
  26. data/lib/isodoc/iso/html/style-iso.scss +18 -0
  27. data/lib/isodoc/iso/html/word_iso_intro.html +4 -0
  28. data/lib/isodoc/iso/html/word_iso_titlepage.html +21 -0
  29. data/lib/isodoc/iso/html/wordstyle.scss +45 -4
  30. data/lib/isodoc/iso/iso.amendment.xsl +5082 -0
  31. data/lib/isodoc/iso/iso.international-standard.xsl +1226 -530
  32. data/lib/isodoc/iso/metadata.rb +67 -23
  33. data/lib/isodoc/iso/pdf_convert.rb +5 -11
  34. data/lib/isodoc/iso/presentation_xml_convert.rb +13 -0
  35. data/lib/isodoc/iso/sections.rb +66 -0
  36. data/lib/isodoc/iso/sts_convert.rb +31 -0
  37. data/lib/isodoc/iso/xref.rb +111 -0
  38. data/lib/metanorma-iso.rb +2 -0
  39. data/lib/metanorma/iso/processor.rb +20 -9
  40. data/lib/metanorma/iso/version.rb +1 -1
  41. data/metanorma-iso.gemspec +5 -2
  42. data/spec/asciidoctor-iso/amd_spec.rb +726 -0
  43. data/spec/asciidoctor-iso/base_spec.rb +24 -20
  44. data/spec/asciidoctor-iso/cleanup_spec.rb +2 -2
  45. data/spec/asciidoctor-iso/macros_spec.rb +33 -17
  46. data/spec/asciidoctor-iso/refs_spec.rb +1 -1
  47. data/spec/asciidoctor-iso/table_spec.rb +1 -1
  48. data/spec/isodoc/amd_spec.rb +652 -0
  49. data/spec/isodoc/blocks_spec.rb +112 -27
  50. data/spec/isodoc/inline_spec.rb +2 -2
  51. data/spec/isodoc/metadata_spec.rb +88 -4
  52. data/spec/isodoc/postproc_spec.rb +11 -11
  53. data/spec/isodoc/ref_spec.rb +7 -7
  54. data/spec/isodoc/section_spec.rb +28 -1
  55. data/spec/isodoc/table_spec.rb +29 -29
  56. data/spec/isodoc/terms_spec.rb +4 -4
  57. data/spec/isodoc/xref_spec.rb +32 -26
  58. data/spec/metanorma/processor_spec.rb +2 -2
  59. data/spec/spec_helper.rb +11 -0
  60. metadata +61 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0207a8005dcd32df7bd28bcf352786a876ff8301ef7942a678d5bf75ef1bd7a0
4
- data.tar.gz: f1eb4a83fe424bc740add6d2a82e2ceaf0b11f38b34ae775108e2afa3d6d2f80
3
+ metadata.gz: b96ba72711abf2b94b4b63a7431c979e2436809689aee14aa1dbc3bf274e9833
4
+ data.tar.gz: 52d899afc5b1949ba84a9663db914faa4f89aee27e3c365328d9d51925c3a218
5
5
  SHA512:
6
- metadata.gz: 181c074093254bbd29824c8af4f7f295781efe18f7ff201f8795da58c52493e30d5e38daff93b6b194e7dd379ea7186a56ae6c2d4331a18a7b7583e6157ec615
7
- data.tar.gz: 8b5afd3661cd307878b38e342235f919a9a3960727560fef059b1df4e1ed8023e3cb253b2a506d3b40ba7bf85272777aa7e49d3efe7b9c0ded44fc134e9a46ed
6
+ metadata.gz: 4a43742cf9c3f5ad00f1f131b351f9cacf417797a985ad10b0a23a4ce059cd53a6fdcbaa07e9e6d7609681878ad686a19d0e3c114f224d7927b5735c44594426
7
+ data.tar.gz: 74b190a8468053ce3e5bc25e477a5bdc48abedc12436e3a971b6fe77e5259ffd6e62c5789e41e18c18a89ab2602b2b188c5f1fdbe747bdcab40e95c938dd681d
@@ -6,22 +6,29 @@ on:
6
6
  push:
7
7
  branches: [ master ]
8
8
  pull_request:
9
+ paths-ignore:
10
+ - .github/workflows/ubuntu.yml
11
+ - .github/workflows/windows.yml
9
12
 
10
13
  jobs:
11
14
  test-macos:
12
15
  name: Test on Ruby ${{ matrix.ruby }} macOS
13
16
  runs-on: macos-latest
17
+ continue-on-error: ${{ matrix.experimental }}
14
18
  strategy:
15
19
  fail-fast: false
16
20
  matrix:
17
21
  ruby: [ '2.6', '2.5', '2.4' ]
22
+ experimental: [false]
23
+ include:
24
+ - ruby: '2.7'
25
+ experimental: true
18
26
  steps:
19
27
  - uses: actions/checkout@master
20
28
  - name: Use Ruby
21
29
  uses: actions/setup-ruby@v1
22
30
  with:
23
31
  ruby-version: ${{ matrix.ruby }}
24
- architecture: 'x64'
25
32
  - name: Update gems
26
33
  run: |
27
34
  sudo gem install bundler --force
@@ -6,29 +6,40 @@ on:
6
6
  push:
7
7
  branches: [ master ]
8
8
  pull_request:
9
+ paths-ignore:
10
+ - .github/workflows/macos.yml
11
+ - .github/workflows/windows.yml
9
12
 
10
13
  jobs:
11
14
  test-linux:
12
15
  name: Test on Ruby ${{ matrix.ruby }} Ubuntu
13
16
  runs-on: ubuntu-latest
17
+ continue-on-error: ${{ matrix.experimental }}
14
18
  strategy:
15
19
  fail-fast: false
16
20
  matrix:
17
21
  ruby: [ '2.6', '2.5', '2.4' ]
22
+ experimental: [false]
23
+ include:
24
+ - ruby: '2.7'
25
+ experimental: true
18
26
  steps:
19
27
  - uses: actions/checkout@master
20
28
  - name: Use Ruby
21
29
  uses: actions/setup-ruby@v1
22
30
  with:
23
31
  ruby-version: ${{ matrix.ruby }}
24
- architecture: 'x64'
25
32
  - name: Update gems
26
33
  run: |
27
34
  gem install bundler
28
35
  bundle install --jobs 4 --retry 3
29
36
  - name: Install PlantUML
30
- run: |
31
- sudo bash -c "curl -L https://github.com/riboseinc/plantuml-install/raw/master/ubuntu.sh | bash"
37
+ uses: nick-invision/retry@v1
38
+ with:
39
+ polling_interval_seconds: 5
40
+ timeout_minutes: 5
41
+ max_attempts: 3
42
+ command: sudo bash -c "curl -L https://github.com/metanorma/plantuml-install/raw/master/ubuntu.sh | bash"
32
43
  - name: Run specs
33
44
  run: |
34
45
  bundle exec rake
@@ -6,22 +6,29 @@ on:
6
6
  push:
7
7
  branches: [ master ]
8
8
  pull_request:
9
+ paths-ignore:
10
+ - .github/workflows/macos.yml
11
+ - .github/workflows/ubuntu.yml
9
12
 
10
13
  jobs:
11
14
  test-windows:
12
15
  name: Test on Ruby ${{ matrix.ruby }} Windows
13
16
  runs-on: windows-latest
17
+ continue-on-error: ${{ matrix.experimental }}
14
18
  strategy:
15
19
  fail-fast: false
16
20
  matrix:
17
21
  ruby: [ '2.6', '2.5', '2.4' ]
22
+ experimental: [false]
23
+ include:
24
+ - ruby: '2.7'
25
+ experimental: true
18
26
  steps:
19
27
  - uses: actions/checkout@master
20
28
  - name: Use Ruby
21
29
  uses: actions/setup-ruby@v1
22
30
  with:
23
31
  ruby-version: ${{ matrix.ruby }}
24
- architecture: 'x64'
25
32
  - name: Update gems
26
33
  shell: pwsh
27
34
  run: |
@@ -36,20 +36,28 @@ module Asciidoctor
36
36
  IsoDoc::Iso::PdfConvert.new(doc_extract_attributes(node))
37
37
  end
38
38
 
39
- def document(node)
40
- init(node)
41
- ret = makexml(node).to_xml(indent: 2)
42
- unless node.attr("nodoc") || !node.attr("docfile")
39
+ def sts_converter(node)
40
+ return nil if node.attr("no-pdf")
41
+ IsoDoc::Iso::StsConvert.new(html_extract_attributes(node))
42
+ end
43
+
44
+ def presentation_xml_converter(node)
45
+ IsoDoc::Iso::PresentationXMLConvert.new(html_extract_attributes(node))
46
+ end
47
+
48
+ def init(node)
49
+ super
50
+ @amd = %w(amendment technical-corrigendum).include? node.attr("doctype")
51
+ end
52
+
53
+ def outputs(node, ret)
43
54
  File.open(@filename + ".xml", "w:UTF-8") { |f| f.write(ret) }
44
- html_converter_alt(node).convert(@filename + ".xml")
45
- FileUtils.mv "#{@filename}.html", "#{@filename}_alt.html"
46
- html_converter(node).convert(@filename + ".xml")
47
- doc_converter(node).convert(@filename + ".xml")
48
- pdf_converter(node)&.convert(@filename + ".xml")
49
- end
50
- @log.write(@localdir + @filename + ".err") unless @novalid
51
- @files_to_delete.each { |f| FileUtils.rm f }
52
- ret
55
+ presentation_xml_converter(node).convert(@filename + ".xml")
56
+ html_converter_alt(node).convert(@filename + ".presentation.xml", nil, false, "#{@filename}_alt.html")
57
+ html_converter(node).convert(@filename + ".presentation.xml", nil, false, "#{@filename}.html")
58
+ doc_converter(node).convert(@filename + ".presentation.xml", nil, false, "#{@filename}.doc")
59
+ pdf_converter(node)&.convert(@filename + ".presentation.xml", nil, false, "#{@filename}.pdf")
60
+ #sts_converter(node)&.convert(@filename + ".xml")
53
61
  end
54
62
 
55
63
  def load_yaml(lang, script)
@@ -88,7 +88,7 @@
88
88
  <text/>
89
89
  </element>
90
90
  </define>
91
- <define name="LocalizedString">
91
+ <define name="LocalizedString1">
92
92
  <optional>
93
93
  <!-- multiple languages and scripts possible: comma delimit them if so -->
94
94
  <attribute name="language"/>
@@ -98,6 +98,16 @@
98
98
  </optional>
99
99
  <text/>
100
100
  </define>
101
+ <define name="LocalizedString">
102
+ <choice>
103
+ <ref name="LocalizedString1"/>
104
+ <oneOrMore>
105
+ <element name="variant">
106
+ <ref name="LocalizedString1"/>
107
+ </element>
108
+ </oneOrMore>
109
+ </choice>
110
+ </define>
101
111
  <!--
102
112
  Unlike UML, change type to format: type is overloaded
103
113
  Would be need if plain were default value and could omit the attribute
@@ -121,7 +131,7 @@
121
131
  </optional>
122
132
  <ref name="LocalizedStringOrXsAny"/>
123
133
  </define>
124
- <define name="LocalizedStringOrXsAny">
134
+ <define name="LocalizedStringOrXsAny1">
125
135
  <optional>
126
136
  <!-- multiple languages and scripts possible: comma delimit them if so -->
127
137
  <attribute name="language"/>
@@ -136,6 +146,16 @@
136
146
  </choice>
137
147
  </oneOrMore>
138
148
  </define>
149
+ <define name="LocalizedStringOrXsAny">
150
+ <choice>
151
+ <ref name="LocalizedStringOrXsAny1"/>
152
+ <oneOrMore>
153
+ <element name="variant">
154
+ <ref name="LocalizedStringOrXsAny1"/>
155
+ </element>
156
+ </oneOrMore>
157
+ </choice>
158
+ </define>
139
159
  <define name="contributor">
140
160
  <element name="contributor">
141
161
  <zeroOrMore>
@@ -512,7 +532,7 @@
512
532
  </define>
513
533
  <define name="LocalityType">
514
534
  <data type="string">
515
- <param name="pattern">section|clause|part|paragraph|chapter|page|whole|table|annex|figure|note|list|example|volume|issue|time|locality:[a-zA-Z0-9_]+</param>
535
+ <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>
516
536
  </data>
517
537
  </define>
518
538
  <define name="referenceFrom">
@@ -641,9 +661,9 @@
641
661
  <optional>
642
662
  <ref name="status"/>
643
663
  </optional>
644
- <optional>
664
+ <zeroOrMore>
645
665
  <ref name="copyright"/>
646
- </optional>
666
+ </zeroOrMore>
647
667
  <zeroOrMore>
648
668
  <ref name="docrelation"/>
649
669
  </zeroOrMore>
@@ -1001,7 +1021,17 @@
1001
1021
  <optional>
1002
1022
  <ref name="to"/>
1003
1023
  </optional>
1004
- <ref name="owner"/>
1024
+ <oneOrMore>
1025
+ <ref name="owner"/>
1026
+ </oneOrMore>
1027
+ <optional>
1028
+ <ref name="copyright_scope"/>
1029
+ </optional>
1030
+ </element>
1031
+ </define>
1032
+ <define name="copyright_scope">
1033
+ <element name="scope">
1034
+ <text/>
1005
1035
  </element>
1006
1036
  </define>
1007
1037
  <define name="from">
@@ -36,6 +36,7 @@ module Asciidoctor
36
36
  end
37
37
 
38
38
  def id_prefix(prefix, id)
39
+ return id.text if @amd # we're just inheriting the prefixes from parent doc
39
40
  prefix.join("/") + ( id.text.match(%{^/}) ? "" : " " ) + id.text
40
41
  end
41
42
 
@@ -52,7 +53,7 @@ module Asciidoctor
52
53
  # ISO as a prefix goes first
53
54
  def docidentifier_cleanup(xmldoc)
54
55
  prefix = get_id_prefix(xmldoc)
55
- id = xmldoc.at("//bibdata/docidentifier[@type = 'iso']") or return
56
+ id = xmldoc.at("//bibdata/docidentifier[@type = 'ISO']") or return
56
57
  id.content = id_prefix(prefix, id)
57
58
  id = xmldoc.at("//bibdata/ext/structuredidentifier/project-number") and
58
59
  id.content = id_prefix(prefix, id)
@@ -116,6 +117,14 @@ module Asciidoctor
116
117
  "#{num.nil? ? abbrid : sprintf("%09d", num.to_i)} :: "\
117
118
  "#{partid} :: #{id&.text} :: #{title}"
118
119
  end
120
+
121
+ def sections_cleanup(x)
122
+ super
123
+ return unless @amd
124
+ x.xpath("//*[@inline-header]").each do |h|
125
+ h.delete('inline-header')
126
+ end
127
+ end
119
128
  end
120
129
  end
121
130
  end
@@ -5,113 +5,18 @@ require "json"
5
5
  require "pathname"
6
6
  require "open-uri"
7
7
  require "pp"
8
+ require_relative "front_id"
8
9
 
9
10
  module Asciidoctor
10
11
  module ISO
11
12
  class Converter < Standoc::Converter
12
- STAGE_ABBRS = {
13
- "00": "PWI",
14
- "10": "NWIP",
15
- "20": "WD",
16
- "30": "CD",
17
- "40": "DIS",
18
- "50": "FDIS",
19
- "60": "IS",
20
- "90": "(Review)",
21
- "95": "(Withdrawal)",
22
- }.freeze
23
-
24
- STAGE_NAMES = {
25
- "00": "Preliminary work item",
26
- "10": "New work item proposal",
27
- "20": "Working draft",
28
- "30": "Committee draft",
29
- "40": "Draft international standard",
30
- "50": "Final draft international standard",
31
- "60": "International standard",
32
- "90": "Review",
33
- "95": "Withdrawal",
34
- }.freeze
35
-
36
- def stage_abbr(stage, substage)
37
- return nil if stage.to_i > 60
38
- return "PRF" if stage == "60" && substage == "00"
39
- STAGE_ABBRS[stage.to_sym]
40
- end
41
-
42
- def stage_name(stage, substage)
43
- return "Proof" if stage == "60" && substage == "00"
44
- STAGE_NAMES[stage.to_sym]
45
- end
46
-
47
- def metadata_id(node, xml)
48
- iso_id(node, xml)
49
- node&.attr("tc-docnumber")&.split(/,\s*/)&.each do |n|
50
- xml.docidentifier(n, **attr_code(type: "iso-tc"))
51
- end
52
- xml.docnumber node&.attr("docnumber")
53
- end
54
-
55
- def iso_id(node, xml)
56
- return unless node.attr("docnumber")
57
- part, subpart = node&.attr("partnumber")&.split(/-/)
58
- dn = add_id_parts(node.attr("docnumber"), part, subpart)
59
- dn1 = id_stage_prefix(dn, node, false)
60
- dn2 = id_stage_prefix(dn, node, true)
61
- xml.docidentifier dn1, **attr_code(type: "iso")
62
- xml.docidentifier id_langsuffix(dn1, node), **attr_code(type: "iso-with-lang")
63
- xml.docidentifier id_langsuffix(dn2, node), **attr_code(type: "iso-reference")
64
- end
65
-
66
- def id_langsuffix(dn, node)
67
- lang = node.attr("language") || "en"
68
- suffix = case lang
69
- when "en" then "(E)"
70
- when "fr" then "(F)"
71
- else
72
- "(X)"
73
- end
74
- "#{dn}#{suffix}"
75
- end
76
-
77
13
  def metadata_ext(node, xml)
78
14
  super
79
15
  structured_id(node, xml)
80
- xml.stagename stage_name(get_stage(node), get_substage(node))
81
- end
82
-
83
- def structured_id(node, xml)
84
- return unless node.attr("docnumber")
85
- part, subpart = node&.attr("partnumber")&.split(/-/)
86
- xml.structuredidentifier do |i|
87
- i.project_number node.attr("docnumber"),
88
- **attr_code(part: part, subpart: subpart)
89
- end
90
- end
91
-
92
- def add_id_parts(dn, part, subpart)
93
- dn += "-#{part}" if part
94
- dn += "-#{subpart}" if subpart
95
- dn
96
- end
97
-
98
- def id_stage_abbr(stage, substage, node)
99
- IsoDoc::Iso::Metadata.new("en", "Latn", {}).
100
- status_abbrev(stage_abbr(stage, substage), substage, node.attr("iteration"),
101
- node.attr("draft"))
102
- end
103
-
104
- def id_stage_prefix(dn, node, force_year)
105
- stage = get_stage(node)
106
- substage = get_substage(node)
107
- if stage && (stage.to_i < 60)
108
- abbr = id_stage_abbr(stage, substage, node)
109
- dn = "/#{abbr} #{dn}" unless abbr.nil? || abbr.empty? # prefixes added in cleanup
110
- end
111
- if force_year || !(stage && (stage.to_i < 60))
112
- dn += ":#{node.attr("copyright-year")}" if node.attr("copyright-year")
113
- end
114
- dn
16
+ xml.stagename stage_name(get_stage(node), get_substage(node),
17
+ node.attr("doctype"), node.attr("iteration"))
18
+ @amd && a = node.attr("updates-document-type") and
19
+ xml.updates_document_type a
115
20
  end
116
21
 
117
22
  def organization(org, orgname)
@@ -160,20 +65,11 @@ module Asciidoctor
160
65
  end
161
66
  end
162
67
 
163
- def get_stage(node)
164
- stage = node.attr("status") || node.attr("docstage") || "60"
165
- end
166
-
167
- def get_substage(node)
168
- stage = get_stage(node)
169
- node.attr("docsubstage") || ( stage == "60" ? "60" : "00" )
170
- end
171
-
172
68
  def metadata_status(node, xml)
173
69
  stage = get_stage(node)
174
70
  substage = get_substage(node)
175
71
  xml.status do |s|
176
- s.stage stage, **attr_code(abbreviation: stage_abbr(stage, substage))
72
+ s.stage stage, **attr_code(abbreviation: stage_abbr(stage, substage, node.attr("doctype")))
177
73
  s.substage substage
178
74
  node.attr("iteration") && (s.iteration node.attr("iteration"))
179
75
  end
@@ -208,12 +104,21 @@ module Asciidoctor
208
104
  end
209
105
  end
210
106
 
107
+ def title_amd(node, t, lang, at)
108
+ return unless node.attr("title-amendment-#{lang}")
109
+ t.title(**attr_code(at.merge(type: "title-amd"))) do |t1|
110
+ t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-amendment-#{lang}"))
111
+ end
112
+ end
113
+
211
114
  def title_full(node, t, lang, at)
212
115
  title = node.attr("title-main-#{lang}")
213
116
  intro = node.attr("title-intro-#{lang}")
214
117
  part = node.attr("title-part-#{lang}")
118
+ amd = node.attr("title-amendment-#{lang}")
215
119
  title = "#{intro} -- #{title}" if intro
216
120
  title = "#{title} -- #{part}" if part
121
+ title = "#{title} -- #{amd}" if amd && @amd
217
122
  t.title **attr_code(at.merge(type: "main")) do |t1|
218
123
  t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(title)
219
124
  end
@@ -226,6 +131,7 @@ module Asciidoctor
226
131
  title_intro(node, xml, lang, at)
227
132
  title_main(node, xml, lang, at)
228
133
  title_part(node, xml, lang, at)
134
+ title_amd(node, xml, lang, at) if @amd
229
135
  end
230
136
  end
231
137
  end