metanorma-iso 1.5.9 → 1.5.14

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 (64) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +66 -0
  3. data/README.adoc +5 -6
  4. data/lib/asciidoctor/iso/base.rb +5 -5
  5. data/lib/asciidoctor/iso/basicdoc.rng +32 -0
  6. data/lib/asciidoctor/iso/boilerplate-fr.xml +40 -0
  7. data/lib/asciidoctor/iso/boilerplate.xml +1 -0
  8. data/lib/asciidoctor/iso/cleanup.rb +38 -6
  9. data/lib/asciidoctor/iso/front.rb +11 -3
  10. data/lib/asciidoctor/iso/isodoc.rng +29 -44
  11. data/lib/asciidoctor/iso/isostandard.rng +11 -0
  12. data/lib/asciidoctor/iso/validate.rb +1 -1
  13. data/lib/asciidoctor/iso/validate_section.rb +9 -0
  14. data/lib/isodoc/iso/base_convert.rb +2 -1
  15. data/lib/isodoc/iso/html/header.html +12 -24
  16. data/lib/isodoc/iso/html/htmlstyle.css +1 -1
  17. data/lib/isodoc/iso/html/htmlstyle.scss +1 -1
  18. data/lib/isodoc/iso/html/isodoc.css +42 -42
  19. data/lib/isodoc/iso/html/isodoc.scss +42 -42
  20. data/lib/isodoc/iso/html/style-human.css +14 -10
  21. data/lib/isodoc/iso/html/style-human.scss +7 -7
  22. data/lib/isodoc/iso/html/style-iso.css +12 -8
  23. data/lib/isodoc/iso/html/style-iso.scss +5 -5
  24. data/lib/isodoc/iso/html/wordstyle.css +67 -67
  25. data/lib/isodoc/iso/html/wordstyle.scss +67 -67
  26. data/lib/isodoc/iso/html_convert.rb +4 -0
  27. data/lib/isodoc/iso/i18n-en.yaml +4 -0
  28. data/lib/isodoc/iso/i18n-fr.yaml +5 -0
  29. data/lib/isodoc/iso/i18n-zh-Hans.yaml +5 -0
  30. data/lib/isodoc/iso/i18n.rb +10 -11
  31. data/lib/isodoc/iso/iso.amendment.xsl +562 -120
  32. data/lib/isodoc/iso/iso.international-standard.xsl +562 -120
  33. data/lib/isodoc/iso/metadata.rb +20 -19
  34. data/lib/isodoc/iso/word_convert.rb +4 -0
  35. data/lib/isodoc/iso/xref.rb +10 -0
  36. data/lib/metanorma/iso/fonts_manifest.yaml +6 -0
  37. data/lib/metanorma/iso/processor.rb +0 -9
  38. data/lib/metanorma/iso/version.rb +1 -1
  39. data/metanorma-iso.gemspec +1 -1
  40. data/spec/asciidoctor-iso/base_spec.rb +140 -12
  41. data/spec/asciidoctor-iso/blocks_spec.rb +1 -1
  42. data/spec/asciidoctor-iso/cleanup_spec.rb +4 -4
  43. data/spec/asciidoctor-iso/lists_spec.rb +6 -6
  44. data/spec/asciidoctor-iso/refs_spec.rb +174 -143
  45. data/spec/asciidoctor-iso/section_spec.rb +5 -0
  46. data/spec/asciidoctor-iso/validate_spec.rb +52 -15
  47. data/spec/assets/xref_error.adoc +7 -0
  48. data/spec/isodoc/amd_spec.rb +188 -29
  49. data/spec/isodoc/blocks_spec.rb +1 -0
  50. data/spec/isodoc/i18n_spec.rb +9 -22
  51. data/spec/isodoc/inline_spec.rb +1 -1
  52. data/spec/isodoc/metadata_spec.rb +172 -19
  53. data/spec/isodoc/postproc_spec.rb +2 -5
  54. data/spec/isodoc/ref_spec.rb +4 -7
  55. data/spec/isodoc/section_spec.rb +20 -0
  56. data/spec/isodoc/xref_spec.rb +12 -0
  57. data/spec/spec_helper.rb +21 -1
  58. metadata +8 -10
  59. data/.github/workflows/macos.yml +0 -41
  60. data/.github/workflows/ubuntu.yml +0 -45
  61. data/.github/workflows/windows.yml +0 -43
  62. data/lib/asciidoctor/iso/macros.rb +0 -21
  63. data/lib/asciidoctor/iso/term_lookup_cleanup.rb +0 -86
  64. data/spec/asciidoctor-iso/macros_spec.rb +0 -310
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f062c8a45b1571a860957f18b17486aeeb235b0b9bc63fe2dced19bfb87cfee7
4
- data.tar.gz: 330063e5d378fedb3b4e40da8b3ab577ba5d64e0ee0171699657eab00bca35b6
3
+ metadata.gz: 0e01ee8230b538949046cc2891d993eb0c6f3c3b9d3276d7e16ad05617c075eb
4
+ data.tar.gz: b1f87a4bc24143414ff469dc73541e4e581c04a803231a1ad10e60faf2a8d6aa
5
5
  SHA512:
