metanorma-itu 1.1.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +0 -1
- data/.github/workflows/ubuntu.yml +10 -7
- data/.github/workflows/windows.yml +0 -1
- data/Rakefile +2 -0
- data/lib/asciidoctor/itu/cleanup.rb +69 -39
- data/lib/asciidoctor/itu/converter.rb +35 -45
- data/lib/asciidoctor/itu/front.rb +2 -31
- data/lib/asciidoctor/itu/isodoc.rng +12 -6
- data/lib/asciidoctor/itu/validate.rb +22 -11
- data/lib/isodoc/itu/base_convert.rb +32 -83
- data/lib/isodoc/itu/html/_coverpage.css +349 -0
- data/lib/isodoc/itu/html/_coverpage.scss +2 -0
- data/lib/isodoc/itu/html/htmlstyle.css +1159 -0
- data/lib/isodoc/itu/html/itu.css +1138 -0
- data/lib/isodoc/itu/html/itu.scss +0 -1
- data/lib/isodoc/itu/html/wordstyle.css +1808 -0
- data/lib/isodoc/itu/html/wordstyle.scss +0 -1
- data/lib/isodoc/itu/html_convert.rb +8 -4
- data/lib/isodoc/itu/i18n-en.yaml +25 -0
- data/lib/isodoc/itu/i18n.rb +14 -0
- data/lib/isodoc/itu/init.rb +29 -0
- data/lib/isodoc/itu/itu.recommendation-annex.xsl +1485 -1872
- data/lib/isodoc/itu/itu.recommendation.xsl +1485 -1872
- data/lib/isodoc/itu/itu.resolution.xsl +1485 -1872
- data/lib/isodoc/itu/metadata.rb +8 -5
- data/lib/isodoc/itu/pdf_convert.rb +0 -1
- data/lib/isodoc/itu/presentation_xml_convert.rb +46 -1
- data/lib/isodoc/itu/ref.rb +12 -9
- data/lib/isodoc/itu/terms.rb +10 -19
- data/lib/isodoc/itu/word_convert.rb +25 -14
- data/lib/isodoc/itu/xref.rb +43 -30
- data/lib/metanorma/itu/processor.rb +8 -8
- data/lib/metanorma/itu/version.rb +1 -1
- data/metanorma-itu.gemspec +3 -2
- metadata +26 -7
- data/lib/asciidoctor/itu/i18n-en.yaml +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6028239b8ffb9cf94de7759755fe208f1fdd936cf725f8888c17f197327a01f
|
4
|
+
data.tar.gz: e32f5d0ee934edb77e41a0014d6cce1be685ed99505331808b3c4a96268e3f37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f49a564d79e27806d8d8669d8b58ac0400a560ea7cab85d5dfb00240e7d644ef70a1c31a8f873f44c10b88edf95f246a736c66ccac9c175b578ed709e08d43c
|
7
|
+
data.tar.gz: c738f41c4de7edd4e5b1ca26f5f298731002c1299d644138638c76addbb8433d2bdb9882e80d0ffd04c5f85159392c6f361c6ec214b2d8a2b99d08bbf9216334
|
data/.github/workflows/macos.yml
CHANGED
@@ -31,7 +31,6 @@ jobs:
|
|
31
31
|
uses: actions/setup-ruby@v1
|
32
32
|
with:
|
33
33
|
ruby-version: ${{ matrix.ruby }}
|
34
|
-
architecture: 'x64'
|
35
34
|
- name: Update gems
|
36
35
|
run: |
|
37
36
|
gem install bundler
|
@@ -39,15 +38,19 @@ jobs:
|
|
39
38
|
- name: Run specs
|
40
39
|
run: |
|
41
40
|
bundle exec rake
|
42
|
-
- name: Trigger
|
43
|
-
if:
|
41
|
+
- name: Trigger repositories
|
42
|
+
if: matrix.ruby == '2.6'
|
44
43
|
env:
|
45
|
-
GH_USERNAME:
|
46
|
-
GH_ACCESS_TOKEN: ${{ secrets.
|
44
|
+
GH_USERNAME: metanorma-ci
|
45
|
+
GH_ACCESS_TOKEN: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
|
47
46
|
run: |
|
48
47
|
curl -LO --retry 3 https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/trigger-gh-actions.sh
|
49
48
|
[[ -f ".github/workflows/dependent_repos.env" ]] && source .github/workflows/dependent_repos.env
|
50
|
-
|
49
|
+
CLIENT_PAYLOAD=$(cat <<EOF
|
50
|
+
"{ "ref": "${GITHUB_REF}", "repo": "${GITHUB_REPOSITORY}" }"
|
51
|
+
EOF
|
52
|
+
)
|
53
|
+
for repo in $REPOS
|
51
54
|
do
|
52
|
-
sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY "
|
55
|
+
sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY "$CLIENT_PAYLOAD"
|
53
56
|
done
|
data/Rakefile
CHANGED
@@ -4,6 +4,7 @@ module Asciidoctor
|
|
4
4
|
def sections_cleanup(x)
|
5
5
|
super
|
6
6
|
insert_missing_sections(x) unless @no_insert_missing_sections
|
7
|
+
insert_empty_clauses(x)
|
7
8
|
end
|
8
9
|
|
9
10
|
def table_cleanup(xmldoc)
|
@@ -22,16 +23,20 @@ module Asciidoctor
|
|
22
23
|
insert_conventions(x)
|
23
24
|
end
|
24
25
|
|
26
|
+
def add_id
|
27
|
+
%(id="_#{UUIDTools::UUID.random_create}")
|
28
|
+
end
|
29
|
+
|
25
30
|
def insert_scope(x)
|
26
31
|
x.at("./*/sections") or
|
27
32
|
x.at("./*/preface | ./*/boilerplate | ./*/bibdata").next =
|
28
33
|
"<sections><sentinel/></sections>"
|
29
34
|
x.at("./*/sections/*") or x.at("./*/sections") << "<sentinel/>"
|
30
35
|
ins = x.at("//sections").elements.first
|
31
|
-
|
32
|
-
ins.previous =
|
33
|
-
"#{@
|
34
|
-
|
36
|
+
x.at("//sections/clause[@type = 'scope']") or
|
37
|
+
ins.previous =
|
38
|
+
"<clause type='scope' #{add_id}><title>#{@i18n.scope}</title><p>"\
|
39
|
+
"#{@i18n.clause_empty}</p></clause>"
|
35
40
|
x&.at("//sentinel")&.remove
|
36
41
|
end
|
37
42
|
|
@@ -40,42 +45,52 @@ module Asciidoctor
|
|
40
45
|
x.at("./*/annex[last()] | ./*/sections").next =
|
41
46
|
"<bibliography><sentinel/></bibliography>"
|
42
47
|
ins = x.at("//bibliography").elements.first
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
ins.previous = "<references normative='true'><title>References</title>"\
|
47
|
-
"</references>"
|
48
|
-
end
|
48
|
+
x.at("//bibliography/references[@normative = 'true']") or
|
49
|
+
ins.previous = "<references #{add_id} normative='true'>"\
|
50
|
+
"<title>#{@i18n.normref}</title></references>"
|
49
51
|
x&.at("//sentinel")&.remove
|
50
52
|
end
|
51
53
|
|
52
54
|
def insert_terms(x)
|
53
|
-
ins = x.at("//sections/clause
|
54
|
-
|
55
|
-
ins.next = "<terms><title
|
56
|
-
"#{@labels['clause_empty']}</p></terms>"
|
57
|
-
end
|
55
|
+
ins = x.at("//sections/clause[@type = 'scope']")
|
56
|
+
x.at("//sections//terms") or
|
57
|
+
ins.next = "<terms #{add_id}><title>#{@i18n.termsdef}</title></terms>"
|
58
58
|
end
|
59
59
|
|
60
60
|
def insert_symbols(x)
|
61
61
|
ins = x.at("//sections/terms") ||
|
62
62
|
x.at("//sections/clause[descendant::terms]")
|
63
63
|
unless x.at("//sections//definitions")
|
64
|
-
ins.next = "<definitions
|
65
|
-
"
|
64
|
+
ins.next = "<definitions #{add_id}>"\
|
65
|
+
"<title>#{@i18n.symbolsabbrev}</title></definitions>"
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
def insert_conventions(x)
|
70
70
|
ins = x.at("//sections//definitions") ||
|
71
71
|
x.at("//sections/clause[descendant::definitions]")
|
72
|
-
unless x.at("//sections/clause
|
73
|
-
ins.next = "<clause
|
74
|
-
"<title
|
75
|
-
"#{@
|
72
|
+
unless x.at("//sections/clause[@type = 'conventions']")
|
73
|
+
ins.next = "<clause #{add_id} type='conventions'>"\
|
74
|
+
"<title>#{@i18n.conventions}</title><p>"\
|
75
|
+
"#{@i18n.clause_empty}</p></clause>"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def insert_empty_clauses(x)
|
80
|
+
x.xpath("//terms[not(./term)][not(.//terms)]").each do |c|
|
81
|
+
insert_empty_clauses1(c, @i18n.clause_empty)
|
82
|
+
end
|
83
|
+
x.xpath("//definitions[not(./dl)]").each do |c|
|
84
|
+
insert_empty_clauses1(c, @i18n.clause_empty)
|
76
85
|
end
|
77
86
|
end
|
78
87
|
|
88
|
+
def insert_empty_clauses1(c, text)
|
89
|
+
c.at("./p") and return
|
90
|
+
ins = c.at("./title") or return
|
91
|
+
ins.next = "<p>#{text}</p>"
|
92
|
+
end
|
93
|
+
|
79
94
|
def cleanup(xmldoc)
|
80
95
|
symbols_cleanup(xmldoc)
|
81
96
|
super
|
@@ -94,24 +109,46 @@ module Asciidoctor
|
|
94
109
|
xmldoc
|
95
110
|
end
|
96
111
|
|
97
|
-
def
|
98
|
-
xmldoc.xpath("//term/preferred").each do |p|
|
99
|
-
if ["terms defined elsewhere",
|
100
|
-
"terms defined in this recommendation"].include? p.text.downcase
|
101
|
-
p.name = "title"
|
102
|
-
p.parent.name = "terms"
|
103
|
-
end
|
104
|
-
end
|
105
|
-
super
|
112
|
+
def termdef_boilerplate_cleanup(xmldoc)
|
106
113
|
end
|
107
114
|
|
108
|
-
def
|
115
|
+
def terms_extract(div)
|
116
|
+
internal = div.at("./terms[@type = 'internal']/title")
|
117
|
+
external = div.at("./terms[@type = 'external']/title")
|
118
|
+
[internal, external]
|
119
|
+
end
|
120
|
+
|
121
|
+
def term_defs_boilerplate(div, source, term, preface, isodoc)
|
122
|
+
internal, external = terms_extract(div.parent)
|
123
|
+
internal&.next_element&.name == "term" and
|
124
|
+
internal.next = "<p>#{@i18n.internal_terms_boilerplate}</p>"
|
125
|
+
internal and internal&.next_element == nil and
|
126
|
+
internal.next = "<p>#{@i18n.no_terms_boilerplate}</p>"
|
127
|
+
external&.next_element&.name == "term" and
|
128
|
+
external.next = "<p>#{@i18n.external_terms_boilerplate}</p>"
|
129
|
+
external and external&.next_element == nil and
|
130
|
+
external.next = "<p>#{@i18n.no_terms_boilerplate}</p>"
|
131
|
+
!internal and !external and
|
132
|
+
%w(term terms).include? div&.next_element&.name and
|
133
|
+
div.next = "<p>#{@i18n.term_def_boilerplate}</p>"
|
134
|
+
end
|
135
|
+
|
136
|
+
def section_names_terms_cleanup(x)
|
137
|
+
super
|
138
|
+
replace_title(
|
139
|
+
x, "//terms[@type = 'internal'] | "\
|
140
|
+
"//clause[./terms[@type = 'internal']][not(./terms[@type = 'external'])]",
|
141
|
+
@i18n&.internal_termsdef)
|
142
|
+
replace_title(
|
143
|
+
x, "//terms[@type = 'external'] | "\
|
144
|
+
"//clause[./terms[@type = 'external']][not(./terms[@type = 'internal'])]",
|
145
|
+
@i18n&.external_termsdef)
|
109
146
|
end
|
110
147
|
|
111
148
|
def symbols_cleanup(xmldoc)
|
112
149
|
sym = xmldoc.at("//definitions/title")
|
113
150
|
sym and sym&.next_element&.name == "dl" and
|
114
|
-
sym.next = "<p>#{@symbols_boilerplate}</p>"
|
151
|
+
sym.next = "<p>#{@i18n.symbols_boilerplate}</p>"
|
115
152
|
end
|
116
153
|
|
117
154
|
PUBLISHER = "./contributor[role/@type = 'publisher']/organization".freeze
|
@@ -160,13 +197,6 @@ module Asciidoctor
|
|
160
197
|
biblio_reorder1(r)
|
161
198
|
end
|
162
199
|
end
|
163
|
-
|
164
|
-
def normref_cleanup(xmldoc)
|
165
|
-
super
|
166
|
-
r = xmldoc.at(NORM_REF) || return
|
167
|
-
title = r.at("./title") and
|
168
|
-
title.content = "References"
|
169
|
-
end
|
170
200
|
end
|
171
201
|
end
|
172
202
|
end
|
@@ -56,9 +56,12 @@ module Asciidoctor
|
|
56
56
|
def outputs(node, ret)
|
57
57
|
File.open(@filename + ".xml", "w:UTF-8") { |f| f.write(ret) }
|
58
58
|
presentation_xml_converter(node).convert(@filename + ".xml")
|
59
|
-
html_converter(node).convert(@filename + ".presentation.xml",
|
60
|
-
|
61
|
-
|
59
|
+
html_converter(node).convert(@filename + ".presentation.xml",
|
60
|
+
nil, false, "#{@filename}.html")
|
61
|
+
doc_converter(node).convert(@filename + ".presentation.xml",
|
62
|
+
nil, false, "#{@filename}.doc")
|
63
|
+
pdf_converter(node)&.convert(@filename + ".presentation.xml",
|
64
|
+
nil, false, "#{@filename}.pdf")
|
62
65
|
end
|
63
66
|
|
64
67
|
def validate(doc)
|
@@ -76,56 +79,32 @@ module Asciidoctor
|
|
76
79
|
when "definitions" then "terms and definitions"
|
77
80
|
when "abbreviations and acronyms" then "symbols and abbreviated terms"
|
78
81
|
when "references" then "normative references"
|
82
|
+
when "terms defined elsewhere" then "terms and definitions"
|
83
|
+
when "terms defined in this recommendation" then "terms and definitions"
|
79
84
|
else
|
80
85
|
super
|
81
86
|
end
|
82
87
|
end
|
83
88
|
|
84
|
-
def
|
85
|
-
|
86
|
-
"
|
89
|
+
def sectiontype(node, level = true)
|
90
|
+
ret = super
|
91
|
+
hdr = sectiontype_streamline(node&.attr("heading")&.downcase)
|
92
|
+
return nil if ret == "terms and definitions" &&
|
93
|
+
hdr != "terms and definitions" && node.level > 1
|
94
|
+
return nil if ret == "symbols and abbreviated terms" &&
|
95
|
+
hdr != "symbols and abbreviated terms" && node.level > 1
|
96
|
+
ret
|
87
97
|
end
|
88
98
|
|
89
|
-
def
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
99
|
+
def term_def_subclause_parse(attrs, xml, node)
|
100
|
+
case clausetype = sectiontype1(node)
|
101
|
+
when "terms defined in this recommendation"
|
102
|
+
term_def_parse(attrs.merge(type: "internal"), xml, node, false)
|
103
|
+
when "terms defined elsewhere"
|
104
|
+
term_def_parse(attrs.merge(type: "external"), xml, node, false)
|
105
|
+
else
|
106
|
+
super
|
97
107
|
end
|
98
|
-
[internal, external]
|
99
|
-
end
|
100
|
-
|
101
|
-
def term_defs_boilerplate(div, source, term, preface, isodoc)
|
102
|
-
internal, external = terms_extract(div)
|
103
|
-
internal&.next_element&.name == "term" and
|
104
|
-
internal.next = "<p>#{@internal_terms_boilerplate}</p>"
|
105
|
-
internal and internal&.next_element == nil and
|
106
|
-
internal.next = "<p>#{@no_terms_boilerplate}</p>"
|
107
|
-
external&.next_element&.name == "term" and
|
108
|
-
external.next = "<p>#{@external_terms_boilerplate}</p>"
|
109
|
-
external and external&.next_element == nil and
|
110
|
-
external.next = "<p>#{@no_terms_boilerplate}</p>"
|
111
|
-
!internal and !external and
|
112
|
-
%w(term terms).include? div&.next_element&.name and
|
113
|
-
div.next = "<p>#{@term_def_boilerplate}</p>"
|
114
|
-
end
|
115
|
-
|
116
|
-
def load_yaml(lang, script)
|
117
|
-
y = if @i18nyaml then YAML.load_file(@i18nyaml)
|
118
|
-
elsif lang == "en"
|
119
|
-
YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
|
120
|
-
else
|
121
|
-
YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
|
122
|
-
end
|
123
|
-
@symbols_boilerplate = y["symbols_boilerplate"] || ""
|
124
|
-
super.merge(y)
|
125
|
-
end
|
126
|
-
|
127
|
-
def i18n_init(lang, script)
|
128
|
-
super
|
129
108
|
end
|
130
109
|
|
131
110
|
def metadata_keywords(node, xml)
|
@@ -135,6 +114,17 @@ module Asciidoctor
|
|
135
114
|
end
|
136
115
|
end
|
137
116
|
|
117
|
+
def clause_parse(attrs, xml, node)
|
118
|
+
case clausetype = sectiontype1(node)
|
119
|
+
when "conventions" then attrs = attrs.merge(type: "conventions")
|
120
|
+
when "history"
|
121
|
+
attrs[:preface] and attrs = attrs.merge(type: "history")
|
122
|
+
when "source"
|
123
|
+
attrs[:preface] and attrs = attrs.merge(type: "source")
|
124
|
+
end
|
125
|
+
super
|
126
|
+
end
|
127
|
+
|
138
128
|
def html_extract_attributes(node)
|
139
129
|
super.merge(hierarchical_assets: node.attr("hierarchical-object-numbering"))
|
140
130
|
end
|
@@ -64,24 +64,8 @@ module Asciidoctor
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
def
|
68
|
-
|
69
|
-
c.role **{ type: "author" }
|
70
|
-
c.organization do |a|
|
71
|
-
a.name "International Telecommunication Union"
|
72
|
-
a.abbreviation "ITU"
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def metadata_publisher(node, xml)
|
78
|
-
xml.contributor do |c|
|
79
|
-
c.role **{ type: "publisher" }
|
80
|
-
c.organization do |a|
|
81
|
-
a.name "International Telecommunication Union"
|
82
|
-
a.abbreviation "ITU"
|
83
|
-
end
|
84
|
-
end
|
67
|
+
def default_publisher
|
68
|
+
"International Telecommunication Union"
|
85
69
|
end
|
86
70
|
|
87
71
|
def metadata_committee(node, xml)
|
@@ -149,19 +133,6 @@ module Asciidoctor
|
|
149
133
|
xml.docnumber { |i| i << node.attr("docnumber") }
|
150
134
|
end
|
151
135
|
|
152
|
-
def metadata_copyright(node, xml)
|
153
|
-
from = node.attr("copyright-year") || Date.today.year
|
154
|
-
xml.copyright do |c|
|
155
|
-
c.from from
|
156
|
-
c.owner do |owner|
|
157
|
-
owner.organization do |o|
|
158
|
-
o.name "International Telecommunication Union"
|
159
|
-
o.abbreviation "ITU"
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
136
|
def metadata_series(node, xml)
|
166
137
|
node.attr("series") and
|
167
138
|
xml.series **{ type: "main" } do |s|
|
@@ -922,6 +922,9 @@
|
|
922
922
|
<optional>
|
923
923
|
<attribute name="script"/>
|
924
924
|
</optional>
|
925
|
+
<optional>
|
926
|
+
<attribute name="type"/>
|
927
|
+
</optional>
|
925
928
|
<optional>
|
926
929
|
<attribute name="obligation">
|
927
930
|
<choice>
|
@@ -961,9 +964,6 @@
|
|
961
964
|
</define>
|
962
965
|
<define name="content-subsection">
|
963
966
|
<element name="clause">
|
964
|
-
<optional>
|
965
|
-
<attribute name="type"/>
|
966
|
-
</optional>
|
967
967
|
<ref name="Content-Section"/>
|
968
968
|
</element>
|
969
969
|
</define>
|
@@ -992,6 +992,9 @@
|
|
992
992
|
</choice>
|
993
993
|
</attribute>
|
994
994
|
</optional>
|
995
|
+
<optional>
|
996
|
+
<attribute name="type"/>
|
997
|
+
</optional>
|
995
998
|
<optional>
|
996
999
|
<ref name="section-title"/>
|
997
1000
|
</optional>
|
@@ -1011,9 +1014,6 @@
|
|
1011
1014
|
</define>
|
1012
1015
|
<define name="clause">
|
1013
1016
|
<element name="clause">
|
1014
|
-
<optional>
|
1015
|
-
<attribute name="type"/>
|
1016
|
-
</optional>
|
1017
1017
|
<ref name="Clause-Section"/>
|
1018
1018
|
</element>
|
1019
1019
|
</define>
|
@@ -1042,6 +1042,9 @@
|
|
1042
1042
|
</choice>
|
1043
1043
|
</attribute>
|
1044
1044
|
</optional>
|
1045
|
+
<optional>
|
1046
|
+
<attribute name="type"/>
|
1047
|
+
</optional>
|
1045
1048
|
<optional>
|
1046
1049
|
<ref name="section-title"/>
|
1047
1050
|
</optional>
|
@@ -1180,6 +1183,9 @@
|
|
1180
1183
|
<optional>
|
1181
1184
|
<attribute name="script"/>
|
1182
1185
|
</optional>
|
1186
|
+
<optional>
|
1187
|
+
<attribute name="type"/>
|
1188
|
+
</optional>
|
1183
1189
|
<optional>
|
1184
1190
|
<attribute name="obligation">
|
1185
1191
|
<choice>
|