metanorma-iso 1.5.10 → 1.6.0

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 (62) 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 +50 -3
  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 +5 -0
  10. data/lib/asciidoctor/iso/isodoc.rng +36 -43
  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 +13 -9
  21. data/lib/isodoc/iso/html/style-human.scss +7 -7
  22. data/lib/isodoc/iso/html/style-iso.css +11 -7
  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 +391 -88
  32. data/lib/isodoc/iso/iso.international-standard.xsl +391 -88
  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/processor.rb +11 -9
  37. data/lib/metanorma/iso/version.rb +1 -1
  38. data/metanorma-iso.gemspec +2 -2
  39. data/spec/asciidoctor-iso/base_spec.rb +26 -14
  40. data/spec/asciidoctor-iso/blocks_spec.rb +1 -1
  41. data/spec/asciidoctor-iso/cleanup_spec.rb +11 -5
  42. data/spec/asciidoctor-iso/lists_spec.rb +6 -6
  43. data/spec/asciidoctor-iso/refs_spec.rb +174 -143
  44. data/spec/asciidoctor-iso/section_spec.rb +5 -0
  45. data/spec/asciidoctor-iso/validate_spec.rb +18 -1
  46. data/spec/isodoc/amd_spec.rb +187 -22
  47. data/spec/isodoc/blocks_spec.rb +1 -0
  48. data/spec/isodoc/i18n_spec.rb +9 -22
  49. data/spec/isodoc/inline_spec.rb +1 -1
  50. data/spec/isodoc/metadata_spec.rb +170 -3
  51. data/spec/isodoc/postproc_spec.rb +2 -5
  52. data/spec/isodoc/ref_spec.rb +4 -7
  53. data/spec/isodoc/section_spec.rb +20 -0
  54. data/spec/isodoc/xref_spec.rb +12 -0
  55. data/spec/spec_helper.rb +17 -1
  56. metadata +8 -12
  57. data/.github/workflows/macos.yml +0 -41
  58. data/.github/workflows/ubuntu.yml +0 -45
  59. data/.github/workflows/windows.yml +0 -43
  60. data/lib/asciidoctor/iso/macros.rb +0 -21
  61. data/lib/asciidoctor/iso/term_lookup_cleanup.rb +0 -86
  62. data/spec/asciidoctor-iso/macros_spec.rb +0 -310
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bcacb0045dc41c1bd31e2623205d83815c60dc4e020bbe6c0485ee0abd2f24d6
4
- data.tar.gz: 795cf80c9d0c18c0aebfeff25f7e919c790b47fbf3352746e5f28cf90701a728
3
+ metadata.gz: c9ff94c61e35de46dc7952d37bfff144de3138445e1deac3634627a2fa6f7a6a
4
+ data.tar.gz: 053100705b2af0c4d3d26359948fa8ba23f811010b2096475664ee5b44c0d3dc
5
5
  SHA512:
6
- metadata.gz: 72ebb4928526e51d726f697c99798f2375f3e26c34b7e641e463a074a9d467a3e94e4d60c68a129ac71552e7826a757af0f20c871aefe5f7b27a2f21e0e17b74
7
- data.tar.gz: 8507e683e4534458a8a3af9908862608e6e07675b2c6cdd9f29788b84ef36b3456fb4a859c33efd8a89f1f91206b2bc6e3dd00ef281ffbcebe8cad5599d08fe7
6
+ metadata.gz: a093a518a812e1fea3f5053f287b589010fc896954ff6da4a9674c72c4d0db566095ba0702ac85b6ba519f23e2d0a09d8697d984c998dbda6759698c6075726c
7
+ data.tar.gz: 45b6dcdb5783272457a495e8c4f2ea2a3c4fab3114d48a8c7d6917782db82f3ee573af34c903fd07cda28447373721dd7cdb83c519bca9ae74208f4f9a77bd8c
@@ -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">
@@ -728,15 +729,61 @@
728
729
  </define>
729
730
  <define name="index">
730
731
  <element name="index">
731
- <attribute name="primary"/>
732
+ <attribute name="to">
733
+ <data type="IDREF"/>
734
+ </attribute>
735
+ <element name="primary">
736
+ <oneOrMore>
737
+ <ref name="PureTextElement"/>
738
+ </oneOrMore>
739
+ </element>
732
740
  <optional>
733
- <attribute name="secondary"/>
741
+ <element name="secondary">
742
+ <oneOrMore>
743
+ <ref name="PureTextElement"/>
744
+ </oneOrMore>
745
+ </element>
734
746
  </optional>
735
747
  <optional>
