metanorma-csa 1.6.6 → 1.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +29 -8
- data/README.adoc +14 -30
- data/lib/asciidoctor/csa/basicdoc.rng +50 -3
- data/lib/asciidoctor/csa/converter.rb +21 -41
- data/lib/asciidoctor/csa/isodoc.rng +61 -3
- data/lib/isodoc/csa/base_convert.rb +2 -12
- data/lib/isodoc/csa/csa.standard.xsl +293 -70
- data/lib/isodoc/csa/html/csa.css +19 -20
- data/lib/isodoc/csa/html/csa.scss +19 -20
- data/lib/isodoc/csa/html/htmlstyle.css +7 -7
- data/lib/isodoc/csa/html/htmlstyle.scss +6 -6
- data/lib/isodoc/csa/html/wordstyle.css +19 -19
- data/lib/isodoc/csa/html/wordstyle.scss +19 -19
- data/lib/isodoc/csa/html_convert.rb +2 -43
- data/lib/isodoc/csa/i18n.rb +3 -4
- data/lib/isodoc/csa/metadata.rb +3 -18
- data/lib/isodoc/csa/presentation_xml_convert.rb +2 -1
- data/lib/isodoc/csa/word_convert.rb +1 -25
- data/lib/isodoc/csa/xref.rb +1 -1
- data/lib/metanorma/csa.rb +26 -1
- data/lib/metanorma/csa/processor.rb +9 -10
- data/lib/metanorma/csa/version.rb +1 -1
- data/metanorma-csa.gemspec +1 -10
- data/metanorma.yml +60 -0
- metadata +6 -104
- data/lib/asciidoctor/csa/validate.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 662b71103ad56cc32d0fcbd4926a6b483b82cebc0658f7b7d792d81a36343686
|
4
|
+
data.tar.gz: 38b71724171ea25595f588335abfd45a9b88e8fc5ff30a962d6341089adb667f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e223eec78966bdf647936260b2da185837a859ae95198bc1eaa459697d1f3d9743fea0a35ada5d6f9e050dce93550aae053d8a05ac9a1e663d63ff3703766b4b
|
7
|
+
data.tar.gz: c3711271668f6f89107bffa7804fac1b97222ae9a8a553b2e592f4e409b70f899f105acf132cf80eae78697ad0707d541045c8d7be414a68f149324cc9a488a8
|
data/.github/workflows/rake.yml
CHANGED
@@ -4,7 +4,8 @@ name: rake
|
|
4
4
|
|
5
5
|
on:
|
6
6
|
push:
|
7
|
-
branches: [ master ]
|
7
|
+
branches: [ master, main ]
|
8
|
+
tags: [ v* ]
|
8
9
|
pull_request:
|
9
10
|
|
10
11
|
jobs:
|
@@ -31,14 +32,34 @@ jobs:
|
|
31
32
|
steps:
|
32
33
|
- uses: actions/checkout@master
|
33
34
|
|
34
|
-
-
|
35
|
-
uses: ruby/setup-ruby@v1
|
35
|
+
- uses: ruby/setup-ruby@v1
|
36
36
|
with:
|
37
37
|
ruby-version: ${{ matrix.ruby }}
|
38
|
-
bundler-cache: true
|
39
38
|
|
40
|
-
-
|
41
|
-
run:
|
39
|
+
- if: matrix.os == 'macos-latest'
|
40
|
+
run: brew install autoconf automake libtool
|
42
41
|
|
43
|
-
-
|
44
|
-
|
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
|
+
- run: bundle exec rake
|
53
|
+
|
54
|
+
tests-passed:
|
55
|
+
needs: rake
|
56
|
+
runs-on: ubuntu-latest
|
57
|
+
steps:
|
58
|
+
- name: Trigger tests passed event
|
59
|
+
uses: Sibz/github-status-action@v1
|
60
|
+
with:
|
61
|
+
authToken: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
|
62
|
+
context: 'tests-passed-successfully'
|
63
|
+
description: 'Tests passed successfully'
|
64
|
+
state: 'success'
|
65
|
+
sha: ${{ github.event.pull_request.head.sha || github.sha }}
|
data/README.adoc
CHANGED
@@ -1,19 +1,15 @@
|
|
1
|
-
=
|
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/
|
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
|
16
|
-
a template for generating
|
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
|
-
*
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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`
|
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="
|
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
|
-
<
|
741
|
+
<element name="secondary">
|
742
|
+
<oneOrMore>
|
743
|
+
<ref name="PureTextElement"/>
|
744
|
+
</oneOrMore>
|
745
|
+
</element>
|
734
746
|
</optional>
|
735
747
|
<optional>
|
736
|
-
<
|
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
|
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 '
|
9
|
+
require 'metanorma/csa'
|
10
10
|
require 'fileutils'
|
11
|
-
require_relative 'validate'
|
12
11
|
|
13
12
|
module Asciidoctor
|
14
13
|
module Csa
|
15
|
-
|
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
|
18
|
+
register_for "csa"
|
24
19
|
|
25
|
-
def
|
26
|
-
|
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
|
@@ -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,12 @@
|
|
233
253
|
<data type="boolean"/>
|
234
254
|
</attribute>
|
235
255
|
</optional>
|
256
|
+
<optional>
|
257
|
+
<attribute name="width"/>
|
258
|
+
</optional>
|
259
|
+
<optional>
|
260
|
+
<ref name="colgroup"/>
|
261
|
+
</optional>
|
236
262
|
<optional>
|
237
263
|
<ref name="tname"/>
|
238
264
|
</optional>
|
@@ -751,6 +777,18 @@
|
|
751
777
|
</define>
|
752
778
|
</include>
|
753
779
|
<!-- end overrides -->
|
780
|
+
<define name="colgroup">
|
781
|
+
<element name="colgroup">
|
782
|
+
<oneOrMore>
|
783
|
+
<ref name="col"/>
|
784
|
+
</oneOrMore>
|
785
|
+
</element>
|
786
|
+
</define>
|
787
|
+
<define name="col">
|
788
|
+
<element name="col">
|
789
|
+
<attribute name="width"/>
|
790
|
+
</element>
|
791
|
+
</define>
|
754
792
|
<define name="TextElement" combine="choice">
|
755
793
|
<ref name="concept"/>
|
756
794
|
</define>
|
@@ -801,6 +839,9 @@
|
|
801
839
|
<data type="boolean"/>
|
802
840
|
</attribute>
|
803
841
|
</optional>
|
842
|
+
<optional>
|
843
|
+
<attribute name="number"/>
|
844
|
+
</optional>
|
804
845
|
<optional>
|
805
846
|
<attribute name="obligation">
|
806
847
|
<choice>
|
@@ -856,9 +897,11 @@
|
|
856
897
|
<element name="code">
|
857
898
|
<text/>
|
858
899
|
</element>
|
859
|
-
<
|
860
|
-
<text
|
861
|
-
|
900
|
+
<optional>
|
901
|
+
<element name="text">
|
902
|
+
<text/>
|
903
|
+
</element>
|
904
|
+
</optional>
|
862
905
|
</element>
|
863
906
|
</define>
|
864
907
|
<define name="standard-document">
|
@@ -1028,6 +1071,9 @@
|
|
1028
1071
|
</choice>
|
1029
1072
|
</attribute>
|
1030
1073
|
</optional>
|
1074
|
+
<optional>
|
1075
|
+
<attribute name="number"/>
|
1076
|
+
</optional>
|
1031
1077
|
<optional>
|
1032
1078
|
<attribute name="type"/>
|
1033
1079
|
</optional>
|
@@ -1081,6 +1127,9 @@
|
|
1081
1127
|
<optional>
|
1082
1128
|
<attribute name="type"/>
|
1083
1129
|
</optional>
|
1130
|
+
<optional>
|
1131
|
+
<attribute name="number"/>
|
1132
|
+
</optional>
|
1084
1133
|
<optional>
|
1085
1134
|
<ref name="section-title"/>
|
1086
1135
|
</optional>
|
@@ -1183,6 +1232,9 @@
|
|
1183
1232
|
<optional>
|
1184
1233
|
<attribute name="type"/>
|
1185
1234
|
</optional>
|
1235
|
+
<optional>
|
1236
|
+
<attribute name="number"/>
|
1237
|
+
</optional>
|
1186
1238
|
<optional>
|
1187
1239
|
<attribute name="obligation">
|
1188
1240
|
<choice>
|
@@ -1511,6 +1563,7 @@
|
|
1511
1563
|
<value>add</value>
|
1512
1564
|
<value>modify</value>
|
1513
1565
|
<value>delete</value>
|
1566
|
+
<value>replace</value>
|
1514
1567
|
</choice>
|
1515
1568
|
</attribute>
|
1516
1569
|
<optional>
|
@@ -1541,6 +1594,11 @@
|
|
1541
1594
|
</optional>
|
1542
1595
|
<optional>
|
1543
1596
|
<element name="newcontent">
|
1597
|
+
<optional>
|
1598
|
+
<attribute name="id">
|
1599
|
+
<data type="ID"/>
|
1600
|
+
</attribute>
|
1601
|
+
</optional>
|
1544
1602
|
<zeroOrMore>
|
1545
1603
|
<ref name="BasicBlock"/>
|
1546
1604
|
</zeroOrMore>
|