6
- metadata.gz: ffa2c512604cfb1cc4933d854df04a7690aecbdddf0df8b09aa74b2d0d4dd7534f2ec33d0eeb54525f3edddc67e4851f7fffb0282c0ddc889b9d81d6b507a370
7
- data.tar.gz: 41fb639fb4076cd238872f8411734e51b7647123a26b4ed05ab948d58b32c1df57f7d8d874b178cb3b5f35cdb9a6efaa3f7c5fb3f59068820797101b34a24bd9
6
+ metadata.gz: 7e5582b6f64fd353fdcf5dd67fe897a91fb1d500b240cc4ddf7cfceba99435eb75935d4eceb70e5b6512ba3a0a3d68c373e2ecfc2f7a4ee718524449d7891870
7
+ data.tar.gz: 386d6f98b45ff9b03dc56e06177a0fa3b7b750732093c3697c1c32935b1b6e7c931f769d6f3ce4073c562ada67e7fc24e4ae6187337182a9d3234a7d72b6c5fe
@@ -0,0 +1,66 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: rake
4
+
5
+ on:
6
+ push:
7
+ branches: [ master, main ]
8
+ tags: [ v* ]
9
+ pull_request:
10
+
11
+ jobs:
12
+ rake:
13
+ name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
14
+ runs-on: ${{ matrix.os }}
15
+ continue-on-error: ${{ matrix.experimental }}
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ ruby: [ '2.6', '2.5', '2.4' ]
20
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
21
+ experimental: [ false ]
22
+ include:
23
+ - ruby: '2.7'
24
+ os: 'ubuntu-latest'
25
+ experimental: true
26
+ - ruby: '2.7'
27
+ os: 'windows-latest'
28
+ experimental: true
29
+ - ruby: '2.7'
30
+ os: 'macos-latest'
31
+ experimental: true
32
+ steps:
33
+ - uses: actions/checkout@master
34
+
35
+ - uses: ruby/setup-ruby@v1
36
+ with:
37
+ ruby-version: ${{ matrix.ruby }}
38
+
39
+ - uses: actions/cache@v2
40
+ with:
41
+ path: vendor/bundle
42
+ key: bundle-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}
43
+ restore-keys: bundle-${{ matrix.os }}-${{ matrix.ruby }}
44
+
45
+ - run: bundle config set path 'vendor/bundle'
46
+
47
+ - run: bundle install --jobs 4 --retry 3
48
+
49
+ - name: install plantuml ubuntu
50
+ if: matrix.os == 'ubuntu-latest'
51
+ uses: nick-invision/retry@v1
52
+ with:
53
+ polling_interval_seconds: 5
54
+ timeout_minutes: 5
55
+ max_attempts: 3
56
+ command: >
57
+ sudo apt-get update -y && sudo bash -c
58
+ "curl -L https://github.com/metanorma/plantuml-install/raw/master/ubuntu.sh | bash"
59
+
60
+ - if: matrix.os == 'macos-latest'
61
+ run: brew install plantuml
62
+
63
+ - if: matrix.os == 'windows-latest'
64
+ run: cinst -y plantuml
65
+
66
+ - run: bundle exec rake
@@ -1,22 +1,18 @@
1
1
  = Metanorma-ISO: Metanorma processor for ISO standards
