metanorma-ietf 2.4.1 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/asciidoctor/ietf/basicdoc.rng +21 -4
- data/lib/asciidoctor/ietf/cleanup.rb +29 -6
- data/lib/asciidoctor/ietf/converter.rb +6 -64
- data/lib/asciidoctor/ietf/ietf.rng +13 -25
- data/lib/asciidoctor/ietf/isodoc.rng +435 -78
- data/lib/asciidoctor/ietf/macros.rb +17 -0
- data/lib/asciidoctor/ietf/reqt.rng +23 -2
- data/lib/isodoc/ietf/blocks.rb +11 -10
- data/lib/isodoc/ietf/cleanup.rb +149 -186
- data/lib/isodoc/ietf/cleanup_inline.rb +76 -0
- data/lib/isodoc/ietf/inline.rb +127 -124
- data/lib/isodoc/ietf/references.rb +23 -9
- data/lib/isodoc/ietf/reqt.rb +63 -59
- data/lib/isodoc/ietf/rfc_convert.rb +2 -0
- data/lib/isodoc/ietf/terms.rb +52 -45
- data/lib/isodoc/ietf/validation.rb +1 -1
- data/lib/metanorma/ietf/version.rb +1 -1
- data/metanorma-ietf.gemspec +1 -3
- metadata +8 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a36096d484f0abebdb0aac35196a9f8975f7d5704851d3209d133e9901b1b82
|
4
|
+
data.tar.gz: 1fbef89a62eddc130fdf1c99367fae06c29369206f11bcbef9c24e1c1ab07c3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ecdee7ac6dd34da6fe68e4613233b352b6eb1fa35ddec7a7f427b1dcce3bf09d8d5672f37efef8aac10f8e6cbf81c7d2f6466818db0a2fbae27676202c57dff
|
7
|
+
data.tar.gz: f914bccab27c70cbf81281aa0475896190e578bdd09a00072f8802d03903cca7b814bde12d214bfa01d43a95b218a9c1f13312877f6736dad9bf80f2c171253f
|
@@ -624,6 +624,9 @@
|
|
624
624
|
<choice>
|
625
625
|
<ref name="PureTextElement"/>
|
626
626
|
<ref name="stem"/>
|
627
|
+
<ref name="eref"/>
|
628
|
+
<ref name="xref"/>
|
629
|
+
<ref name="hyperlink"/>
|
627
630
|
</choice>
|
628
631
|
</zeroOrMore>
|
629
632
|
</element>
|
@@ -634,6 +637,9 @@
|
|
634
637
|
<choice>
|
635
638
|
<ref name="PureTextElement"/>
|
636
639
|
<ref name="stem"/>
|
640
|
+
<ref name="eref"/>
|
641
|
+
<ref name="xref"/>
|
642
|
+
<ref name="hyperlink"/>
|
637
643
|
</choice>
|
638
644
|
</zeroOrMore>
|
639
645
|
</element>
|
@@ -641,7 +647,12 @@
|
|
641
647
|
<define name="tt">
|
642
648
|
<element name="tt">
|
643
649
|
<zeroOrMore>
|
644
|
-
<
|
650
|
+
<choice>
|
651
|
+
<ref name="PureTextElement"/>
|
652
|
+
<ref name="eref"/>
|
653
|
+
<ref name="xref"/>
|
654
|
+
<ref name="hyperlink"/>
|
655
|
+
</choice>
|
645
656
|
</zeroOrMore>
|
646
657
|
</element>
|
647
658
|
</define>
|
@@ -822,7 +833,9 @@
|
|
822
833
|
<attribute name="alt"/>
|
823
834
|
</optional>
|
824
835
|
<ref name="CitationType"/>
|
825
|
-
<
|
836
|
+
<oneOrMore>
|
837
|
+
<ref name="PureTextElement"/>
|
838
|
+
</oneOrMore>
|
826
839
|
</define>
|
827
840
|
<define name="hyperlink">
|
828
841
|
<element name="link">
|
@@ -835,7 +848,9 @@
|
|
835
848
|
<optional>
|
836
849
|
<attribute name="alt"/>
|
837
850
|
</optional>
|
838
|
-
<
|
851
|
+
<oneOrMore>
|
852
|
+
<ref name="PureTextElement"/>
|
853
|
+
</oneOrMore>
|
839
854
|
</element>
|
840
855
|
</define>
|
841
856
|
<define name="xref">
|
@@ -849,7 +864,9 @@
|
|
849
864
|
<optional>
|
850
865
|
<attribute name="alt"/>
|
851
866
|
</optional>
|
852
|
-
<
|
867
|
+
<oneOrMore>
|
868
|
+
<ref name="PureTextElement"/>
|
869
|
+
</oneOrMore>
|
853
870
|
</element>
|
854
871
|
</define>
|
855
872
|
<define name="fn">
|
@@ -6,6 +6,8 @@ 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
13
|
def abstract_cleanup(xmldoc)
|
@@ -15,6 +17,21 @@ module Asciidoctor
|
|
15
17
|
end
|
16
18
|
end
|
17
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
|
+
|
18
35
|
def bcp14_cleanup(xmldoc)
|
19
36
|
return unless @bcp_bold
|
20
37
|
|
@@ -26,12 +43,13 @@ module Asciidoctor
|
|
26
43
|
end
|
27
44
|
|
28
45
|
def rfc_anchor_cleanup(xmldoc)
|
29
|
-
map =
|
30
|
-
|
31
|
-
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")
|
32
49
|
|
33
|
-
|
34
|
-
b["id"] =
|
50
|
+
id = b.at("./docidentifier[@type = 'rfc-anchor']").text
|
51
|
+
m[b["id"]] = id
|
52
|
+
b["id"] = id
|
35
53
|
end
|
36
54
|
xmldoc.xpath("//eref | //origin").each do |x|
|
37
55
|
map[x["bibitemid"]] and x["bibitemid"] = map[x["bibitemid"]]
|
@@ -45,7 +63,12 @@ module Asciidoctor
|
|
45
63
|
|
46
64
|
n.replace(HTMLEntities.new.encode(
|
47
65
|
n.text.gsub(/\u2019|\u2018|\u201a|\u201b/, "'")
|
48
|
-
.gsub(/\u201c|\u201d|\u201e|\u201f/, '"')
|
66
|
+
.gsub(/\u201c|\u201d|\u201e|\u201f/, '"')
|
67
|
+
.gsub(/[\u2010-\u2015]/, "-")
|
68
|
+
.gsub(/\u2026/, "...")
|
69
|
+
.gsub(/[\u200b-\u200c]/, "")
|
70
|
+
.gsub(/[\u2000-\u200a]|\u202f|\u205f/, " "),
|
71
|
+
:basic,
|
49
72
|
))
|
50
73
|
end
|
51
74
|
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")
|
@@ -459,14 +459,9 @@
|
|
459
459
|
<ref name="section-title"/>
|
460
460
|
</optional>
|
461
461
|
<group>
|
462
|
-
<
|
463
|
-
<
|
464
|
-
|
465
|
-
</zeroOrMore>
|
466
|
-
<zeroOrMore>
|
467
|
-
<ref name="note"/>
|
468
|
-
</zeroOrMore>
|
469
|
-
</group>
|
462
|
+
<zeroOrMore>
|
463
|
+
<ref name="BasicBlock"/>
|
464
|
+
</zeroOrMore>
|
470
465
|
<zeroOrMore>
|
471
466
|
<choice>
|
472
467
|
<ref name="clause-subsection"/>
|
@@ -508,14 +503,9 @@
|
|
508
503
|
<ref name="section-title"/>
|
509
504
|
</optional>
|
510
505
|
<group>
|
511
|
-
<
|
512
|
-
<
|
513
|
-
|
514
|
-
</zeroOrMore>
|
515
|
-
<zeroOrMore>
|
516
|
-
<ref name="note"/>
|
517
|
-
</zeroOrMore>
|
518
|
-
</group>
|
506
|
+
<zeroOrMore>
|
507
|
+
<ref name="BasicBlock"/>
|
508
|
+
</zeroOrMore>
|
519
509
|
<zeroOrMore>
|
520
510
|
<ref name="clause-subsection"/>
|
521
511
|
</zeroOrMore>
|
@@ -547,14 +537,9 @@
|
|
547
537
|
<ref name="section-title"/>
|
548
538
|
</optional>
|
549
539
|
<group>
|
550
|
-
<
|
551
|
-
<
|
552
|
-
|
553
|
-
</zeroOrMore>
|
554
|
-
<zeroOrMore>
|
555
|
-
<ref name="note"/>
|
556
|
-
</zeroOrMore>
|
557
|
-
</group>
|
540
|
+
<zeroOrMore>
|
541
|
+
<ref name="BasicBlock"/>
|
542
|
+
</zeroOrMore>
|
558
543
|
<zeroOrMore>
|
559
544
|
<ref name="content-subsection"/>
|
560
545
|
</zeroOrMore>
|
@@ -602,7 +587,10 @@
|
|
602
587
|
</define>
|
603
588
|
</include>
|
604
589
|
<define name="TextElement" combine="choice">
|
605
|
-
<
|
590
|
+
<choice>
|
591
|
+
<ref name="bcp14"/>
|
592
|
+
<ref name="review"/>
|
593
|
+
</choice>
|
606
594
|
</define>
|
607
595
|
<define name="bcp14">
|
608
596
|
<element name="bcp14">
|