metanorma-ietf 2.3.6 → 2.4.3
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 +27 -10
- data/lib/asciidoctor/ietf/converter.rb +6 -64
- data/lib/asciidoctor/ietf/front.rb +1 -1
- data/lib/asciidoctor/ietf/ietf.rng +5 -2
- data/lib/asciidoctor/ietf/isodoc.rng +61 -11
- 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 +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b22c8815c0cc3923b629bedb736f56ff20f06aca37abf875d67ff91a63ac6af
|
4
|
+
data.tar.gz: 7a2dd5c740d7f2343c07f684f1f7c672b5577f03e5acc48467da7e3d63f6eb2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f602fe12119c1bf21a3d35ef675d67ce68964373a41a34e39c3f6c38ba5233d129cc43e39599a87ac3237c0b1da2ece3773d50e499b8f3b1a36dce35c6d1acd0
|
7
|
+
data.tar.gz: 03fbcf5cb80118d00fdf3753cc00277f52c16fe60c229b03e360ac47cd9b8df3982a11b35a5226dd36c58c593c2aba6e1a08158ebbc5c4184f7aaaceb95d8959
|
@@ -6,12 +6,10 @@ module Asciidoctor
|
|
6
6
|
abstract_cleanup(xmldoc)
|
7
7
|
super
|
8
8
|
rfc_anchor_cleanup(xmldoc)
|
9
|
+
cref_cleanup(xmldoc)
|
10
|
+
xmldoc
|
9
11
|
end
|
10
12
|
|
11
|
-
BCP_KEYWORDS =
|
12
|
-
["MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
|
13
|
-
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", "OPTIONAL"].freeze
|
14
|
-
|
15
13
|
def abstract_cleanup(xmldoc)
|
16
14
|
xmldoc.xpath("//abstract[not(text())]").each do |x|
|
17
15
|
x.remove
|
@@ -19,6 +17,21 @@ module Asciidoctor
|
|
19
17
|
end
|
20
18
|
end
|
21
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
|
+
|
22
35
|
def bcp14_cleanup(xmldoc)
|
23
36
|
return unless @bcp_bold
|
24
37
|
|
@@ -30,12 +43,13 @@ module Asciidoctor
|
|
30
43
|
end
|
31
44
|
|
32
45
|
def rfc_anchor_cleanup(xmldoc)
|
33
|
-
map =
|
34
|
-
|
35
|
-
next if b.at("./ancestor::bibdata")
|
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")
|
36
49
|
|
37
|
-
|
38
|
-
b["id"] =
|
50
|
+
id = b.at("./docidentifier[@type = 'rfc-anchor']").text
|
51
|
+
m[b["id"]] = id
|
52
|
+
b["id"] = id
|
39
53
|
end
|
40
54
|
xmldoc.xpath("//eref | //origin").each do |x|
|
41
55
|
map[x["bibitemid"]] and x["bibitemid"] = map[x["bibitemid"]]
|
@@ -49,7 +63,10 @@ module Asciidoctor
|
|
49
63
|
|
50
64
|
n.replace(HTMLEntities.new.encode(
|
51
65
|
n.text.gsub(/\u2019|\u2018|\u201a|\u201b/, "'")
|
52
|
-
.gsub(/\u201c|\u201d|\u201e|\u201f/, '"')
|
66
|
+
.gsub(/\u201c|\u201d|\u201e|\u201f/, '"')
|
67
|
+
.gsub(/[\u2010-\u2015]/, "-")
|
68
|
+
.gsub(/[\u2000-\u200a]|\u202f|\u205f/, " "),
|
69
|
+
:basic,
|
53
70
|
))
|
54
71
|
end
|
55
72
|
xmldoc
|
@@ -5,10 +5,15 @@ require_relative "./front"
|
|
5
5
|
require_relative "./blocks"
|
6
6
|
require_relative "./validate"
|
7
7
|
require_relative "./cleanup"
|
8
|
+
require_relative "./macros"
|
8
9
|
|
9
10
|
module Asciidoctor
|
10
11
|
module Ietf
|
11
12
|
class Converter < ::Asciidoctor::Standoc::Converter
|
13
|
+
Asciidoctor::Extensions.register do
|
14
|
+
inline_macro Asciidoctor::Ietf::InlineCrefMacro
|
15
|
+
end
|
16
|
+
|
12
17
|
XML_ROOT_TAG = "ietf-standard".freeze
|
13
18
|
XML_NAMESPACE = "https://www.metanorma.org/ns/ietf".freeze
|
14
19
|
|
@@ -113,70 +118,7 @@ module Asciidoctor
|
|
113
118
|
[t, rel]
|
114
119
|
end
|
115
120
|
|
116
|
-
def
|
117
|
-
bcp14_cleanup(xmldoc)
|
118
|
-
abstract_cleanup(xmldoc)
|
119
|
-
super
|
120
|
-
rfc_anchor_cleanup(xmldoc)
|
121
|
-
end
|
122
|
-
|
123
|
-
BCP_KEYWORDS = ["MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
|
124
|
-
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", "OPTIONAL"].freeze
|
125
|
-
|
126
|
-
def abstract_cleanup(xmldoc)
|
127
|
-
xmldoc.xpath("//abstract[not(text())]").each do |x|
|
128
|
-
x.remove
|
129
|
-
warn "Empty abstract section removed"
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
def bcp14_cleanup(xmldoc)
|
134
|
-
return unless @bcp_bold
|
135
|
-
xmldoc.xpath("//strong").each do |s|
|
136
|
-
next unless BCP_KEYWORDS.include?(s.text)
|
137
|
-
s.name = "bcp14"
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
def rfc_anchor_cleanup(xmldoc)
|
142
|
-
map = {}
|
143
|
-
xmldoc.xpath("//bibitem[docidentifier/@type = 'rfc-anchor']").each do |b|
|
144
|
-
next if b.at("./ancestor::bibdata | ./ancestor::bibitem")
|
145
|
-
|
146
|
-
map[b["id"]] = b.at("./docidentifier[@type = 'rfc-anchor']").text
|
147
|
-
b["id"] = b.at("./docidentifier[@type = 'rfc-anchor']").text
|
148
|
-
end
|
149
|
-
xmldoc.xpath("//eref | //origin").each do |x|
|
150
|
-
map[x["bibitemid"]] and x["bibitemid"] = map[x["bibitemid"]]
|
151
|
-
end
|
152
|
-
xmldoc
|
153
|
-
end
|
154
|
-
|
155
|
-
def smartquotes_cleanup(xmldoc)
|
156
|
-
xmldoc.traverse do |n|
|
157
|
-
next unless n.text?
|
158
|
-
n.replace(HTMLEntities.new.encode(
|
159
|
-
n.text.gsub(/\u2019|\u2018|\u201a|\u201b/, "'").
|
160
|
-
gsub(/\u201c|\u201d|\u201e|\u201f/, '"'), :basic))
|
161
|
-
end
|
162
|
-
xmldoc
|
163
|
-
end
|
164
|
-
|
165
|
-
def xref_to_eref(x)
|
166
|
-
super
|
167
|
-
x.delete("format")
|
168
|
-
end
|
169
|
-
|
170
|
-
def xref_cleanup(xmldoc)
|
171
|
-
super
|
172
|
-
xmldoc.xpath("//xref").each do |x|
|
173
|
-
x.delete("displayFormat")
|
174
|
-
x.delete("relative")
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
def norm_ref_preface(f)
|
179
|
-
end
|
121
|
+
def norm_ref_preface(sect); end
|
180
122
|
|
181
123
|
def clause_parse(attrs, xml, node)
|
182
124
|
attrs[:numbered] = node.attr("numbered")
|
@@ -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>
|
@@ -976,6 +990,16 @@
|
|
976
990
|
<data type="boolean"/>
|
977
991
|
</attribute>
|
978
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>
|
979
1003
|
<optional>
|
980
1004
|
<element name="refterm">
|
981
1005
|
<zeroOrMore>
|
@@ -1011,8 +1035,23 @@
|
|
1011
1035
|
<ref name="imagemap"/>
|
1012
1036
|
<ref name="svgmap"/>
|
1013
1037
|
<ref name="inputform"/>
|
1038
|
+
<ref name="toc"/>
|
1039
|
+
<ref name="passthrough"/>
|
1014
1040
|
</choice>
|
1015
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>
|
1016
1055
|
<define name="inputform">
|
1017
1056
|
<element name="form">
|
1018
1057
|
<attribute name="id">
|
@@ -1254,6 +1293,12 @@
|
|
1254
1293
|
<optional>
|
1255
1294
|
<attribute name="type"/>
|
1256
1295
|
</optional>
|
1296
|
+
<optional>
|
1297
|
+
<attribute name="identifier"/>
|
1298
|
+
</optional>
|
1299
|
+
<optional>
|
1300
|
+
<attribute name="prefix"/>
|
1301
|
+
</optional>
|
1257
1302
|
<text/>
|
1258
1303
|
</define>
|
1259
1304
|
<define name="ics">
|
@@ -1674,7 +1719,9 @@
|
|
1674
1719
|
<zeroOrMore>
|
1675
1720
|
<ref name="termgrammar"/>
|
1676
1721
|
</zeroOrMore>
|
1677
|
-
<
|
1722
|
+
<oneOrMore>
|
1723
|
+
<ref name="termdefinition"/>
|
1724
|
+
</oneOrMore>
|
1678
1725
|
<zeroOrMore>
|
1679
1726
|
<ref name="termnote"/>
|
1680
1727
|
</zeroOrMore>
|
@@ -1737,7 +1784,7 @@
|
|
1737
1784
|
</oneOrMore>
|
1738
1785
|
</element>
|
1739
1786
|
</define>
|
1740
|
-
<define name="
|
1787
|
+
<define name="termdefinition">
|
1741
1788
|
<element name="definition">
|
1742
1789
|
<oneOrMore>
|
1743
1790
|
<choice>
|
@@ -1746,6 +1793,9 @@
|
|
1746
1793
|
<ref name="formula"/>
|
1747
1794
|
</choice>
|
1748
1795
|
</oneOrMore>
|
1796
|
+
<zeroOrMore>
|
1797
|
+
<ref name="termsource"/>
|
1798
|
+
</zeroOrMore>
|
1749
1799
|
</element>
|
1750
1800
|
</define>
|
1751
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
|