2
2
 
3
3
  image:https://img.shields.io/gem/v/metanorma-iso.svg["Gem Version", link="https://rubygems.org/gems/metanorma-iso"]
4
- image:https://github.com/metanorma/metanorma-iso/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/metanorma/metanorma-iso/actions?workflow=macos"]
5
- image:https://github.com/metanorma/metanorma-iso/workflows/ubuntu/badge.svg["Build Status (ubuntu)", link="https://github.com/metanorma/metanorma-iso/actions?workflow=ubuntu"]
6
- image:https://github.com/metanorma/metanorma-iso/workflows/windows/badge.svg["Build Status (Windows)", link="https://github.com/metanorma/metanorma-iso/actions?workflow=windows"]
4
+ image:https://github.com/metanorma/metanorma-iso/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/metanorma-iso/actions?workflow=rake"]
7
5
  image:https://codeclimate.com/github/metanorma/metanorma-iso/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/metanorma-iso"]
8
6
  image:https://img.shields.io/github/issues-pr-raw/metanorma/metanorma-iso.svg["Pull Requests", link="https://github.com/metanorma/metanorma-iso/pulls"]
9
7
  image:https://img.shields.io/github/commits-since/metanorma/metanorma-iso/latest.svg["Commits since latest",link="https://github.com/metanorma/metanorma-iso/releases"]
10
8
 
11
- _Formerly known as_ `asciidoctor-iso`.
12
-
13
9
  == Functionality and Approach
14
10
 
15
11
  For the conceptual underpinnings of this gem, and the other gems in the Metanorma suite, see the https://github.com/metanorma/metanorma-model-standoc/blob/master/README.adoc[metanorma-standoc README].
16
12
 
17
13
  == Outputs
18
14
 
19
- This gem processes Metanorma documents following a template for generating ISO
15
+ This gem processes https://www.metanorma.com[Metanorma documents] following a template for generating ISO
20
16
  International Standards. The following outputs are generated.
21
17
 
22
18
  * The XML representation of the document, intended as a document model for ISO
@@ -79,3 +75,6 @@ See https://www.metanorma.com/author/iso/[The ISO flavor of Metanorma].
79
75
  * Example documents are avalable at the https://github.com/metanorma/mn-samples-iso[mn-samples-iso] repository.
80
76
  * Document templates are available at the https://github.com/metanorma/mn-templates-iso[mn-templates-iso] repository.
81
77
 
78
+ == Notes
79
+
80
+ Metanorma-ISO was formerly published as `asciidoctor-iso`.
@@ -5,7 +5,6 @@ require "pathname"
5
5
  require "open-uri"
6
6
  require "isodoc"
7
7
  require "fileutils"
8
- require 'asciidoctor/iso/macros'
9
8
 
10
9
  module Asciidoctor
11
10
  module ISO
@@ -13,10 +12,6 @@ module Asciidoctor
13
12
  XML_ROOT_TAG = "iso-standard".freeze
14
13
  XML_NAMESPACE = "https://www.metanorma.org/ns/iso".freeze
15
14
 
16
- Asciidoctor::Extensions.register do
17
- inline_macro Asciidoctor::Iso::TermRefInlineMacro
18
- end
19
-
20
15
  def html_converter(node)
21
16
  IsoDoc::Iso::HtmlConvert.new(html_extract_attributes(node))
22
17
  end
@@ -49,6 +44,11 @@ module Asciidoctor
49
44
  @amd = %w(amendment technical-corrigendum).include? doctype(node)
50
45
  end
51
46
 
47
+ def ol_attrs(node)
48
+ attr_code(keep_attrs(node).
49
+ merge(id: ::Asciidoctor::Standoc::Utils::anchor_or_uuid(node)))
50
+ end
51
+
52
52
  def outputs(node, ret)
