metanorma-ietf 2.3.4 → 2.4.1
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/.github/workflows/rake.yml +1 -1
- data/lib/asciidoctor/ietf/cleanup.rb +81 -0
- data/lib/asciidoctor/ietf/converter.rb +19 -27
- data/lib/asciidoctor/ietf/front.rb +1 -1
- data/lib/asciidoctor/ietf/ietf.rng +1 -1
- data/lib/asciidoctor/ietf/isodoc.rng +85 -17
- 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/references.rb +139 -129
- data/lib/isodoc/ietf/rfc_convert.rb +6 -4
- data/lib/isodoc/ietf/section.rb +1 -1
- data/lib/isodoc/ietf/terms.rb +13 -2
- data/lib/isodoc/ietf/validation.rb +158 -157
- data/lib/metanorma/ietf/version.rb +1 -1
- data/metanorma-ietf.gemspec +3 -2
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: def69cf551c6c50fcb28fcdf04ab02e0d3d9cf83ba3dcd81114c41f71860599f
|
4
|
+
data.tar.gz: 5afc33bb93c93fbc86565d984562a3a61ed02b700e0a1e66a70f47289ef230c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a2c6f8d47d875c1fb896d1fffdc5d5f789c05a679ab474ae7dfbc52795b9df47eb4763164f08c2da964c0de53ad51f91233ea230a8bce9553a31986f19bf4cd
|
7
|
+
data.tar.gz: eb7fbd7913907b01e95f07bd2b28058b1d8c953f5f9b8b8a9c81a6c1638319fbb2ce8f593a3d83970b5ea748fbf34b7d0ba60b73ea5fa8f9c1a41e3076aec6ac
|
data/.github/workflows/rake.yml
CHANGED
@@ -0,0 +1,81 @@
|
|
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
|
+
end
|
10
|
+
|
11
|
+
def abstract_cleanup(xmldoc)
|
12
|
+
xmldoc.xpath("//abstract[not(text())]").each do |x|
|
13
|
+
x.remove
|
14
|
+
warn "Empty abstract section removed"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def bcp14_cleanup(xmldoc)
|
19
|
+
return unless @bcp_bold
|
20
|
+
|
21
|
+
xmldoc.xpath("//strong").each do |s|
|
22
|
+
next unless BCP_KEYWORDS.include?(s.text)
|
23
|
+
|
24
|
+
s.name = "bcp14"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def rfc_anchor_cleanup(xmldoc)
|
29
|
+
map = {}
|
30
|
+
xmldoc.xpath("//bibitem[docidentifier/@type = 'rfc-anchor']").each do |b|
|
31
|
+
next if b.at("./ancestor::bibdata")
|
32
|
+
|
33
|
+
map[b["id"]] = b.at("./docidentifier[@type = 'rfc-anchor']").text
|
34
|
+
b["id"] = b.at("./docidentifier[@type = 'rfc-anchor']").text
|
35
|
+
end
|
36
|
+
xmldoc.xpath("//eref | //origin").each do |x|
|
37
|
+
map[x["bibitemid"]] and x["bibitemid"] = map[x["bibitemid"]]
|
38
|
+
end
|
39
|
+
xmldoc
|
40
|
+
end
|
41
|
+
|
42
|
+
def smartquotes_cleanup(xmldoc)
|
43
|
+
xmldoc.traverse do |n|
|
44
|
+
next unless n.text?
|
45
|
+
|
46
|
+
n.replace(HTMLEntities.new.encode(
|
47
|
+
n.text.gsub(/\u2019|\u2018|\u201a|\u201b/, "'")
|
48
|
+
.gsub(/\u201c|\u201d|\u201e|\u201f/, '"'), :basic
|
49
|
+
))
|
50
|
+
end
|
51
|
+
xmldoc
|
52
|
+
end
|
53
|
+
|
54
|
+
def xref_to_eref(xref)
|
55
|
+
super
|
56
|
+
xref.delete("format")
|
57
|
+
end
|
58
|
+
|
59
|
+
def xref_cleanup(xmldoc)
|
60
|
+
super
|
61
|
+
xmldoc.xpath("//xref").each do |x|
|
62
|
+
x.delete("displayFormat")
|
63
|
+
x.delete("relative")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def quotesource_cleanup(xmldoc)
|
68
|
+
xmldoc.xpath("//quote/source | //terms/source").each do |x|
|
69
|
+
if x["target"]&.match?(URI::DEFAULT_PARSER.make_regexp)
|
70
|
+
x["uri"] = x["target"]
|
71
|
+
x.delete("target")
|
72
|
+
else
|
73
|
+
xref_to_eref(x)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def section_names_refs_cleanup(xml); end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -4,6 +4,7 @@ require "isodoc/ietf/rfc_convert"
|
|
4
4
|
require_relative "./front"
|
5
5
|
require_relative "./blocks"
|
6
6
|
require_relative "./validate"
|
7
|
+
require_relative "./cleanup"
|
7
8
|
|
8
9
|
module Asciidoctor
|
9
10
|
module Ietf
|
@@ -22,13 +23,13 @@ module Asciidoctor
|
|
22
23
|
@draft = node.attributes.has_key?("draft")
|
23
24
|
@workgroups = cache_workgroup(node)
|
24
25
|
@bcp_bold = !node.attr?("no-rfc-bold-bcp14")
|
25
|
-
@xinclude = node.attr?("use-xinclude")
|
26
|
+
@xinclude = node.attr?("use-xinclude")
|
26
27
|
super
|
27
28
|
end
|
28
29
|
|
29
30
|
def outputs(node, ret)
|
30
|
-
File.open(@filename
|
31
|
-
rfc_converter(node).convert(@filename
|
31
|
+
File.open("#{@filename}.xml", "w:UTF-8") { |f| f.write(ret) }
|
32
|
+
rfc_converter(node).convert("#{@filename}.xml")
|
32
33
|
end
|
33
34
|
|
34
35
|
def doctype(node)
|
@@ -63,12 +64,12 @@ module Asciidoctor
|
|
63
64
|
f, c = xref_text(node)
|
64
65
|
f1, c = eref_text(node) if f.nil?
|
65
66
|
t, rel = xref_rel(node)
|
67
|
+
attrs = { target: t, type: "inline", displayFormat: f1, format: f,
|
68
|
+
relative: rel }
|
66
69
|
noko do |xml|
|
67
|
-
xml.xref **attr_code(
|
68
|
-
|
69
|
-
|
70
|
-
x << c
|
71
|
-
end
|
70
|
+
xml.xref **attr_code(attrs) do |x|
|
71
|
+
x << c
|
72
|
+
end
|
72
73
|
end.join
|
73
74
|
end
|
74
75
|
|
@@ -140,7 +141,8 @@ module Asciidoctor
|
|
140
141
|
def rfc_anchor_cleanup(xmldoc)
|
141
142
|
map = {}
|
142
143
|
xmldoc.xpath("//bibitem[docidentifier/@type = 'rfc-anchor']").each do |b|
|
143
|
-
next if b.at("./ancestor::bibdata")
|
144
|
+
next if b.at("./ancestor::bibdata | ./ancestor::bibitem")
|
145
|
+
|
144
146
|
map[b["id"]] = b.at("./docidentifier[@type = 'rfc-anchor']").text
|
145
147
|
b["id"] = b.at("./docidentifier[@type = 'rfc-anchor']").text
|
146
148
|
end
|
@@ -194,34 +196,24 @@ module Asciidoctor
|
|
194
196
|
clause_parse(attrs, xml, node)
|
195
197
|
end
|
196
198
|
|
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
199
|
def inline_indexterm(node)
|
209
200
|
noko do |xml|
|
210
201
|
node.type == :visible and xml << node.text.sub(/^primary:(?=\S)/, "")
|
211
202
|
terms = (node.attr("terms") || [node.text]).map { |x| xml_encode(x) }
|
212
|
-
if /^primary:\S/.match(terms[0])
|
203
|
+
if /^primary:\S/.match?(terms[0])
|
213
204
|
terms[0].sub!(/^primary:/, "")
|
214
205
|
has_primary = true
|
215
206
|
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
|
207
|
+
inline_indexterm1(has_primary, terms, xml)
|
221
208
|
end.join
|
222
209
|
end
|
223
210
|
|
224
|
-
def
|
211
|
+
def inline_indexterm1(has_primary, terms, xml)
|
212
|
+
xml.index **attr_code(primary: has_primary) do |i|
|
213
|
+
i.primary { |x| x << terms[0] }
|
214
|
+
a = terms[1] and i.secondary { |x| x << a }
|
215
|
+
a = terms[2] and i.tertiary { |x| x << a }
|
216
|
+
end
|
225
217
|
end
|
226
218
|
|
227
219
|
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"),
|
@@ -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>
|
@@ -955,7 +981,34 @@
|
|
955
981
|
<define name="concept">
|
956
982
|
<element name="concept">
|
957
983
|
<optional>
|
958
|
-
<attribute name="
|
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
|
+
<element name="refterm">
|
995
|
+
<zeroOrMore>
|
996
|
+
<choice>
|
997
|
+
<ref name="PureTextElement"/>
|
998
|
+
<ref name="stem"/>
|
999
|
+
</choice>
|
1000
|
+
</zeroOrMore>
|
1001
|
+
</element>
|
1002
|
+
</optional>
|
1003
|
+
<optional>
|
1004
|
+
<element name="renderterm">
|
1005
|
+
<zeroOrMore>
|
1006
|
+
<choice>
|
1007
|
+
<ref name="PureTextElement"/>
|
1008
|
+
<ref name="stem"/>
|
1009
|
+
</choice>
|
1010
|
+
</zeroOrMore>
|
1011
|
+
</element>
|
959
1012
|
</optional>
|
960
1013
|
<choice>
|
961
1014
|
<ref name="eref"/>
|
@@ -972,8 +1025,14 @@
|
|
972
1025
|
<ref name="imagemap"/>
|
973
1026
|
<ref name="svgmap"/>
|
974
1027
|
<ref name="inputform"/>
|
1028
|
+
<ref name="toc"/>
|
975
1029
|
</choice>
|
976
1030
|
</define>
|
1031
|
+
<define name="toc">
|
1032
|
+
<element name="toc">
|
1033
|
+
<ref name="ul"/>
|
1034
|
+
</element>
|
1035
|
+
</define>
|
977
1036
|
<define name="inputform">
|
978
1037
|
<element name="form">
|
979
1038
|
<attribute name="id">
|
@@ -981,6 +1040,9 @@
|
|
981
1040
|
</attribute>
|
982
1041
|
<attribute name="name"/>
|
983
1042
|
<attribute name="action"/>
|
1043
|
+
<optional>
|
1044
|
+
<attribute name="class"/>
|
1045
|
+
</optional>
|
984
1046
|
<zeroOrMore>
|
985
1047
|
<choice>
|
986
1048
|
<ref name="TextElement"/>
|
@@ -1212,6 +1274,12 @@
|
|
1212
1274
|
<optional>
|
1213
1275
|
<attribute name="type"/>
|
1214
1276
|
</optional>
|
1277
|
+
<optional>
|
1278
|
+
<attribute name="identifier"/>
|
1279
|
+
</optional>
|
1280
|
+
<optional>
|
1281
|
+
<attribute name="prefix"/>
|
1282
|
+
</optional>
|
1215
1283
|
<text/>
|
1216
1284
|
</define>
|
1217
1285
|
<define name="ics">
|
@@ -1473,26 +1541,26 @@
|
|
1473
1541
|
<optional>
|
1474
1542
|
<ref name="section-title"/>
|
1475
1543
|
</optional>
|
1476
|
-
<
|
1544
|
+
<choice>
|
1477
1545
|
<choice>
|
1478
1546
|
<group>
|
1479
|
-
<
|
1547
|
+
<oneOrMore>
|
1480
1548
|
<ref name="BasicBlock"/>
|
1481
|
-
</
|
1549
|
+
</oneOrMore>
|
1482
1550
|
<zeroOrMore>
|
1483
1551
|
<ref name="note"/>
|
1484
1552
|
</zeroOrMore>
|
1485
1553
|
</group>
|
1486
1554
|
<ref name="amend"/>
|
1487
1555
|
</choice>
|
1488
|
-
<
|
1556
|
+
<oneOrMore>
|
1489
1557
|
<choice>
|
1490
1558
|
<ref name="clause-subsection"/>
|
1491
1559
|
<ref name="terms"/>
|
1492
1560
|
<ref name="definitions"/>
|
1493
1561
|
</choice>
|
1494
|
-
</
|
1495
|
-
</
|
1562
|
+
</oneOrMore>
|
1563
|
+
</choice>
|
1496
1564
|
</define>
|
1497
1565
|
<define name="Annex-Section">
|
1498
1566
|
<optional>
|
@@ -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>
|