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
data/lib/isodoc/ietf/inline.rb
CHANGED
@@ -1,167 +1,170 @@
|
|
1
1
|
require "mathml2asciimath"
|
2
2
|
|
3
|
-
module IsoDoc
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
module IsoDoc
|
4
|
+
module Ietf
|
5
|
+
class RfcConvert < ::IsoDoc::Convert
|
6
|
+
def em_parse(node, out)
|
7
|
+
out.em do |e|
|
8
|
+
node.children.each { |n| parse(n, e) }
|
9
|
+
end
|
8
10
|
end
|
9
|
-
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
def sup_parse(node, out)
|
13
|
+
out.sup do |e|
|
14
|
+
node.children.each { |n| parse(n, e) }
|
15
|
+
end
|
14
16
|
end
|
15
|
-
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
def sub_parse(node, out)
|
19
|
+
out.sub do |e|
|
20
|
+
node.children.each { |n| parse(n, e) }
|
21
|
+
end
|
20
22
|
end
|
21
|
-
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
def tt_parse(node, out)
|
25
|
+
out.tt do |e|
|
26
|
+
node.children.each { |n| parse(n, e) }
|
27
|
+
end
|
26
28
|
end
|
27
|
-
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
def strong_parse(node, out)
|
31
|
+
out.strong do |e|
|
32
|
+
node.children.each { |n| parse(n, e) }
|
33
|
+
end
|
32
34
|
end
|
33
|
-
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
def bcp14_parse(node, out)
|
37
|
+
out.bcp14 do |e|
|
38
|
+
node.children.each { |n| parse(n, e) }
|
39
|
+
end
|
38
40
|
end
|
39
|
-
end
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
def strike_parse(node, out)
|
43
|
+
node.children.each { |n| parse(n, out) }
|
44
|
+
end
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
def smallcap_parse(node, out)
|
47
|
+
node.children.each { |n| parse(n, out) }
|
48
|
+
end
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
def keyword_parse(node, out)
|
51
|
+
node.children.each { |n| parse(n, out) }
|
52
|
+
end
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
text = node.to_s
|
56
|
-
out << text
|
57
|
-
end
|
54
|
+
def text_parse(node, out)
|
55
|
+
return if node.nil? || node.text.nil?
|
58
56
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
else
|
63
|
-
HTMLEntities.new.encode(node.text)
|
64
|
-
end
|
65
|
-
out << "#{@openmathdelim} #{stem} #{@closemathdelim}"
|
66
|
-
end
|
57
|
+
text = node.to_s
|
58
|
+
out << text
|
59
|
+
end
|
67
60
|
|
68
|
-
|
69
|
-
|
61
|
+
def stem_parse(node, out)
|
62
|
+
stem = case node["type"]
|
63
|
+
when "MathML" then MathML2AsciiMath.m2a(node.children.to_xml)
|
64
|
+
else HTMLEntities.new.encode(node.text)
|
65
|
+
end
|
66
|
+
out << "#{@openmathdelim} #{stem} #{@closemathdelim}"
|
67
|
+
end
|
70
68
|
|
71
|
-
|
72
|
-
end
|
69
|
+
def page_break(_out); end
|
73
70
|
|
74
|
-
|
75
|
-
|
71
|
+
def pagebreak_parse(_node, _out); end
|
72
|
+
|
73
|
+
def br_parse(_node, out)
|
76
74
|
out.br
|
77
75
|
end
|
78
|
-
end
|
79
76
|
|
80
|
-
|
81
|
-
end
|
77
|
+
def hr_parse(node, out); end
|
82
78
|
|
83
|
-
|
84
|
-
|
85
|
-
|
79
|
+
def link_parse(node, out)
|
80
|
+
out.eref **attr_code(target: node["target"]) do |l|
|
81
|
+
node.children.each { |n| parse(n, l) }
|
82
|
+
end
|
86
83
|
end
|
87
|
-
end
|
88
84
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
85
|
+
def image_parse(node, out, caption)
|
86
|
+
attrs = { src: node["src"], title: node["title"],
|
87
|
+
align: node["align"], name: node["filename"],
|
88
|
+
anchor: node["id"], type: "svg",
|
89
|
+
alt: node["alt"] }
|
90
|
+
out.artwork **attr_code(attrs)
|
91
|
+
image_title_parse(out, caption)
|
92
|
+
end
|
97
93
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
94
|
+
def image_title_parse(out, caption)
|
95
|
+
unless caption.nil?
|
96
|
+
out.t **{ align: "center", keepWithPrevious: "true" } do |p|
|
97
|
+
p << caption.to_s
|
98
|
+
end
|
102
99
|
end
|
103
100
|
end
|
104
|
-
end
|
105
101
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
102
|
+
def xref_parse(node, out)
|
103
|
+
out.xref **attr_code(target: node["target"], format: node["format"],
|
104
|
+
relative: node["relative"]) do |l|
|
105
|
+
l << get_linkend(node)
|
106
|
+
end
|
107
|
+
end
|
112
108
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
109
|
+
def get_linkend(node)
|
110
|
+
contents = node.children.reject do |c|
|
111
|
+
%w{locality localityStack}.include? c.name
|
112
|
+
end
|
113
|
+
.select { |c| !c.text? || /\S/.match(c) }
|
114
|
+
!contents.empty? and
|
115
|
+
return Nokogiri::XML::NodeSet.new(node.document, contents).to_xml
|
116
|
+
""
|
117
|
+
end
|
120
118
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
119
|
+
def eref_parse(node, out)
|
120
|
+
linkend = node.children.reject do |c|
|
121
|
+
%w{locality localityStack}.include? c.name
|
122
|
+
end
|
123
|
+
relative = node["relative"] ||
|
124
|
+
node.at(ns(".//locality[@type = 'anchor']/referenceFrom"))&.text || ""
|
125
|
+
section = eref_clause(node.xpath(ns("./locality | ./localityStack")),
|
126
|
+
nil) || ""
|
127
|
+
#section = "" unless relative.empty?
|
128
|
+
out.relref **attr_code(target: node["bibitemid"], section: section,
|
129
|
+
relative: relative,
|
130
|
+
displayFormat: node["displayFormat"]) do |l|
|
131
|
+
linkend.each { |n| parse(n, l) }
|
132
|
+
end
|
133
|
+
end
|
133
134
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
135
|
+
def eref_clause(refs, target)
|
136
|
+
ret = []
|
137
|
+
ret1 = ""
|
138
|
+
refs.each do |l|
|
139
|
+
if l.name == "localityStack"
|
140
|
+
ret << ret1
|
141
|
+
ret1 = ""
|
142
|
+
ret << eref_clause1(l.elements, target)
|
143
|
+
else ret1 += eref_clause1([l], target)
|
144
|
+
end
|
144
145
|
end
|
146
|
+
ret << ret1
|
147
|
+
ret.reject { |c| c.nil? || c.empty? }.join("; ")
|
145
148
|
end
|
146
|
-
ret << ret1
|
147
|
-
ret.reject { |c| c.nil? || c.empty? }.join("; ")
|
148
|
-
end
|
149
149
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
150
|
+
def eref_clause1(refs, _target)
|
151
|
+
refs.each do |l|
|
152
|
+
next unless %w(clause section).include? l["type"]
|
153
|
+
|
154
|
+
return l&.at(ns("./referenceFrom"))&.text
|
155
|
+
end
|
156
|
+
""
|
154
157
|
end
|
155
|
-
return ""
|
156
|
-
end
|
157
158
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
159
|
+
def index_parse(node, out)
|
160
|
+
out.iref nil, **attr_code(item: node.at(ns("./primary")).text,
|
161
|
+
primary: node["primary"],
|
162
|
+
subitem: node&.at(ns("./secondary"))&.text)
|
163
|
+
end
|
162
164
|
|
163
|
-
|
164
|
-
|
165
|
+
def bookmark_parse(node, out)
|
166
|
+
out.bookmark nil, **attr_code(anchor: node["id"])
|
167
|
+
end
|
165
168
|
end
|
166
169
|
end
|
167
170
|
end
|
@@ -55,15 +55,29 @@ module IsoDoc
|
|
55
55
|
uris&.each do |u|
|
56
56
|
r.format nil, **attr_code(target: u.text, type: u["type"])
|
57
57
|
end
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
58
|
+
docidentifier_render(bib, r)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def docidentifier_render(bib, out)
|
63
|
+
docidentifiers = bib.xpath(ns("./docidentifier"))
|
64
|
+
id = render_identifier(bibitem_ref_code(bib))
|
65
|
+
!id[1].nil? && id[1] != "(NO ID)" and out.refcontent id[1]
|
66
|
+
docidentifiers&.each do |u|
|
67
|
+
u["type"] == "DOI" and
|
68
|
+
out.seriesInfo nil, **attr_code(value: u.text.sub(/^DOI /, ""),
|
69
|
+
name: "DOI")
|
70
|
+
u["type"] == "IETF" and docidentifier_ietf(u, out)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def docidentifier_ietf(ident, out)
|
75
|
+
if /^RFC /.match?(ident.text)
|
76
|
+
out.seriesInfo nil, **attr_code(value: ident.text.sub(/^RFC 0*/, ""),
|
77
|
+
name: "RFC")
|
78
|
+
elsif /^I-D\./.match?(ident.text)
|
79
|
+
out.seriesInfo nil, **attr_code(value: ident.text.sub(/^I-D\./, ""),
|
80
|
+
name: "Internet-Draft")
|
67
81
|
end
|
68
82
|
end
|
69
83
|
|
data/lib/isodoc/ietf/reqt.rb
CHANGED
@@ -1,79 +1,83 @@
|
|
1
|
-
module IsoDoc
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
def recommendation_name(node, out, type)
|
9
|
-
label, title, lbl = recommendation_labels(node)
|
10
|
-
out.t **{ keepWithNext: "true" } do |b|
|
11
|
-
b << (lbl.nil? ? l10n("#{type}:") : l10n("#{type} #{lbl}:"))
|
1
|
+
module IsoDoc
|
2
|
+
module Ietf
|
3
|
+
class RfcConvert < ::IsoDoc::Convert
|
4
|
+
def recommendation_labels(node)
|
5
|
+
[node.at(ns("./label")), node.at(ns("./title")),
|
6
|
+
@xrefs.anchor(node["id"], :label, false)]
|
12
7
|
end
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
8
|
+
|
9
|
+
def recommendation_name(node, out, type)
|
10
|
+
label, title, lbl = recommendation_labels(node)
|
11
|
+
out.t **{ keepWithNext: "true" } do |b|
|
12
|
+
b << (lbl.nil? ? l10n("#{type}:") : l10n("#{type} #{lbl}:"))
|
13
|
+
end
|
14
|
+
if label || title
|
15
|
+
out.t **{ keepWithNext: "true" } do |b|
|
16
|
+
label and label.children.each { |n| parse(n, b) }
|
17
|
+
b << "#{clausedelim} " if label && title
|
18
|
+
title and title.children.each { |n| parse(n, b) }
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
20
|
-
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
def recommendation_attributes(node, out)
|
24
|
+
ret = recommendation_attributes1(node)
|
25
|
+
return if ret.empty?
|
26
|
+
|
27
|
+
out.ul do |p|
|
28
|
+
ret.each do |l|
|
29
|
+
p.li do |i|
|
30
|
+
i.em { |_e| i << l }
|
31
|
+
end
|
29
32
|
end
|
30
33
|
end
|
31
34
|
end
|
32
|
-
end
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
def recommendation_parse(node, out)
|
37
|
+
recommendation_name(node, out, @i18n.recommendation)
|
38
|
+
recommendation_attributes(node, out)
|
39
|
+
node.children.each do |n|
|
40
|
+
parse(n, out) unless %w(label title).include? n.name
|
41
|
+
end
|
39
42
|
end
|
40
|
-
end
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
def requirement_parse(node, out)
|
45
|
+
recommendation_name(node, out, @i18n.requirement)
|
46
|
+
recommendation_attributes(node, out)
|
47
|
+
node.children.each do |n|
|
48
|
+
parse(n, out) unless %w(label title).include? n.name
|
49
|
+
end
|
47
50
|
end
|
48
|
-
end
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
def permission_parse(node, out)
|
53
|
+
recommendation_name(node, out, @i18n.permission)
|
54
|
+
recommendation_attributes(node, out)
|
55
|
+
node.children.each do |n|
|
56
|
+
parse(n, out) unless %w(label title).include? n.name
|
57
|
+
end
|
55
58
|
end
|
56
|
-
end
|
57
59
|
|
58
|
-
|
59
|
-
|
60
|
-
%w(em link eref xref strong tt sup sub strike keyword smallcap
|
61
|
-
br hr bookmark pagebreak stem origin term preferred admitted
|
62
|
-
deprecates domain termsource modification).include? node.first_element_child.name
|
63
|
-
end
|
60
|
+
def inline?(node)
|
61
|
+
return true if node.first_element_child.nil?
|
64
62
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
63
|
+
%w(em link eref xref strong tt sup sub strike keyword smallcap
|
64
|
+
br hr bookmark pagebreak stem origin term preferred admitted
|
65
|
+
deprecates domain termsource modification)
|
66
|
+
.include? node.first_element_child.name
|
67
|
+
end
|
68
|
+
|
69
|
+
def requirement_component_parse(node, out)
|
70
|
+
return if node["exclude"] == "true"
|
71
|
+
|
72
|
+
if inline?(node)
|
73
|
+
out.t do |p|
|
74
|
+
p << "INHERIT: " if node.name == "inherit"
|
75
|
+
node.children.each { |n| parse(n, p) }
|
76
|
+
end
|
77
|
+
else
|
78
|
+
node.children.each { |n| parse(n, out) }
|
72
79
|
end
|
73
|
-
else
|
74
|
-
node.children.each { |n| parse(n, out) }
|
75
80
|
end
|
76
81
|
end
|
77
82
|
end
|
78
83
|
end
|
79
|
-
|
@@ -52,6 +52,8 @@ module IsoDoc::Ietf
|
|
52
52
|
case node.name
|
53
53
|
when "bcp14" then bcp14_parse(node, out)
|
54
54
|
when "concept" then concept_parse(node, out)
|
55
|
+
when "verbaldefinition", "nonverbalrepresentation"
|
56
|
+
node.elements.each { |n| parse(n, out) }
|
55
57
|
else
|
56
58
|
text = node.to_xml.gsub(/</, "<").gsub(/>/, ">")
|
57
59
|
out.t { |p| p << text }
|
data/lib/isodoc/ietf/terms.rb
CHANGED
@@ -1,63 +1,70 @@
|
|
1
|
-
module IsoDoc
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
module IsoDoc
|
2
|
+
module Ietf
|
3
|
+
class RfcConvert < ::IsoDoc::Convert
|
4
|
+
def definition_parse(node, out)
|
5
|
+
node.children.each { |n| parse(n, out) }
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
def modification_parse(node, out)
|
9
|
+
para = node.at(ns("./p"))
|
10
|
+
out << " -- "
|
11
|
+
para.children.each { |n| parse(n, out) }
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
def deprecated_term_parse(node, out)
|
15
|
+
name = node.at(ns(".//name"))
|
16
|
+
out.t do |p|
|
17
|
+
p << l10n("#{@i18n.deprecated}: ")
|
18
|
+
name.children.each { |c| parse(c, p) }
|
19
|
+
end
|
17
20
|
end
|
18
|
-
end
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
def admitted_term_parse(node, out)
|
23
|
+
name = node.at(ns(".//name"))
|
24
|
+
out.t do |p|
|
25
|
+
name.children.each { |c| parse(c, p) }
|
26
|
+
end
|
23
27
|
end
|
24
|
-
end
|
25
28
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
+
def term_parse(node, out)
|
30
|
+
name = node.at(ns(".//name"))
|
31
|
+
out.name do |p|
|
32
|
+
name.children.each { |n| parse(n, p) }
|
33
|
+
end
|
29
34
|
end
|
30
|
-
end
|
31
35
|
|
32
|
-
|
33
|
-
|
34
|
-
|
36
|
+
def termnote_parse(node, out)
|
37
|
+
note_parse(node, out)
|
38
|
+
end
|
35
39
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
+
def termref_parse(node, out)
|
41
|
+
out.t do |p|
|
42
|
+
p << "SOURCE: "
|
43
|
+
node.children.each { |n| parse(n, p) }
|
44
|
+
end
|
40
45
|
end
|
41
|
-
end
|
42
46
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
+
def termdef_parse(node, out)
|
48
|
+
set_termdomain("")
|
49
|
+
node.xpath(ns("./definition")).size > 1 and
|
50
|
+
IsoDoc::PresentationXMLConvert.new({}).multidef(node)
|
51
|
+
clause_parse(node, out)
|
52
|
+
end
|
47
53
|
|
48
|
-
|
54
|
+
def termdocsource_parse(_node, _out); end
|
49
55
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
56
|
+
def concept_parse(node, out)
|
57
|
+
if d = node.at(ns("./renderterm"))
|
58
|
+
out.em do |em|
|
59
|
+
d.children.each { |n| parse(n, em) }
|
60
|
+
end
|
61
|
+
out << " "
|
54
62
|
end
|
55
|
-
out << " "
|
63
|
+
out << "[term defined in "
|
64
|
+
r = node.at(ns("./xref | ./eref | ./termref"))
|
65
|
+
parse(r, out)
|
66
|
+
out << "]"
|
56
67
|
end
|
57
|
-
out << "[term defined in "
|
58
|
-
r = node.at(ns("./xref | ./eref | ./termref"))
|
59
|
-
parse(r, out)
|
60
|
-
out << "]"
|
61
68
|
end
|
62
69
|
end
|
63
70
|
end
|
@@ -165,7 +165,7 @@ module IsoDoc
|
|
165
165
|
def seriesInfo_check(xml)
|
166
166
|
ret = []
|
167
167
|
xml.root["ipr"] == "none" and return []
|
168
|
-
rfcinfo = xml.at("//seriesInfo[@name = 'RFC']")
|
168
|
+
rfcinfo = xml.at("//front//seriesInfo[@name = 'RFC']")
|
169
169
|
rfcnumber = xml.root["number"]
|
170
170
|
rfcinfo && rfcnumber && rfcnumber != rfcinfo["value"] and
|
171
171
|
ret << "Mismatch between <rfc number='#{rfcnumber}'> "\
|
data/metanorma-ietf.gemspec
CHANGED
@@ -35,11 +35,9 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.require_paths = ["lib"]
|
36
36
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
37
37
|
|
38
|
-
spec.add_dependency "isodoc", "~> 1.7.0"
|
39
38
|
spec.add_dependency "mathml2asciimath"
|
40
|
-
spec.add_dependency "metanorma-standoc", "~> 1.10.0"
|
41
39
|
spec.add_dependency "metanorma-ietf-data"
|
42
|
-
spec.add_dependency "
|
40
|
+
spec.add_dependency "metanorma-standoc", "~> 1.11.0"
|
43
41
|
spec.add_dependency "open-uri"
|
44
42
|
|
45
43
|
spec.add_development_dependency "byebug"
|