736
- <attribute name="tertiary"/>
748
+ <element name="tertiary">
749
+ <oneOrMore>
750
+ <ref name="PureTextElement"/>
751
+ </oneOrMore>
752
+ </element>
737
753
  </optional>
738
754
  </element>
739
755
  </define>
756
+ <define name="index-xref">
757
+ <element name="index-xref">
758
+ <attribute name="also">
759
+ <data type="boolean"/>
760
+ </attribute>
761
+ <element name="primary">
762
+ <oneOrMore>
763
+ <ref name="PureTextElement"/>
764
+ </oneOrMore>
765
+ </element>
766
+ <optional>
767
+ <element name="secondary">
768
+ <oneOrMore>
769
+ <ref name="PureTextElement"/>
770
+ </oneOrMore>
771
+ </element>
772
+ </optional>
773
+ <optional>
774
+ <element name="tertiary">
775
+ <oneOrMore>
776
+ <ref name="PureTextElement"/>
777
+ </oneOrMore>
778
+ </element>
779
+ </optional>
780
+ <element name="target">
781
+ <oneOrMore>
782
+ <ref name="PureTextElement"/>
783
+ </oneOrMore>
784
+ </element>
785
+ </element>
786
+ </define>
740
787
  <!-- bare ID element, used for referencing arbitrary spans of text -->
741
788
  <define name="bookmark">
742
789
  <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" }
@@ -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">
@@ -47,6 +55,13 @@
47
55
  <param name="pattern">\i\c*|\c+#\c+</param>
48
56
  </data>
49
57
  </attribute>
58
+ <optional>
59
+ <attribute name="to">
60
+ <data type="string">
61
+ <param name="pattern">\i\c*|\c+#\c+</param>
62
+ </data>
63
+ </attribute>
64
+ </optional>
50
65
  <optional>
51
66
  <attribute name="type">
52
67
  <ref name="ReferenceFormat"/>
@@ -141,6 +156,11 @@
141
156
  <data type="boolean"/>
142
157
  </attribute>
143
158
  </optional>
159
+ <optional>
160
+ <attribute name="key">
161
+ <data type="boolean"/>
162
+ </attribute>
163
+ </optional>
144
164
  <oneOrMore>
145
165
  <ref name="dt"/>
146
166
  <ref name="dd"/>
@@ -233,6 +253,9 @@
233
253
  <data type="boolean"/>
234
254
  </attribute>
235
255
  </optional>
256
+ <optional>
257
+ <ref name="colgroup"/>
258
+ </optional>
236
259
  <optional>
237
260
  <ref name="tname"/>
238
261
  </optional>
@@ -751,6 +774,18 @@
751
774
  </define>
752
775
  </include>
753
776
  <!-- end overrides -->
777
+ <define name="colgroup">
778
+ <element name="colgroup">
779
+ <oneOrMore>
780
+ <ref name="col"/>
781
+ </oneOrMore>
782
+ </element>
783
+ </define>
784
+ <define name="col">
785
+ <element name="col">
786
+ <attribute name="width"/>
787
+ </element>
788
+ </define>
754
789
  <define name="TextElement" combine="choice">
755
790
  <ref name="concept"/>
756
791
  </define>
@@ -1164,49 +1199,7 @@
1164
1199
  </define>
1165
1200
  <define name="annex">
1166
1201
  <element name="annex">
1167
- <optional>
1168
- <attribute name="id">
1169
- <data type="ID"/>
1170
- </attribute>
1171
- </optional>
1172
- <optional>
1173
- <attribute name="language"/>
1174
- </optional>
1175
- <optional>
1176
- <attribute name="script"/>
1177
- </optional>
1178
- <optional>
1179
- <attribute name="inline-header">
1180
- <data type="boolean"/>
1181
- </attribute>
1182
- </optional>
1183
- <attribute name="obligation">
1184
- <choice>
1185
- <value>normative</value>
1186
- <value>informative</value>
1187
- </choice>
1188
- </attribute>
1189
- <optional>
1190
- <ref name="section-title"/>
1191
- </optional>
1192
- <group>
1193
- <group>
1194
- <zeroOrMore>
1195
- <ref name="BasicBlock"/>
1196
- </zeroOrMore>
1197
- <zeroOrMore>
1198
- <ref name="note"/>
1199
- </zeroOrMore>
1200
- </group>
1201
- <zeroOrMore>
1202
- <choice>
1203
- <ref name="annex-subsection"/>
1204
- <ref name="terms"/>
1205
- <ref name="definitions"/>
1206
- <ref name="references"/>
1207
- </choice>
1208
- </zeroOrMore>
1209
- </group>
1202
+ <ref name="Annex-Section"/>
1210
1203
  </element>
1211
1204
  </define>
1212
1205
  <define name="terms">