53
53
  File.open(@filename + ".xml", "w:UTF-8") { |f| f.write(ret) }
54
54
  presentation_xml_converter(node).convert(@filename + ".xml")
@@ -596,6 +596,7 @@
596
596
  <ref name="bookmark"/>
597
597
  <ref name="image"/>
598
598
  <ref name="index"/>
599
+ <ref name="index-xref"/>
599
600
  </choice>
600
601
  </define>
601
602
  <define name="PureTextElement">
@@ -737,6 +738,37 @@
737
738
  </optional>
738
739
  </element>
739
740
  </define>
741
+ <define name="index-xref">
742
+ <element name="index-xref">
743
+ <attribute name="also">
744
+ <data type="boolean"/>
745
+ </attribute>
746
+ <element name="primary">
747
+ <oneOrMore>
748
+ <ref name="PureTextElement"/>
749
+ </oneOrMore>
750
+ </element>
751
+ <optional>
752
+ <element name="secondary">
753
+ <oneOrMore>
754
+ <ref name="PureTextElement"/>
755
+ </oneOrMore>
756
+ </element>
757
+ </optional>
758
+ <optional>
759
+ <element name="tertiary">
760
+ <oneOrMore>
761
+ <ref name="PureTextElement"/>
762
+ </oneOrMore>
763
+ </element>
764
+ </optional>
765
+ <element name="target">
766
+ <oneOrMore>
767
+ <ref name="PureTextElement"/>
768
+ </oneOrMore>
769
+ </element>
770
+ </element>
771
+ </define>
740
772
  <!-- bare ID element, used for referencing arbitrary spans of text -->
741
773
  <define name="bookmark">
742
774
  <element name="bookmark">
@@ -0,0 +1,40 @@
1
+ <boilerplate>
2
+ <copyright-statement>
3
+ <clause>
4
+ <title>DOCUMENT PROTÉGÉ PAR COPYRIGHT</title>
5
+ <p id="boilerplate-year">&copy; {{ agency }} {{ docyear }}</p>
6
+
7
+ <p id="boilerplate-message">
8
+ Droits de reproduction réservés. Sauf indication contraire, aucune partie de cette publication ne
9
+ peut être reproduite ni utilisée sous quelque forme que ce soit et par aucun procédé, électronique
10
+ ou mécanique, y compris la photocopie, l’affichage sur l’internet ou sur un Intranet, sans
11
+ autorisation écrite préalable. Les demandes d’autorisation peuvent être adressées à l’ISO à
12
+ l’adresse ci-après ou au comité membre de l’ISO dans le pays du demandeur.
13
+ </p>
14
+
15
+ <p id="boilerplate-address" align="left">
16
+ ISO copyright office<br/>
17
+ Ch. de Blandonnet 8 &#x2022; CP 401<br/>
18
+ CH-1214 Vernier, Geneva, Switzerland<br/>
19
+ Tel.&nbsp;&nbsp;+ 41 22 749 01 11<br/>
20
+ Fax&nbsp;&nbsp;+ 41 22 749 09 47<br/>
21
+ Email: copyright@iso.org<br/>
22
+ Website: www.iso.org
23
+ </p>
24
+ <p id="boilerplate-place">
25
+ Publié en Suisse
26
+ </p>
27
+ </clause>
28
+ </copyright-statement>
29
+
30
+ {% if unpublished %}
31
+ <license-statement>
32
+ <clause>
33
+ <title>Avertissement</title>
34
+
35
+ <p>Ce document n'est pas une Norme internationale de l'ISO. Il est distribué pour examen et observations. Il est susceptible de modification sans préavis et ne peut être cité comme Norme internationale.</p>
36
+ <p>Les destinataires du présent projet sont invités à présenter, avec leurs observations, notification des droits de propriété dont ils auraient éventuellement connaissance et à fournir une documentation explicative.</p>
37
+ </clause>
38
+ </license-statement>
39
+ {% endif %}
40
+ </boilerplate>
@@ -1,6 +1,7 @@
1
1
  <boilerplate>
