metanorma-csa 1.6.5 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b39b8dc480981f588fa326b12c646f7ed4e40967f18a5614e23032dde195fccb
4
- data.tar.gz: 41e2d38150cb17f451786e0f753b51094097c43694c847ddcd9f193e7881b8a2
3
+ metadata.gz: e6fe06c1107b70d768044a3ebc469e00b060b466c0a4582b84344d25460daff8
4
+ data.tar.gz: 3bdd15ce9f800edd24868b63ffe09f46d110b71906a67446a7000e8291ffa33d
5
5
  SHA512:
6
- metadata.gz: f08298b4edade5b2ec79b7ba3a711ebf47707671f0b31cfda119cb3689c6b092264196535694b04946d59464b32edef2be13405009292c1d4b193ed45f4ff3dd
7
- data.tar.gz: 9007cbedf8e94f4cbd5e65163e8dfefe4659539b5aafd76306fe66a01c8401c5f88fffcae2a1e158f13b9e0e169ab6bfdd3b7f1aaa3744cff46f62e38398c0a6
6
+ metadata.gz: 2ccc69f6f1dd8e66f96787f93ded9d5e867a73c0c38358908b7616fd9f25ddf5e3a3009089c0144ef50523e25fb6de4c50305e874d2fba315d42049d28e326eb
7
+ data.tar.gz: e2127ad0bf2f0dec437c30a677b0bae3f3283946bb83d5eda4597daebfb97aa5304fb0e6e333f895f274677d86d3f369163dc8ef5a4625dbe169c02d435cf475
@@ -0,0 +1,62 @@
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
+ - run: bundle exec rake
50
+
51
+ tests-passed:
52
+ needs: rake
53
+ runs-on: ubuntu-latest
54
+ steps:
55
+ - name: Trigger tests passed event
56
+ uses: Sibz/github-status-action@v1
57
+ with:
58
+ authToken: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
59
+ context: 'tests-passed-successfully'
60
+ description: 'Tests passed successfully'
61
+ state: 'success'
62
+ sha: ${{ github.event.pull_request.head.sha || github.sha }}
@@ -1,19 +1,15 @@
1
- = AsciiCSAND: Asciidoctor processor for CSA Normal Documents (CSAND)
1
+ = Metanorma processor for CSA documents
2
2
 
3
3
  image:https://img.shields.io/gem/v/metanorma-csa.svg["Gem Version", link="https://rubygems.org/gems/metanorma-csa"]
4
- image:https://github.com/metanorma/metanorma-csa/workflows/ubuntu/badge.svg["Build Status", link="https://github.com/metanorma/metanorma-csa/actions?query=workflow%3Aubuntu"]
5
- image:https://github.com/metanorma/metanorma-csa/workflows/macos/badge.svg["Build Status", link="https://github.com/metanorma/metanorma-csa/actions?query=workflow%3Amacos"]
6
- image:https://github.com/metanorma/metanorma-csa/workflows/windows/badge.svg["Build Status", link="https://github.com/metanorma/metanorma-csa/actions?query=workflow%3Awindows"]
4
+ image:https://github.com/metanorma/metanorma-csa/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/metanorma-csa/actions?query=workflow=rake"]
7
5
  image:https://codeclimate.com/github/metanorma/metanorma-csand/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/metanorma-csand"]
8
6
  image:https://img.shields.io/github/issues-pr-raw/metanorma/metanorma-csa.svg["Pull Requests", link="https://github.com/metanorma/metanorma-csa/pulls"]
9
7
  image:https://img.shields.io/github/commits-since/metanorma/metanorma-csa/latest.svg["Commits since latest",link="https://github.com/metanorma/metanorma-csa/releases"]
10
8
 
11
- _Formerly known as_ `asciidoctor-csand`.
12
-
13
9
  == Functionality
14
10
 
15
- This gem processes http://asciidoctor.org/[Asciidoctor] documents following
16
- a template for generating CSAND documents.
11
+ This gem processes https://www.metanorma.com/[Metanorma documents] following
12
+ a template for generating CSA documents.
17
13
 
18
14
  The gem currently inherits from the https://github.com/metanorma/metanorma-standoc
19
15
  gem, and aligns closely to it. Refer to the ISO gem documentation
@@ -21,24 +17,15 @@ for guidance, including https://github.com/metanorma/metanorma-iso/wiki/Guidance
21
17
 
22
18
  The following outputs are generated.
23
19
 
24
- * (Optional) An HTML preview generated directly from the Asciidoctor document,
25
- using native Asciidoctor formatting.
26
- ** http://asciimath.org[AsciiMathML] is to be used for mathematical formatting.
27
- The gem uses the https://github.com/asciidoctor/asciimath[Ruby AsciiMath parser],
28
- which is syntactically stricter than the common MathJax processor;
29
- if you do not get expected results, try bracketing terms your in AsciiMathML
30
- expressions.
31
- * an XML representation of the document, intended as a document model for CSAND
32
- International Standards.
33
- * The XML representation is processed in turn to generate the following outputs
34
- as end deliverable CSAND standard drafts.
35
- ** HTML output.
36
-
37
- This AsciiDoc syntax for writing CSAND standards is hereby named "AsciiCSAND".
20
+ * Metanorma XML
21
+ * HTML output (from Metanorma XML)
22
+ * PDF output (from Metanorma XML)
23
+
24
+ // This AsciiDoc syntax for writing CSAND standards is hereby named "AsciiCSAND".
38
25
 
39
26
  == Usage
40
27
 
41
- The preferred way to invoke this gem is via the `metanorma` script:
28
+ The preferred way to invoke this gem is via the `metanorma` command:
42
29
 
43
30
  [source,console]
