metanorma-ietf 2.3.5 → 2.4.2
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.
- checksums.yaml +4 -4
- data/lib/asciidoctor/ietf/cleanup.rb +99 -0
- data/lib/asciidoctor/ietf/converter.rb +23 -89
- data/lib/asciidoctor/ietf/front.rb +1 -1
- data/lib/asciidoctor/ietf/ietf.rng +5 -2
- data/lib/asciidoctor/ietf/isodoc.rng +93 -18
- data/lib/asciidoctor/ietf/macros.rb +17 -0
- data/lib/asciidoctor/ietf/reqt.rng +15 -4
- data/lib/asciidoctor/ietf/validate.rb +3 -54
- data/lib/isodoc/ietf/blocks.rb +181 -174
- data/lib/isodoc/ietf/cleanup.rb +19 -1
- data/lib/isodoc/ietf/inline.rb +127 -124
- data/lib/isodoc/ietf/references.rb +152 -128
- data/lib/isodoc/ietf/section.rb +1 -1
- data/lib/isodoc/ietf/validation.rb +158 -157
- data/lib/metanorma/ietf/version.rb +1 -1
- data/metanorma-ietf.gemspec +1 -1
- metadata +12 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0bce55e3d73f441a77b94d2aa6f7f464e727b914dd8e8c6fa67dbf035122d63
|
4
|
+
data.tar.gz: 1eaa61e2a47f793b47653f76e8ff6a7fd53a8f7889a06b9e43e61132cb6b066d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8f01b1753308bdb0d335a766fa4ed638a417a81433bb6f6b95a02518674d5eff55b3951db0717e748f7dc8dc3d0def3db27ddadb0f0a36105247f666747099b
|
7
|
+
data.tar.gz: af96278d659ea2949ad3aa2a435cdbe17017e171502fdea71cd5c332d13d7f7a2dade54361e8173aaf9b41e0614af7402fed6773d6f978e2388616f929108007
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Asciidoctor
|
2
|
+
module Ietf
|
3
|
+
class Converter < ::Asciidoctor::Standoc::Converter
|
4
|
+
def cleanup(xmldoc)
|
5
|
+
bcp14_cleanup(xmldoc)
|
6
|
+
abstract_cleanup(xmldoc)
|
7
|
+
super
|
8
|
+
rfc_anchor_cleanup(xmldoc)
|
9
|
+
cref_cleanup(xmldoc)
|
10
|
+
xmldoc
|
11
|
+
end
|
12
|
+
|
13
|
+
def abstract_cleanup(xmldoc)
|
14
|
+
xmldoc.xpath("//abstract[not(text())]").each do |x|
|
15
|
+
x.remove
|
16
|
+
warn "Empty abstract section removed"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def cref_cleanup(xmldoc)
|
21
|
+
xmldoc.xpath("//crefref").each do |r|
|
22
|
+
if c = xmldoc.at("//review[@id = '#{r.text}']")
|
23
|
+
r.replace(c.remove)
|
24
|
+
else
|
25
|
+
@log.add("Crossrefences", r,
|
26
|
+
"No matching review for cref:[#{r.text}]")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
BCP_KEYWORDS = ["MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
|
32
|
+
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY",
|
33
|
+
"OPTIONAL"].freeze
|
34
|
+
|
35
|
+
def bcp14_cleanup(xmldoc)
|
36
|
+
return unless @bcp_bold
|
37
|
+
|
38
|
+
xmldoc.xpath("//strong").each do |s|
|
39
|
+
next unless BCP_KEYWORDS.include?(s.text)
|
40
|
+
|
41
|
+
s.name = "bcp14"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def rfc_anchor_cleanup(xmldoc)
|
46
|
+
map = xmldoc.xpath("//bibitem[docidentifier/@type = 'rfc-anchor']")
|
47
|
+
.each_with_object({}) do |b, m|
|
48
|
+
next if b.at("./ancestor::bibdata | ./ancestor::bibitem")
|
49
|
+
|
50
|
+
id = b.at("./docidentifier[@type = 'rfc-anchor']").text
|
51
|
+
m[b["id"]] = id
|
52
|
+
b["id"] = id
|
53
|
+
end
|
54
|
+
xmldoc.xpath("//eref | //origin").each do |x|
|
55
|
+
map[x["bibitemid"]] and x["bibitemid"] = map[x["bibitemid"]]
|
56
|
+
end
|
57
|
+
xmldoc
|
58
|
+
end
|
59
|
+
|
60
|
+
def smartquotes_cleanup(xmldoc)
|
61
|
+
xmldoc.traverse do |n|
|
62
|
+
next unless n.text?
|
63
|
+
|
64
|
+
n.replace(HTMLEntities.new.encode(
|
65
|
+
n.text.gsub(/\u2019|\u2018|\u201a|\u201b/, "'")
|
66
|
+
.gsub(/\u201c|\u201d|\u201e|\u201f/, '"'), :basic
|
67
|
+
))
|
68
|
+
end
|
69
|
+
xmldoc
|
70
|
+
end
|
71
|
+
|
72
|
+
def xref_to_eref(xref)
|
73
|
+
super
|
74
|
+
xref.delete("format")
|
75
|
+
end
|
76
|
+
|
77
|
+
def xref_cleanup(xmldoc)
|
78
|
+
super
|
79
|
+
xmldoc.xpath("//xref").each do |x|
|
80
|
+
x.delete("displayFormat")
|
81
|
+
x.delete("relative")
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def quotesource_cleanup(xmldoc)
|
86
|
+
xmldoc.xpath("//quote/source | //terms/source").each do |x|
|
87
|
+
if x["target"]&.match?(URI::DEFAULT_PARSER.make_regexp)
|
88
|
+
x["uri"] = x["target"]
|
89
|
+
x.delete("target")
|
90
|
+
else
|
91
|
+
xref_to_eref(x)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def section_names_refs_cleanup(xml); end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -4,10 +4,16 @@ require "isodoc/ietf/rfc_convert"
|
|
4
4
|
require_relative "./front"
|
5
5
|
require_relative "./blocks"
|
6
6
|
require_relative "./validate"
|
7
|
+
require_relative "./cleanup"
|
8
|
+
require_relative "./macros"
|
7
9
|
|
8
10
|
module Asciidoctor
|
9
11
|
module Ietf
|
10
12
|
class Converter < ::Asciidoctor::Standoc::Converter
|
13
|
+
Asciidoctor::Extensions.register do
|
14
|
+
inline_macro Asciidoctor::Ietf::InlineCrefMacro
|
15
|
+
end
|
16
|
+
|
11
17
|
XML_ROOT_TAG = "ietf-standard".freeze
|
12
18
|
XML_NAMESPACE = "https://www.metanorma.org/ns/ietf".freeze
|
13
19
|
|
@@ -22,13 +28,13 @@ module Asciidoctor
|
|
22
28
|
@draft = node.attributes.has_key?("draft")
|
23
29
|
@workgroups = cache_workgroup(node)
|
24
30
|
@bcp_bold = !node.attr?("no-rfc-bold-bcp14")
|
25
|
-
@xinclude = node.attr?("use-xinclude")
|
31
|
+
@xinclude = node.attr?("use-xinclude")
|
26
32
|
super
|
27
33
|
end
|
28
34
|
|
29
35
|
def outputs(node, ret)
|
30
|
-
File.open(@filename
|
31
|
-
rfc_converter(node).convert(@filename
|
36
|
+
File.open("#{@filename}.xml", "w:UTF-8") { |f| f.write(ret) }
|
37
|
+
rfc_converter(node).convert("#{@filename}.xml")
|
32
38
|
end
|
33
39
|
|
34
40
|
def doctype(node)
|
@@ -63,12 +69,12 @@ module Asciidoctor
|
|
63
69
|
f, c = xref_text(node)
|
64
70
|
f1, c = eref_text(node) if f.nil?
|
65
71
|
t, rel = xref_rel(node)
|
72
|
+
attrs = { target: t, type: "inline", displayFormat: f1, format: f,
|
73
|
+
relative: rel }
|
66
74
|
noko do |xml|
|
67
|
-
xml.xref **attr_code(
|
68
|
-
|
69
|
-
|
70
|
-
x << c
|
71
|
-
end
|
75
|
+
xml.xref **attr_code(attrs) do |x|
|
76
|
+
x << c
|
77
|
+
end
|
72
78
|
end.join
|
73
79
|
end
|
74
80
|
|
@@ -112,69 +118,7 @@ module Asciidoctor
|
|
112
118
|
[t, rel]
|
113
119
|
end
|
114
120
|
|
115
|
-
def
|
116
|
-
bcp14_cleanup(xmldoc)
|
117
|
-
abstract_cleanup(xmldoc)
|
118
|
-
super
|
119
|
-
rfc_anchor_cleanup(xmldoc)
|
120
|
-
end
|
121
|
-
|
122
|
-
BCP_KEYWORDS = ["MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
|
123
|
-
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", "OPTIONAL"].freeze
|
124
|
-
|
125
|
-
def abstract_cleanup(xmldoc)
|
126
|
-
xmldoc.xpath("//abstract[not(text())]").each do |x|
|
127
|
-
x.remove
|
128
|
-
warn "Empty abstract section removed"
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
def bcp14_cleanup(xmldoc)
|
133
|
-
return unless @bcp_bold
|
134
|
-
xmldoc.xpath("//strong").each do |s|
|
135
|
-
next unless BCP_KEYWORDS.include?(s.text)
|
136
|
-
s.name = "bcp14"
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
def rfc_anchor_cleanup(xmldoc)
|
141
|
-
map = {}
|
142
|
-
xmldoc.xpath("//bibitem[docidentifier/@type = 'rfc-anchor']").each do |b|
|
143
|
-
next if b.at("./ancestor::bibdata")
|
144
|
-
map[b["id"]] = b.at("./docidentifier[@type = 'rfc-anchor']").text
|
145
|
-
b["id"] = b.at("./docidentifier[@type = 'rfc-anchor']").text
|
146
|
-
end
|
147
|
-
xmldoc.xpath("//eref | //origin").each do |x|
|
148
|
-
map[x["bibitemid"]] and x["bibitemid"] = map[x["bibitemid"]]
|
149
|
-
end
|
150
|
-
xmldoc
|
151
|
-
end
|
152
|
-
|
153
|
-
def smartquotes_cleanup(xmldoc)
|
154
|
-
xmldoc.traverse do |n|
|
155
|
-
next unless n.text?
|
156
|
-
n.replace(HTMLEntities.new.encode(
|
157
|
-
n.text.gsub(/\u2019|\u2018|\u201a|\u201b/, "'").
|
158
|
-
gsub(/\u201c|\u201d|\u201e|\u201f/, '"'), :basic))
|
159
|
-
end
|
160
|
-
xmldoc
|
161
|
-
end
|
162
|
-
|
163
|
-
def xref_to_eref(x)
|
164
|
-
super
|
165
|
-
x.delete("format")
|
166
|
-
end
|
167
|
-
|
168
|
-
def xref_cleanup(xmldoc)
|
169
|
-
super
|
170
|
-
xmldoc.xpath("//xref").each do |x|
|
171
|
-
x.delete("displayFormat")
|
172
|
-
x.delete("relative")
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
def norm_ref_preface(f)
|
177
|
-
end
|
121
|
+
def norm_ref_preface(sect); end
|
178
122
|
|
179
123
|
def clause_parse(attrs, xml, node)
|
180
124
|
attrs[:numbered] = node.attr("numbered")
|
@@ -194,34 +138,24 @@ module Asciidoctor
|
|
194
138
|
clause_parse(attrs, xml, node)
|
195
139
|
end
|
196
140
|
|
197
|
-
def quotesource_cleanup(xmldoc)
|
198
|
-
xmldoc.xpath("//quote/source | //terms/source").each do |x|
|
199
|
-
if x["target"] =~ URI::DEFAULT_PARSER.make_regexp
|
200
|
-
x["uri"] = x["target"]
|
201
|
-
x.delete("target")
|
202
|
-
else
|
203
|
-
xref_to_eref(x)
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
141
|
def inline_indexterm(node)
|
209
142
|
noko do |xml|
|
210
143
|
node.type == :visible and xml << node.text.sub(/^primary:(?=\S)/, "")
|
211
144
|
terms = (node.attr("terms") || [node.text]).map { |x| xml_encode(x) }
|
212
|
-
if /^primary:\S/.match(terms[0])
|
145
|
+
if /^primary:\S/.match?(terms[0])
|
213
146
|
terms[0].sub!(/^primary:/, "")
|
214
147
|
has_primary = true
|
215
148
|
end
|
216
|
-
|
217
|
-
i.primary { |x| x << terms[0] }
|
218
|
-
a = terms.dig(1) and i.secondary { |x| x << a }
|
219
|
-
a = terms.dig(2) and i.tertiary { |x| x << a }
|
220
|
-
end
|
149
|
+
inline_indexterm1(has_primary, terms, xml)
|
221
150
|
end.join
|
222
151
|
end
|
223
152
|
|
224
|
-
def
|
153
|
+
def inline_indexterm1(has_primary, terms, xml)
|
154
|
+
xml.index **attr_code(primary: has_primary) do |i|
|
155
|
+
i.primary { |x| x << terms[0] }
|
156
|
+
a = terms[1] and i.secondary { |x| x << a }
|
157
|
+
a = terms[2] and i.tertiary { |x| x << a }
|
158
|
+
end
|
225
159
|
end
|
226
160
|
|
227
161
|
def html_extract_attributes(node)
|
@@ -119,7 +119,7 @@ module Asciidoctor
|
|
119
119
|
strict: node.attr("strict"),
|
120
120
|
compact: node.attr("compact"),
|
121
121
|
subcompact: node.attr("subcompact"),
|
122
|
-
|
122
|
+
tocinclude: node.attr("toc-include") == "false" ? "no" : "yes",
|
123
123
|
tocdepth: node.attr("toc-depth"),
|
124
124
|
symrefs: node.attr("sym-refs"),
|
125
125
|
sortrefs: node.attr("sort-refs"),
|
@@ -602,7 +602,10 @@
|
|
602
602
|
</define>
|
603
603
|
</include>
|
604
604
|
<define name="TextElement" combine="choice">
|
605
|
-
<
|
605
|
+
<choice>
|
606
|
+
<ref name="bcp14"/>
|
607
|
+
<ref name="review"/>
|
608
|
+
</choice>
|
606
609
|
</define>
|
607
610
|
<define name="bcp14">
|
608
611
|
<element name="bcp14">
|
@@ -842,7 +845,7 @@
|
|
842
845
|
</element>
|
843
846
|
</optional>
|
844
847
|
<optional>
|
845
|
-
<element name="
|
848
|
+
<element name="tocinclude">
|
846
849
|
<text/>
|
847
850
|
</element>
|
848
851
|
</optional>
|
@@ -32,6 +32,18 @@
|
|
32
32
|
<ref name="DocumentType"/>
|
33
33
|
</element>
|
34
34
|
</define>
|
35
|
+
<define name="section-title">
|
36
|
+
<element name="title">
|
37
|
+
<zeroOrMore>
|
38
|
+
<ref name="TextElement"/>
|
39
|
+
</zeroOrMore>
|
40
|
+
</element>
|
41
|
+
<zeroOrMore>
|
42
|
+
<element name="variant-title">
|
43
|
+
<ref name="TypedTitleString"/>
|
44
|
+
</element>
|
45
|
+
</zeroOrMore>
|
46
|
+
</define>
|
35
47
|
<define name="hyperlink">
|
36
48
|
<element name="link">
|
37
49
|
<attribute name="target">
|
@@ -158,15 +170,17 @@
|
|
158
170
|
<data type="boolean"/>
|
159
171
|
</attribute>
|
160
172
|
</optional>
|
161
|
-
<
|
162
|
-
<
|
163
|
-
<
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
173
|
+
<optional>
|
174
|
+
<attribute name="type">
|
175
|
+
<choice>
|
176
|
+
<value>roman</value>
|
177
|
+
<value>alphabet</value>
|
178
|
+
<value>arabic</value>
|
179
|
+
<value>roman_upper</value>
|
180
|
+
<value>alphabet_upper</value>
|
181
|
+
</choice>
|
182
|
+
</attribute>
|
183
|
+
</optional>
|
170
184
|
<oneOrMore>
|
171
185
|
<ref name="li"/>
|
172
186
|
</oneOrMore>
|
@@ -204,6 +218,18 @@
|
|
204
218
|
</zeroOrMore>
|
205
219
|
</element>
|
206
220
|
</define>
|
221
|
+
<define name="dt">
|
222
|
+
<element name="dt">
|
223
|
+
<optional>
|
224
|
+
<attribute name="id">
|
225
|
+
<data type="ID"/>
|
226
|
+
</attribute>
|
227
|
+
</optional>
|
228
|
+
<zeroOrMore>
|
229
|
+
<ref name="TextElement"/>
|
230
|
+
</zeroOrMore>
|
231
|
+
</element>
|
232
|
+
</define>
|
207
233
|
<define name="example">
|
208
234
|
<element name="example">
|
209
235
|
<attribute name="id">
|
@@ -899,7 +925,7 @@
|
|
899
925
|
</include>
|
900
926
|
<!-- end overrides -->
|
901
927
|
<define name="docsubtype">
|
902
|
-
<element name="
|
928
|
+
<element name="subdoctype">
|
903
929
|
<ref name="DocumentSubtype"/>
|
904
930
|
</element>
|
905
931
|
</define>
|
@@ -954,6 +980,26 @@
|
|
954
980
|
</define>
|
955
981
|
<define name="concept">
|
956
982
|
<element name="concept">
|
983
|
+
<optional>
|
984
|
+
<attribute name="ital">
|
985
|
+
<data type="boolean"/>
|
986
|
+
</attribute>
|
987
|
+
</optional>
|
988
|
+
<optional>
|
989
|
+
<attribute name="ref">
|
990
|
+
<data type="boolean"/>
|
991
|
+
</attribute>
|
992
|
+
</optional>
|
993
|
+
<optional>
|
994
|
+
<attribute name="linkmention">
|
995
|
+
<data type="boolean"/>
|
996
|
+
</attribute>
|
997
|
+
</optional>
|
998
|
+
<optional>
|
999
|
+
<attribute name="linkref">
|
1000
|
+
<data type="boolean"/>
|
1001
|
+
</attribute>
|
1002
|
+
</optional>
|
957
1003
|
<optional>
|
958
1004
|
<element name="refterm">
|
959
1005
|
<zeroOrMore>
|
@@ -989,8 +1035,23 @@
|
|
989
1035
|
<ref name="imagemap"/>
|
990
1036
|
<ref name="svgmap"/>
|
991
1037
|
<ref name="inputform"/>
|
1038
|
+
<ref name="toc"/>
|
1039
|
+
<ref name="passthrough"/>
|
992
1040
|
</choice>
|
993
1041
|
</define>
|
1042
|
+
<define name="toc">
|
1043
|
+
<element name="toc">
|
1044
|
+
<ref name="ul"/>
|
1045
|
+
</element>
|
1046
|
+
</define>
|
1047
|
+
<define name="passthrough">
|
1048
|
+
<element name="passthrough">
|
1049
|
+
<optional>
|
1050
|
+
<attribute name="formats"/>
|
1051
|
+
</optional>
|
1052
|
+
<text/>
|
1053
|
+
</element>
|
1054
|
+
</define>
|
994
1055
|
<define name="inputform">
|
995
1056
|
<element name="form">
|
996
1057
|
<attribute name="id">
|
@@ -998,6 +1059,9 @@
|
|
998
1059
|
</attribute>
|
999
1060
|
<attribute name="name"/>
|
1000
1061
|
<attribute name="action"/>
|
1062
|
+
<optional>
|
1063
|
+
<attribute name="class"/>
|
1064
|
+
</optional>
|
1001
1065
|
<zeroOrMore>
|
1002
1066
|
<choice>
|
1003
1067
|
<ref name="TextElement"/>
|
@@ -1229,6 +1293,12 @@
|
|
1229
1293
|
<optional>
|
1230
1294
|
<attribute name="type"/>
|
1231
1295
|
</optional>
|
1296
|
+
<optional>
|
1297
|
+
<attribute name="identifier"/>
|
1298
|
+
</optional>
|
1299
|
+
<optional>
|
1300
|
+
<attribute name="prefix"/>
|
1301
|
+
</optional>
|
1232
1302
|
<text/>
|
1233
1303
|
</define>
|
1234
1304
|
<define name="ics">
|
@@ -1490,26 +1560,26 @@
|
|
1490
1560
|
<optional>
|
1491
1561
|
<ref name="section-title"/>
|
1492
1562
|
</optional>
|
1493
|
-
<
|
1563
|
+
<choice>
|
1494
1564
|
<choice>
|
1495
1565
|
<group>
|
1496
|
-
<
|
1566
|
+
<oneOrMore>
|
1497
1567
|
<ref name="BasicBlock"/>
|
1498
|
-
</
|
1568
|
+
</oneOrMore>
|
1499
1569
|
<zeroOrMore>
|
1500
1570
|
<ref name="note"/>
|
1501
1571
|
</zeroOrMore>
|
1502
1572
|
</group>
|
1503
1573
|
<ref name="amend"/>
|
1504
1574
|
</choice>
|
1505
|
-
<
|
1575
|
+
<oneOrMore>
|
1506
1576
|
<choice>
|
1507
1577
|
<ref name="clause-subsection"/>
|
1508
1578
|
<ref name="terms"/>
|
1509
1579
|
<ref name="definitions"/>
|
1510
1580
|
</choice>
|
1511
|
-
</
|
1512
|
-
</
|
1581
|
+
</oneOrMore>
|
1582
|
+
</choice>
|
1513
1583
|
</define>
|
1514
1584
|
<define name="Annex-Section">
|
1515
1585
|
<optional>
|
@@ -1649,7 +1719,9 @@
|
|
1649
1719
|
<zeroOrMore>
|
1650
1720
|
<ref name="termgrammar"/>
|
1651
1721
|
</zeroOrMore>
|
1652
|
-
<
|
1722
|
+
<oneOrMore>
|
1723
|
+
<ref name="termdefinition"/>
|
1724
|
+
</oneOrMore>
|
1653
1725
|
<zeroOrMore>
|
1654
1726
|
<ref name="termnote"/>
|
1655
1727
|
</zeroOrMore>
|
@@ -1712,7 +1784,7 @@
|
|
1712
1784
|
</oneOrMore>
|
1713
1785
|
</element>
|
1714
1786
|
</define>
|
1715
|
-
<define name="
|
1787
|
+
<define name="termdefinition">
|
1716
1788
|
<element name="definition">
|
1717
1789
|
<oneOrMore>
|
1718
1790
|
<choice>
|
@@ -1721,6 +1793,9 @@
|
|
1721
1793
|
<ref name="formula"/>
|
1722
1794
|
</choice>
|
1723
1795
|
</oneOrMore>
|
1796
|
+
<zeroOrMore>
|
1797
|
+
<ref name="termsource"/>
|
1798
|
+
</zeroOrMore>
|
1724
1799
|
</element>
|
1725
1800
|
</define>
|
1726
1801
|
<define name="termnote">
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "asciidoctor/extensions"
|
2
|
+
|
3
|
+
module Asciidoctor
|
4
|
+
module Ietf
|
5
|
+
class InlineCrefMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
6
|
+
use_dsl
|
7
|
+
named :cref
|
8
|
+
parse_content_as :text
|
9
|
+
using_format :short
|
10
|
+
|
11
|
+
def process(parent, _target, attrs)
|
12
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
13
|
+
%{<crefref>#{out}</crefref>}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -64,9 +64,9 @@
|
|
64
64
|
<optional>
|
65
65
|
<ref name="label"/>
|
66
66
|
</optional>
|
67
|
-
<
|
67
|
+
<zeroOrMore>
|
68
68
|
<ref name="subject"/>
|
69
|
-
</
|
69
|
+
</zeroOrMore>
|
70
70
|
<zeroOrMore>
|
71
71
|
<ref name="reqinherit"/>
|
72
72
|
</zeroOrMore>
|
@@ -80,6 +80,7 @@
|
|
80
80
|
<ref name="verification"/>
|
81
81
|
<ref name="import"/>
|
82
82
|
<ref name="description"/>
|
83
|
+
<ref name="component"/>
|
83
84
|
</choice>
|
84
85
|
</zeroOrMore>
|
85
86
|
<optional>
|
@@ -105,12 +106,16 @@
|
|
105
106
|
</define>
|
106
107
|
<define name="subject">
|
107
108
|
<element name="subject">
|
108
|
-
<
|
109
|
+
<oneOrMore>
|
110
|
+
<ref name="TextElement"/>
|
111
|
+
</oneOrMore>
|
109
112
|
</element>
|
110
113
|
</define>
|
111
114
|
<define name="reqinherit">
|
112
115
|
<element name="inherit">
|
113
|
-
<
|
116
|
+
<oneOrMore>
|
117
|
+
<ref name="TextElement"/>
|
118
|
+
</oneOrMore>
|
114
119
|
</element>
|
115
120
|
</define>
|
116
121
|
<define name="measurementtarget">
|
@@ -138,6 +143,12 @@
|
|
138
143
|
<ref name="RequirementSubpart"/>
|
139
144
|
</element>
|
140
145
|
</define>
|
146
|
+
<define name="component">
|
147
|
+
<element name="component">
|
148
|
+
<attribute name="class"/>
|
149
|
+
<ref name="RequirementSubpart"/>
|
150
|
+
</element>
|
151
|
+
</define>
|
141
152
|
<define name="reqt_references">
|
142
153
|
<element name="references">
|
143
154
|
<oneOrMore>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require "
|
1
|
+
require "metanorma/ietf/data/workgroups"
|
2
2
|
|
3
3
|
module Asciidoctor
|
4
4
|
module Ietf
|
@@ -34,59 +34,8 @@ module Asciidoctor
|
|
34
34
|
File.join(File.dirname(__FILE__), "ietf.rng"))
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
def open_wg_cache(node)
|
42
|
-
node.attr("flush-caches") == "true" and
|
43
|
-
FileUtils.rm wgcache_name, force: true
|
44
|
-
wg = []
|
45
|
-
if Pathname.new(wgcache_name).file?
|
46
|
-
begin
|
47
|
-
File.open(wgcache_name, "r") { |f| wg = JSON.parse(f.read) }
|
48
|
-
rescue Exception => e
|
49
|
-
warn "Cache #{wgcache_name} is invalid, drop it"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
[wg, wgcache_name]
|
53
|
-
end
|
54
|
-
|
55
|
-
def cache_workgroup_ietf(wg, _b)
|
56
|
-
warn "Reading workgroups from https://tools.ietf.org/wg/..."
|
57
|
-
URI.open("https://tools.ietf.org/wg/") do |f|
|
58
|
-
f.each_line do |l|
|
59
|
-
l.scan(%r{<td width="50%" style='padding: 0 1ex'>([^<]+)</td>}) do |w|
|
60
|
-
wg << w[0].gsub(/\s+$/, "").gsub(/ Working Group$/, "")
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
wg
|
65
|
-
end
|
66
|
-
|
67
|
-
def cache_workgroup_irtf(wg, _b)
|
68
|
-
warn "Reading workgroups from https://irtf.org/groups..."
|
69
|
-
URI.open("https://irtf.org/groups", ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE) do |f|
|
70
|
-
f.each_line do |l|
|
71
|
-
l.scan(%r{<a title="([^"]+) Research Group"[^>]+>([^<]+)<}) do |w|
|
72
|
-
wg << w[0].gsub(/\s+$/, "")
|
73
|
-
wg << w[1].gsub(/\s+$/, "") # abbrev
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
wg
|
78
|
-
end
|
79
|
-
|
80
|
-
def cache_workgroup(node)
|
81
|
-
wg, wgcache_name = open_wg_cache(node)
|
82
|
-
if wg.empty?
|
83
|
-
File.open(wgcache_name, "w") do |b|
|
84
|
-
wg = cache_workgroup_ietf(wg, b)
|
85
|
-
wg = cache_workgroup_irtf(wg, b)
|
86
|
-
b << wg.to_json
|
87
|
-
end
|
88
|
-
end
|
89
|
-
wg
|
37
|
+
def cache_workgroup(_node)
|
38
|
+
Metanorma::Ietf::Data::WORKGROUPS
|
90
39
|
end
|
91
40
|
end
|
92
41
|
end
|