2
2
  <copyright-statement>
3
3
  <clause>
4
+ <title>COPYRIGHT PROTECTED DOCUMENT</title>
4
5
  <p id="boilerplate-year">
5
6
  &copy; {{ agency }} {{ docyear }}
6
7
  </p>
@@ -4,7 +4,6 @@ require "htmlentities"
4
4
  require "json"
5
5
  require "pathname"
6
6
  require "open-uri"
7
- require "asciidoctor/iso/term_lookup_cleanup"
8
7
 
9
8
  module Asciidoctor
10
9
  module ISO
@@ -89,11 +88,6 @@ module Asciidoctor
89
88
  end
90
89
  end
91
90
 
92
- def termdef_cleanup(xmldoc)
93
- Asciidoctor::ISO::TermLookupCleanup.new(xmldoc, @log).call
94
- super
95
- end
96
-
97
91
  # TODO sort by authors
98
92
  # sort by: doc class (ISO, IEC, other standard (not DOI &c), other
99
93
  # then standard class (docid class other than DOI &c)
@@ -124,6 +118,44 @@ module Asciidoctor
124
118
  h.delete('inline-header')
125
119
  end
126
120
  end
121
+
122
+ def boilerplate_file(xmldoc)
123
+ file = @lang == "fr" ? "boilerplate-fr.xml" : "boilerplate.xml"
124
+ File.join(@libdir, file)
125
+ end
126
+
127
+ def footnote_cleanup(xmldoc)
128
+ unpub_footnotes(xmldoc)
129
+ super
130
+ end
131
+
132
+ def unpub_footnotes(xmldoc)
133
+ xmldoc.xpath("//bibitem/note[@type = 'Unpublished-Status']").each do |n|
134
+ id = n.parent["id"]
135
+ e = xmldoc.at("//eref[@bibitemid = '#{id}']") or next
136
+ e.next = n.dup
137
+ e.next.name = "fn"
138
+ e.next.delete("format")
139
+ e.next.delete("type")
140
+ end
141
+ end
142
+
143
+ def bibitem_cleanup(xmldoc)
144
+ super
145
+ unpublished_note(xmldoc)
146
+ end
147
+
148
+ def unpublished_note(xmldoc)
149
+ xmldoc.xpath("//bibitem[not(note[@type = 'Unpublished-Status'])]").each do |b|
150
+ next if pub_class(b) > 2
151
+ next unless s = b.at("./status/stage") and s.text.to_i < 60
152
+ 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
157
+ end
158
+ end
127
159
  end
128
160
  end
129
161
  end
@@ -18,6 +18,11 @@ module Asciidoctor
18
18
  xml.updates_document_type a
19
19
  end
20
20
 
21
+ def metadata_doctype(node, xml)
22
+ xml.doctype doctype(node)
23
+ a = node.attr("horizontal") and xml.horizontal a
24
+ end
25
+
21
26
  def org_abbrev
22
27
  { "International Organization for Standardization" => "ISO",
23
28
  "International Electrotechnical Commission" => "IEC" }
@@ -28,7 +33,7 @@ module Asciidoctor
28
33
  csv_split(publishers).each do |p|
29
34
  xml.contributor do |c|
30
35
  c.role **{ type: "author" }
31
- c.organization { |a| organization(a, p) }
36
+ c.organization { |a| organization(a, p, node, !node.attr("publisher")) }
32
37
  end
33
38
  end
34
39
  end
@@ -38,7 +43,7 @@ module Asciidoctor
38
43
  csv_split(publishers).each do |p|
39
44
  xml.contributor do |c|
40
45
  c.role **{ type: "publisher" }
41
- c.organization { |a| organization(a, p) }
46
+ c.organization { |a| organization(a, p, node, !node.attr("publisher")) }
42
47
  end
43
48
  end
44
49
  end
@@ -49,7 +54,10 @@ module Asciidoctor
49
54
  xml.copyright do |c|