44
31
  ----
@@ -56,13 +43,6 @@ document.
56
43
  The gem then converts the XML to HTML, and
57
44
  outputs that files with the appropriate `.html` suffix.
58
45
 
59
- The gem can also be invoked directly within asciidoctor, though this is deprecated:
60
-
61
- [source,console]
62
- ----
63
- $ asciidoctor -b csa -r 'metanorma-csa' a.adoc
64
- ----
65
-
66
46
  === Installation
67
47
 
68
48
  If you are using a Mac, the https://github.com/metanorma/metanorma-macos-setup
@@ -83,3 +63,7 @@ See https://www.metanorma.com/author/csa/[Author Cloud Security Alliance documen
83
63
  == Examples
84
64
 
85
65
  See https://github.com/metanorma/mn-samples-csa for sample documents.
66
+
67
+ == Notes
68
+
69
+ Metanorma-CSA was formerly published as `asciidoctor-csand`.
@@ -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">
@@ -1,29 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'asciidoctor'
4
- require 'metanorma/csa/version'
4
+ require 'metanorma-generic'
5
5
  require 'isodoc/csa/html_convert'
6
6
  require 'isodoc/csa/pdf_convert'
7
7
  require 'isodoc/csa/word_convert'
8
8
  require 'isodoc/csa/presentation_xml_convert'
9
- require 'asciidoctor/standoc/converter'
9
+ require 'metanorma/csa'
10
10
  require 'fileutils'
11
- require_relative 'validate'
12
11
 
13
12
  module Asciidoctor
14
13
  module Csa
15
- CSA_TYPE = 'csa'
16
-
17
- # A {Converter} implementation that generates CSD output, and a document
18
- # schema encapsulation of the document for validation
19
- class Converter < Standoc::Converter
14
+ class Converter < ::Asciidoctor::Generic::Converter
20
15
  XML_ROOT_TAG = "csa-standard".freeze
21
16
  XML_NAMESPACE = "https://www.metanorma.org/ns/csa".freeze
22
17
 
23
- register_for CSA_TYPE
18
+ register_for "csa"
24
19
 
25
- def default_publisher
26
- "Cloud Security Alliance"
20
+ def configuration
21
+ Metanorma::Csa.configuration
27
22
  end
28
23
 
29
24
  def personal_role(node, c, suffix)
@@ -47,34 +42,10 @@ module Asciidoctor
47
42
  end
48
43
  end
49
44
 
50
- def metadata_id(node, xml)
51
- dn = node.attr('docnumber') or return
52
- docstatus = node.attr('status')
53
- if docstatus
54
- abbr = IsoDoc::Csa::Metadata.new('en', 'Latn', @i18n)
55
- .stage_abbr(docstatus)
56
- dn = "#{dn}(#{abbr})" unless abbr.empty?
57
- end
58
- node.attr('copyright-year') && dn += ":#{node.attr('copyright-year')}"
59
- xml.docidentifier dn, **{ type: CSA_TYPE }
60
- xml.docnumber { |i| i << node.attr('docnumber') }
61
- end
62
-
63
45
  def title_validate(root)
64
46
  nil
65
47
  end
66
48
 
67
- def doctype(node)
68
- d = super
69
- unless %w{guidance proposal standard report whitepaper charter policy
70
- glossary case-study}.include? d
71
- @log.add("Document Attributes", nil,
72
- "#{d} is not a legal document type: reverting to 'standard'")
73
- d = 'standard'
74
- end
75
- d
76
- end
77
-
78
49
  def outputs(node, ret)
79
50
  File.open(@filename + ".xml", "w:UTF-8") { |f| f.write(ret) }
80
51
  presentation_xml_converter(node).convert(@filename + ".xml")
@@ -86,12 +57,6 @@ module Asciidoctor
86
57
  nil, false, "#{@filename}.pdf")
87
58
  end
88
59
 
89
- def validate(doc)
90
- content_validate(doc)
91
- schema_validate(formattedstr_strip(doc.dup),
92
- File.join(File.dirname(__FILE__), 'csa.rng'))
93
- end
94
-
95
60
  def sections_cleanup(x)
96
61
  super
97
62
  x.xpath("//*[@inline-header]").each do |h|
@@ -99,6 +64,21 @@ module Asciidoctor
99
64
  end
100
65
  end
101
66
 
67
+ def bibdata_validate(doc)
68
+ super
69
+ role_validate(doc)
70
+ end
71
+
72
+ def role_validate(doc)
73
+ doc&.xpath("//bibdata/contributor/role[description]")&.each do |r|
74
+ r["type"] == "author" or next
75
+ role = r.at("./description").text
76
+ %w{full-author contributor staff reviewer}.include?(role) or
77
+ @log.add("Document Attributes", nil,
78
+ "#{role} is not a recognised role")
79
+ end
80
+ end
81
+
102
82
  def style(n, t)
103
83
  return
104
84
  end
@@ -106,12 +86,16 @@ module Asciidoctor
106
86
  def html_converter(node)
107
87
  IsoDoc::Csa::HtmlConvert.new(html_extract_attributes(node))
108
88
  end
89
+
109
90
  def pdf_converter(node)
91
+ return if node.attr("no-pdf")
110
92
  IsoDoc::Csa::PdfConvert.new(html_extract_attributes(node))
111
93
  end
94
+
112
95
  def doc_converter(node)
113
96
  IsoDoc::Csa::WordConvert.new(doc_extract_attributes(node))
114
97
  end
98
+
115
99
  def presentation_xml_converter(node)
116
100
  IsoDoc::Csa::PresentationXMLConvert.new(doc_extract_attributes(node))
117
101
  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">
@@ -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">