metanorma-itu 1.0.11 → 1.0.16
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 +10 -10
- data/.github/workflows/ubuntu.yml +25 -11
- data/.github/workflows/windows.yml +11 -12
- data/README.adoc +9 -49
- data/lib/asciidoctor/itu/biblio.rng +131 -46
- data/lib/asciidoctor/itu/cleanup.rb +90 -78
- data/lib/asciidoctor/itu/converter.rb +8 -12
- data/lib/asciidoctor/itu/front.rb +47 -18
- data/lib/asciidoctor/itu/isodoc.rng +32 -4
- data/lib/asciidoctor/itu/validate.rb +1 -1
- data/lib/isodoc/itu/base_convert.rb +9 -6
- data/lib/isodoc/itu/html/_coverpage.scss +1 -1
- data/lib/isodoc/itu/html/header.html +8 -8
- data/lib/isodoc/itu/html/html_itu_titlepage.html +5 -3
- data/lib/isodoc/itu/html/htmlstyle.scss +9 -5
- data/lib/isodoc/itu/html/itu.scss +24 -1
- data/lib/isodoc/itu/html/scripts.html +14 -27
- data/lib/isodoc/itu/html/word_itu_intro.html +2 -0
- data/lib/isodoc/itu/html/word_itu_titlepage.html +3 -3
- data/lib/isodoc/itu/html/wordstyle.scss +1 -1
- data/lib/isodoc/itu/html_convert.rb +3 -3
- data/lib/isodoc/itu/itu.recommendation-annex.xsl +3589 -0
- data/lib/isodoc/itu/itu.recommendation.xsl +3589 -0
- data/lib/isodoc/itu/itu.resolution.xsl +3589 -0
- data/lib/isodoc/itu/metadata.rb +6 -26
- data/lib/isodoc/itu/pdf_convert.rb +17 -44
- data/lib/isodoc/itu/ref.rb +26 -21
- data/lib/isodoc/itu/terms.rb +3 -4
- data/lib/isodoc/itu/word_convert.rb +5 -2
- data/lib/isodoc/itu/xref.rb +16 -12
- data/lib/metanorma/itu/processor.rb +8 -0
- data/lib/metanorma/itu/version.rb +1 -1
- metadata +5 -3
- data/lib/isodoc/itu/html/scripts.pdf.html +0 -72
@@ -3,9 +3,6 @@ module Asciidoctor
|
|
3
3
|
class Converter < Standoc::Converter
|
4
4
|
def sections_cleanup(x)
|
5
5
|
super
|
6
|
-
x.xpath("//*[@inline-header]").each do |h|
|
7
|
-
h.delete("inline-header")
|
8
|
-
end
|
9
6
|
insert_missing_sections(x) unless @no_insert_missing_sections
|
10
7
|
end
|
11
8
|
|
@@ -30,7 +27,7 @@ module Asciidoctor
|
|
30
27
|
x.at("./*/preface | ./*/boilerplate | ./*/bibdata").next =
|
31
28
|
"<sections><sentinel/></sections>"
|
32
29
|
x.at("./*/sections/*") or x.at("./*/sections") << "<sentinel/>"
|
33
|
-
ins = x.at("//sections").
|
30
|
+
ins = x.at("//sections").elements.first
|
34
31
|
unless x.at("//sections/clause/title[text() = 'Scope']")
|
35
32
|
ins.previous = "<clause><title>Scope</title><p>"\
|
36
33
|
"#{@labels['clause_empty']}</p></clause>"
|
@@ -39,73 +36,81 @@ module Asciidoctor
|
|
39
36
|
end
|
40
37
|
|
41
38
|
def insert_norm_ref(x)
|
42
|
-
x.at("//bibliography") or
|
39
|
+
x.at("//bibliography") or
|
40
|
+
x.at("./*/annex[last()] | ./*/sections").next =
|
43
41
|
"<bibliography><sentinel/></bibliography>"
|
44
|
-
ins = x.at("//bibliography").
|
45
|
-
unless x.at("//bibliography/references
|
46
|
-
ins.previous = "<references><title>References</title><p>"\
|
47
|
-
|
42
|
+
ins = x.at("//bibliography").elements.first
|
43
|
+
unless x.at("//bibliography/references[@normative = 'true']")
|
44
|
+
#ins.previous = "<references normative='true'><title>References</title><p>"\
|
45
|
+
# "#{@labels['clause_empty']}</p></references>"
|
46
|
+
ins.previous = "<references normative='true'><title>References</title>"\
|
47
|
+
"</references>"
|
48
48
|
end
|
49
49
|
x&.at("//sentinel")&.remove
|
50
50
|
end
|
51
51
|
|
52
52
|
def insert_terms(x)
|
53
|
-
ins = x.at("//sections/clause/title[text() = 'Scope']")
|
54
|
-
unless x.at("//sections
|
53
|
+
ins = x.at("//sections/clause/title[text() = 'Scope']/..")
|
54
|
+
unless x.at("//sections//terms")
|
55
55
|
ins.next = "<terms><title>Definitions</title><p>"\
|
56
56
|
"#{@labels['clause_empty']}</p></terms>"
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
def insert_symbols(x)
|
61
|
-
ins = x.at("//terms")
|
61
|
+
ins = x.at("//sections/terms") ||
|
62
|
+
x.at("//sections/clause[descendant::terms]")
|
62
63
|
unless x.at("//sections//definitions")
|
63
|
-
ins.next = "<definitions><title>
|
64
|
+
ins.next = "<definitions><title>Abbreviations and acronyms</title><p>"\
|
64
65
|
"#{@labels['clause_empty']}</p></definitions>"
|
65
66
|
end
|
66
67
|
end
|
67
68
|
|
68
69
|
def insert_conventions(x)
|
69
|
-
ins = x.at("//sections//definitions")
|
70
|
+
ins = x.at("//sections//definitions") ||
|
71
|
+
x.at("//sections/clause[descendant::definitions]")
|
70
72
|
unless x.at("//sections/clause/title[text() = 'Conventions']")
|
71
|
-
ins.next = "<clause
|
72
|
-
|
73
|
-
|
74
|
-
|
73
|
+
ins.next = "<clause id='_#{UUIDTools::UUID.random_create}'>"\
|
74
|
+
"<title>Conventions</title><p>"\
|
75
|
+
"#{@labels['clause_empty']}</p></clause>"
|
76
|
+
end
|
77
|
+
end
|
75
78
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
79
|
+
def cleanup(xmldoc)
|
80
|
+
symbols_cleanup(xmldoc)
|
81
|
+
super
|
82
|
+
obligations_cleanup(xmldoc)
|
83
|
+
xmldoc
|
84
|
+
end
|
80
85
|
|
81
|
-
|
82
|
-
|
83
|
-
|
86
|
+
def smartquotes_cleanup(xmldoc)
|
87
|
+
return super if @smartquotes
|
88
|
+
xmldoc.traverse do |n|
|
84
89
|
next unless n.text?
|
85
90
|
n.replace(HTMLEntities.new.encode(
|
86
91
|
n.text.gsub(/\u2019|\u2018|\u201a|\u201b/, "'").
|
87
92
|
gsub(/\u201c|\u201d|\u201e|\u201f/, '"'), :basic))
|
88
|
-
|
89
|
-
|
90
|
-
|
93
|
+
end
|
94
|
+
xmldoc
|
95
|
+
end
|
91
96
|
|
92
|
-
|
93
|
-
|
97
|
+
def termdef_cleanup(xmldoc)
|
98
|
+
xmldoc.xpath("//term/preferred").each do |p|
|
94
99
|
if ["terms defined elsewhere",
|
95
|
-
|
96
|
-
|
97
|
-
|
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
|
98
106
|
end
|
99
|
-
end
|
100
|
-
super
|
101
|
-
end
|
102
107
|
|
103
|
-
|
104
|
-
|
108
|
+
def termdef_boilerplate_cleanup(xmldoc)
|
109
|
+
end
|
105
110
|
|
106
|
-
|
107
|
-
|
108
|
-
|
111
|
+
def symbols_cleanup(xmldoc)
|
112
|
+
sym = xmldoc.at("//definitions/title")
|
113
|
+
sym and sym&.next_element&.name == "dl" and
|
109
114
|
sym.next = "<p>#{@symbols_boilerplate}</p>"
|
110
115
|
end
|
111
116
|
|
@@ -113,48 +118,55 @@ module Asciidoctor
|
|
113
118
|
|
114
119
|
def pub_class(bib)
|
115
120
|
return 1 if bib.at("#{PUBLISHER}[abbreviation = 'ITU']")
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
121
|
+
return 1 if bib.at("#{PUBLISHER}[name = 'International "\
|
122
|
+
"Telecommunication Union']")
|
123
|
+
return 2 if bib.at("#{PUBLISHER}[abbreviation = 'ISO']")
|
124
|
+
return 2 if bib.at("#{PUBLISHER}[name = 'International Organization "\
|
125
|
+
"for Standardization']")
|
126
|
+
return 3 if bib.at("#{PUBLISHER}[abbreviation = 'IEC']")
|
127
|
+
return 3 if bib.at("#{PUBLISHER}[name = 'International "\
|
128
|
+
"Electrotechnical Commission']")
|
129
|
+
return 4 if bib.at("./docidentifier[@type][not(@type = 'DOI' or "\
|
130
|
+
"@type = 'metanorma' or @type = 'ISSN' or @type = "\
|
131
|
+
"'ISBN')]")
|
132
|
+
5
|
133
|
+
end
|
129
134
|
|
130
|
-
|
131
|
-
|
132
|
-
|
135
|
+
def sort_biblio(bib)
|
136
|
+
bib.sort do |a, b|
|
137
|
+
sort_biblio_key(a) <=> sort_biblio_key(b)
|
138
|
+
end
|
133
139
|
end
|
134
|
-
end
|
135
140
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
141
|
+
# sort by: doc class (ITU, ISO, IEC, other standard (not DOI &c), other
|
142
|
+
# then standard class (docid class other than DOI &c)
|
143
|
+
# then alphanumeric doc id (not DOI &c)
|
144
|
+
# then title
|
145
|
+
def sort_biblio_key(bib)
|
146
|
+
pubclass = pub_class(bib)
|
147
|
+
num = bib&.at("./docnumber")&.text
|
148
|
+
id = bib&.at("./docidentifier[not(@type = 'DOI' or @type = "\
|
149
|
+
"'metanorma' or @type = 'ISSN' or @type = 'ISBN')]")
|
150
|
+
metaid = bib&.at("./docidentifier[@type = 'metanorma']")&.text
|
151
|
+
abbrid = metaid unless /^\[\d+\]$/.match(metaid)
|
152
|
+
type = id['type'] if id
|
153
|
+
title = bib&.at("./title[@type = 'main']")&.text ||
|
154
|
+
bib&.at("./title")&.text || bib&.at("./formattedref")&.text
|
155
|
+
"#{pubclass} :: #{type} :: #{id&.text || metaid} :: #{title}"
|
156
|
+
end
|
157
|
+
|
158
|
+
def biblio_reorder(xmldoc)
|
159
|
+
xmldoc.xpath("//references").each do |r|
|
160
|
+
biblio_reorder1(r)
|
161
|
+
end
|
162
|
+
end
|
152
163
|
|
153
|
-
|
154
|
-
|
155
|
-
|
164
|
+
def normref_cleanup(xmldoc)
|
165
|
+
super
|
166
|
+
r = xmldoc.at(NORM_REF) || return
|
167
|
+
title = r.at("./title") and
|
168
|
+
title.content = "References"
|
156
169
|
end
|
157
170
|
end
|
158
171
|
end
|
159
172
|
end
|
160
|
-
end
|
@@ -65,7 +65,7 @@ module Asciidoctor
|
|
65
65
|
word_converter(node).convert filename unless node.attr("nodoc")
|
66
66
|
pdf_converter(node).convert filename unless node.attr("nodoc")
|
67
67
|
end
|
68
|
-
@log.write(@filename + ".err") unless @novalid
|
68
|
+
@log.write(@localdir + @filename + ".err") unless @novalid
|
69
69
|
@files_to_delete.each { |f| FileUtils.rm f }
|
70
70
|
ret
|
71
71
|
end
|
@@ -90,15 +90,6 @@ module Asciidoctor
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
def norm_ref_parse(attrs, xml, node)
|
94
|
-
@norm_ref = true
|
95
|
-
xml.references **attr_code(attrs) do |xml_section|
|
96
|
-
xml_section.title { |t| t << "References" }
|
97
|
-
xml_section << node.content
|
98
|
-
end
|
99
|
-
@norm_ref = false
|
100
|
-
end
|
101
|
-
|
102
93
|
def term_def_title(toplevel, node)
|
103
94
|
return node.title unless toplevel
|
104
95
|
"Definitions"
|
@@ -131,8 +122,6 @@ module Asciidoctor
|
|
131
122
|
div.next = "<p>#{@term_def_boilerplate}</p>"
|
132
123
|
end
|
133
124
|
|
134
|
-
NORM_REF = "//bibliography/references[title = 'References']".freeze
|
135
|
-
|
136
125
|
def load_yaml(lang, script)
|
137
126
|
y = if @i18nyaml then YAML.load_file(@i18nyaml)
|
138
127
|
elsif lang == "en"
|
@@ -148,6 +137,13 @@ module Asciidoctor
|
|
148
137
|
super
|
149
138
|
end
|
150
139
|
|
140
|
+
def metadata_keywords(node, xml)
|
141
|
+
return unless node.attr("keywords")
|
142
|
+
node.attr("keywords").split(/,[ ]*/).sort.each_with_index do |kw, i|
|
143
|
+
xml.keyword (i == 0 ? kw.capitalize : kw)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
151
147
|
def html_extract_attributes(node)
|
152
148
|
super.merge(hierarchical_assets: node.attr("hierarchical-object-numbering"))
|
153
149
|
end
|
@@ -4,36 +4,63 @@ require "fileutils"
|
|
4
4
|
|
5
5
|
module Asciidoctor
|
6
6
|
module ITU
|
7
|
-
|
8
|
-
# A {Converter} implementation that generates RSD output, and a document
|
9
|
-
# schema encapsulation of the document for validation
|
10
|
-
#
|
11
7
|
class Converter < Standoc::Converter
|
12
8
|
def metadata_status(node, xml)
|
13
9
|
xml.status do |s|
|
14
10
|
s.stage (node.attributes.has_key?("draft") ? "draft" :
|
15
|
-
(node.attr("status") || node.attr("docstage") ||
|
11
|
+
(node.attr("status") || node.attr("docstage") ||
|
12
|
+
"published" ))
|
16
13
|
end
|
17
14
|
end
|
18
15
|
|
19
16
|
def title_english(node, xml)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
17
|
+
at = { language: "en", format: "text/plain", type: "main" }
|
18
|
+
a = node.attr("title") || node.attr("title-en")
|
19
|
+
xml.title **attr_code(at) do |t|
|
20
|
+
t << (Asciidoctor::Standoc::Utils::asciidoc_sub(a) || node.title)
|
21
|
+
end
|
22
|
+
if a = node.attr("annextitle") || node.attr("annextitle-en")
|
23
|
+
at[:type] = "annex"
|
24
|
+
xml.title **attr_code(at) do |t|
|
25
|
+
t << Asciidoctor::Standoc::Utils::asciidoc_sub(a)
|
27
26
|
end
|
28
27
|
end
|
29
28
|
end
|
30
29
|
|
31
30
|
def title_otherlangs(node, xml)
|
32
31
|
node.attributes.each do |k, v|
|
33
|
-
next unless /^(annex)?title-(?<
|
34
|
-
next if
|
35
|
-
|
36
|
-
|
32
|
+
next unless /^(annex)?title-(?<lang>.+)$/ =~ k
|
33
|
+
next if lang == "en"
|
34
|
+
type = /^annex/.match(k) ? "annex" : "main"
|
35
|
+
xml.title **attr_code(language: lang, format: "text/plain",
|
36
|
+
type: type) do |t|
|
37
|
+
t << v
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def title(node, xml)
|
43
|
+
super
|
44
|
+
subtitle_english(node, xml)
|
45
|
+
subtitle_otherlangs(node, xml)
|
46
|
+
end
|
47
|
+
|
48
|
+
def subtitle_english(node, xml)
|
49
|
+
at = { language: "en", format: "text/plain", type: "subtitle" }
|
50
|
+
a = node.attr("subtitle") || node.attr("subtitle-en")
|
51
|
+
xml.title **attr_code(at) do |t|
|
52
|
+
t << Asciidoctor::Standoc::Utils::asciidoc_sub(a)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def subtitle_otherlangs(node, xml)
|
57
|
+
node.attributes.each do |k, v|
|
58
|
+
next unless /^subtitle-(?<lang>.+)$/ =~ k
|
59
|
+
next if lang == "en"
|
60
|
+
xml.title **attr_code(language: lang, format: "text/plain",
|
61
|
+
type: "subtitle") do |t|
|
62
|
+
t << v
|
63
|
+
end
|
37
64
|
end
|
38
65
|
end
|
39
66
|
|
@@ -89,11 +116,13 @@ module Asciidoctor
|
|
89
116
|
|
90
117
|
def metadata_committee2(node, g, suffix, prefix)
|
91
118
|
g.name node.attr("#{prefix}group#{suffix}")
|
92
|
-
|
119
|
+
node.attr("#{prefix}groupacronym#{suffix}") and
|
120
|
+
g.acronym node.attr("#{prefix}groupacronym#{suffix}")
|
93
121
|
if node.attr("#{prefix}groupyearstart#{suffix}")
|
94
122
|
g.period do |p|
|
95
123
|
p.start node.attr("#{prefix}groupyearstart#{suffix}")
|
96
|
-
|
124
|
+
node.attr("#{prefix}groupacronym#{suffix}") and
|
125
|
+
p.end node.attr("#{prefix}groupyearend#{suffix}")
|
97
126
|
end
|
98
127
|
end
|
99
128
|
end
|
@@ -101,9 +101,7 @@
|
|
101
101
|
<ref name="structuredidentifier"/>
|
102
102
|
</zeroOrMore>
|
103
103
|
</define>
|
104
|
-
|
105
|
-
<text/>
|
106
|
-
</define>
|
104
|
+
<!-- TitleType = text -->
|
107
105
|
<define name="sections">
|
108
106
|
<element name="sections">
|
109
107
|
<oneOrMore>
|
@@ -131,6 +129,9 @@
|
|
131
129
|
</choice>
|
132
130
|
</attribute>
|
133
131
|
</optional>
|
132
|
+
<attribute name="normative">
|
133
|
+
<data type="boolean"/>
|
134
|
+
</attribute>
|
134
135
|
<optional>
|
135
136
|
<ref name="section-title"/>
|
136
137
|
</optional>
|
@@ -307,6 +308,21 @@
|
|
307
308
|
</define>
|
308
309
|
</include>
|
309
310
|
<!-- end overrides -->
|
311
|
+
<define name="TextElement" combine="choice">
|
312
|
+
<ref name="concept"/>
|
313
|
+
</define>
|
314
|
+
<define name="concept">
|
315
|
+
<element name="concept">
|
316
|
+
<optional>
|
317
|
+
<attribute name="term"/>
|
318
|
+
</optional>
|
319
|
+
<choice>
|
320
|
+
<ref name="eref"/>
|
321
|
+
<ref name="xref"/>
|
322
|
+
<ref name="termref"/>
|
323
|
+
</choice>
|
324
|
+
</element>
|
325
|
+
</define>
|
310
326
|
<define name="BasicBlock" combine="choice">
|
311
327
|
<choice>
|
312
328
|
<ref name="requirement"/>
|
@@ -913,7 +929,10 @@
|
|
913
929
|
</define>
|
914
930
|
<define name="origin">
|
915
931
|
<element name="origin">
|
916
|
-
<
|
932
|
+
<choice>
|
933
|
+
<ref name="erefType"/>
|
934
|
+
<ref name="termref"/>
|
935
|
+
</choice>
|
917
936
|
</element>
|
918
937
|
</define>
|
919
938
|
<define name="modification">
|
@@ -921,6 +940,15 @@
|
|
921
940
|
<ref name="paragraph"/>
|
922
941
|
</element>
|
923
942
|
</define>
|
943
|
+
<define name="termref">
|
944
|
+
<element name="termref">
|
945
|
+
<attribute name="base"/>
|
946
|
+
<attribute name="target"/>
|
947
|
+
<optional>
|
948
|
+
<text/>
|
949
|
+
</optional>
|
950
|
+
</element>
|
951
|
+
</define>
|
924
952
|
<define name="structuredidentifier">
|
925
953
|
<element name="structuredidentifier">
|
926
954
|
<optional>
|
@@ -45,7 +45,7 @@ module Asciidoctor
|
|
45
45
|
def extract_text(node)
|
46
46
|
return "" if node.nil?
|
47
47
|
node1 = Nokogiri::XML.fragment(node.to_s)
|
48
|
-
node1.xpath("//link | //locality").each(&:remove)
|
48
|
+
node1.xpath("//link | //locality | //localityStack").each(&:remove)
|
49
49
|
ret = ""
|
50
50
|
node1.traverse { |x| ret += x.text if x.text? }
|
51
51
|
ret
|