50
55
  c.from (node.attr("copyright-year") || Date.today.year)
51
56
  c.owner do |owner|
52
- owner.organization { |o| organization(o, p) }
57
+ owner.organization do |o|
58
+ organization(o, p, node,
59
+ !(node.attr("copyright-holder") || node.attr("publisher")))
60
+ end
53
61
  end
54
62
  end
55
63
  end
@@ -24,6 +24,14 @@
24
24
  <start>
25
25
  <ref name="standard-document"/>
26
26
  </start>
27
+ <define name="doctype">
28
+ <element name="doctype">
29
+ <optional>
30
+ <attribute name="abbreviation"/>
31
+ </optional>
32
+ <ref name="DocumentType"/>
33
+ </element>
34
+ </define>
27
35
  <define name="hyperlink">
28
36
  <element name="link">
29
37
  <attribute name="target">
@@ -42,7 +50,6 @@
42
50
  </define>
43
51
  <define name="xref">
44
52
  <element name="xref">
45
- <!-- attribute target { xsd:IDREF }, -->
46
53
  <attribute name="target">
47
54
  <data type="string">
48
55
  <param name="pattern">\i\c*|\c+#\c+</param>
@@ -142,6 +149,11 @@
142
149
  <data type="boolean"/>
143
150
  </attribute>
144
151
  </optional>
152
+ <optional>
153
+ <attribute name="key">
154
+ <data type="boolean"/>
155
+ </attribute>
156
+ </optional>
145
157
  <oneOrMore>
146
158
  <ref name="dt"/>
147
159
  <ref name="dd"/>
@@ -234,6 +246,9 @@
234
246
  <data type="boolean"/>
235
247
  </attribute>
236
248
  </optional>
249
+ <optional>
250
+ <ref name="colgroup"/>
251
+ </optional>
237
252
  <optional>
238
253
  <ref name="tname"/>
239
254
  </optional>
@@ -752,6 +767,18 @@
752
767
  </define>
753
768
  </include>
754
769
  <!-- end overrides -->
770
+ <define name="colgroup">
771
+ <element name="colgroup">
772
+ <oneOrMore>
773
+ <ref name="col"/>
774
+ </oneOrMore>
775
+ </element>
776
+ </define>
777
+ <define name="col">
778
+ <element name="col">
779
+ <attribute name="width"/>
780
+ </element>
781
+ </define>
755
782
  <define name="TextElement" combine="choice">
756
783
  <ref name="concept"/>
757
784
  </define>
@@ -1165,49 +1192,7 @@
1165
1192
  </define>
1166
1193
  <define name="annex">
1167
1194
  <element name="annex">
1168
- <optional>
1169
- <attribute name="id">
1170
- <data type="ID"/>
1171
- </attribute>
1172
- </optional>
1173
- <optional>
1174
- <attribute name="language"/>
1175
- </optional>
1176
- <optional>
1177
- <attribute name="script"/>
1178
- </optional>
1179
- <optional>
1180
- <attribute name="inline-header">
1181
- <data type="boolean"/>
1182
- </attribute>
1183
- </optional>
1184
- <attribute name="obligation">
1185
- <choice>
1186
- <value>normative</value>
1187
- <value>informative</value>
1188
- </choice>
1189
- </attribute>
1190
- <optional>
1191
- <ref name="section-title"/>
1192
- </optional>
1193
- <group>
1194
- <group>
1195
- <zeroOrMore>
1196
- <ref name="BasicBlock"/>
1197
- </zeroOrMore>
1198
- <zeroOrMore>
1199
- <ref name="note"/>
1200
- </zeroOrMore>
1201
- </group>
1202
- <zeroOrMore>
1203
- <choice>
1204
- <ref name="annex-subsection"/>
1205
- <ref name="terms"/>
1206
- <ref name="definitions"/>
1207
- <ref name="references"/>
1208
- </choice>
1209
- </zeroOrMore>
1210
- </group>
1195
+ <ref name="Annex-Section"/>
1211
1196
  </element>
1212
1197
  </define>
1213
1198
  <define name="terms">