metanorma-ietf 2.2.7 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +10 -26
- data/.gitignore +2 -0
- data/.rubocop.yml +5 -6
- data/lib/asciidoctor/ietf/basicdoc.rng +5 -3
- data/lib/asciidoctor/ietf/biblio.rng +4 -6
- data/lib/asciidoctor/ietf/blocks.rb +6 -6
- data/lib/asciidoctor/ietf/converter.rb +20 -0
- data/lib/asciidoctor/ietf/front.rb +4 -4
- data/lib/asciidoctor/ietf/ietf.rng +39 -0
- data/lib/asciidoctor/ietf/isodoc.rng +238 -3
- data/lib/isodoc/ietf/blocks.rb +17 -15
- data/lib/isodoc/ietf/cleanup.rb +22 -25
- data/lib/isodoc/ietf/front.rb +1 -0
- data/lib/isodoc/ietf/inline.rb +1 -1
- data/lib/isodoc/ietf/rfc_convert.rb +10 -5
- data/lib/metanorma/ietf/version.rb +1 -1
- data/metanorma-ietf.gemspec +6 -5
- metadata +32 -20
- data/.rubocop.ribose.yml +0 -65
- data/.rubocop.tb.yml +0 -650
data/lib/isodoc/ietf/blocks.rb
CHANGED
@@ -43,7 +43,7 @@ module IsoDoc::Ietf
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def ol_attrs(node)
|
46
|
-
{ anchor: node["id"],
|
46
|
+
{ anchor: node["id"],
|
47
47
|
spacing: node["spacing"],
|
48
48
|
type: ol_style(node["type"]),
|
49
49
|
group: node["group"],
|
@@ -73,7 +73,9 @@ module IsoDoc::Ietf
|
|
73
73
|
|
74
74
|
def note_label(node)
|
75
75
|
n = @xrefs.get[node["id"]]
|
76
|
-
return l10n("#{@i18n.note}: ") if n.nil? || n[:label].nil? ||
|
76
|
+
return l10n("#{@i18n.note}: ") if n.nil? || n[:label].nil? ||
|
77
|
+
n[:label].empty?
|
78
|
+
|
77
79
|
l10n("#{@i18n.note} #{n[:label]}: ")
|
78
80
|
end
|
79
81
|
|
@@ -98,7 +100,7 @@ module IsoDoc::Ietf
|
|
98
100
|
def example_label(node, div, name)
|
99
101
|
n = @xrefs.get[node["id"]]
|
100
102
|
div.t **attr_code(anchor: node["id"], keepWithNext: "true") do |p|
|
101
|
-
lbl =
|
103
|
+
lbl = n.nil? || n[:label].nil? || n[:label].empty? ? @i18n.example :
|
102
104
|
l10n("#{@i18n.example} #{n[:label]}")
|
103
105
|
p << lbl
|
104
106
|
name and !lbl.nil? and p << ": "
|
@@ -107,15 +109,11 @@ module IsoDoc::Ietf
|
|
107
109
|
end
|
108
110
|
|
109
111
|
def sourcecode_parse(node, out)
|
110
|
-
out.
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
markers: node["markers"],
|
116
|
-
src: node["src"]) do |s|
|
117
|
-
node.children.each { |x| parse(x, s) unless x.name == "name" }
|
118
|
-
end
|
112
|
+
out.sourcecode **attr_code(
|
113
|
+
anchor: node["id"], type: node["lang"], name: node["filename"],
|
114
|
+
markers: node["markers"], src: node["src"]
|
115
|
+
) do |s|
|
116
|
+
node.children.each { |x| parse(x, s) unless x.name == "name" }
|
119
117
|
end
|
120
118
|
end
|
121
119
|
|
@@ -139,6 +137,7 @@ module IsoDoc::Ietf
|
|
139
137
|
|
140
138
|
def formula_where(dl, out)
|
141
139
|
return unless dl
|
140
|
+
|
142
141
|
out.t { |p| p << @i18n.where }
|
143
142
|
parse(dl, out)
|
144
143
|
end
|
@@ -146,7 +145,7 @@ module IsoDoc::Ietf
|
|
146
145
|
def formula_parse1(node, out)
|
147
146
|
out.t **attr_code(anchor: node["id"]) do |p|
|
148
147
|
parse(node.at(ns("./stem")), p)
|
149
|
-
lbl = @xrefs.anchor(node[
|
148
|
+
lbl = @xrefs.anchor(node["id"], :label, false)
|
150
149
|
lbl.nil? or
|
151
150
|
p << " (#{lbl})"
|
152
151
|
end
|
@@ -157,6 +156,7 @@ module IsoDoc::Ietf
|
|
157
156
|
formula_where(node.at(ns("./dl")), out)
|
158
157
|
node.children.each do |n|
|
159
158
|
next if %w(stem dl).include? n.name
|
159
|
+
|
160
160
|
parse(n, out)
|
161
161
|
end
|
162
162
|
end
|
@@ -176,7 +176,7 @@ module IsoDoc::Ietf
|
|
176
176
|
end
|
177
177
|
|
178
178
|
def admonition_name_parse(_node, div, name)
|
179
|
-
div.t **{keepWithNext: "true" } do |p|
|
179
|
+
div.t **{ keepWithNext: "true" } do |p|
|
180
180
|
name.children.each { |n| parse(n, p) }
|
181
181
|
end
|
182
182
|
end
|
@@ -200,8 +200,9 @@ module IsoDoc::Ietf
|
|
200
200
|
end
|
201
201
|
end
|
202
202
|
|
203
|
-
def figure_name_parse(
|
203
|
+
def figure_name_parse(_node, div, name)
|
204
204
|
return if name.nil?
|
205
|
+
|
205
206
|
div.name do |n|
|
206
207
|
name.children.each { |n| parse(n, div) }
|
207
208
|
end
|
@@ -214,6 +215,7 @@ module IsoDoc::Ietf
|
|
214
215
|
def figure_parse(node, out)
|
215
216
|
return pseudocode_parse(node, out) if node["class"] == "pseudocode" ||
|
216
217
|
node["type"] == "pseudocode"
|
218
|
+
|
217
219
|
@in_figure = true
|
218
220
|
out.figure **attr_code(anchor: node["id"]) do |div|
|
219
221
|
figure_name_parse(node, div, node.at(ns("./name")))
|
data/lib/isodoc/ietf/cleanup.rb
CHANGED
@@ -15,14 +15,14 @@ module IsoDoc::Ietf
|
|
15
15
|
end
|
16
16
|
|
17
17
|
# TODO: insert <u>
|
18
|
-
|
18
|
+
|
19
19
|
def front_cleanup(xmldoc)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
20
|
+
xmldoc.xpath("//title").each { |s| s.children = s.text }
|
21
|
+
xmldoc.xpath("//reference/front[not(author)]").each do |f|
|
22
|
+
insert = f.at("./seriesInfo[last()]") || f.at("./title")
|
23
|
+
insert.next = "<author surname='Unknown'/>"
|
25
24
|
end
|
25
|
+
end
|
26
26
|
|
27
27
|
def table_footnote_cleanup(docxml)
|
28
28
|
docxml.xpath("//table[descendant::fn]").each do |t|
|
@@ -46,25 +46,19 @@ module IsoDoc::Ietf
|
|
46
46
|
|
47
47
|
def figure_cleanup(docxml)
|
48
48
|
figure_postamble(docxml)
|
49
|
-
figure_wrap_artwork(docxml)
|
50
49
|
figure_unnest(docxml)
|
51
50
|
figure_footnote_cleanup(docxml)
|
52
51
|
end
|
53
52
|
|
54
|
-
def figure_wrap_artwork(docxml)
|
55
|
-
docxml.xpath("//artwork[not(parent::figure)] | "\
|
56
|
-
"//sourcecode[not(parent::figure)]").each do |a|
|
57
|
-
a.wrap("<figure></figure>")
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
53
|
def figure_unnest(docxml)
|
62
54
|
docxml.xpath("//figure[descendant::figure]").each do |f|
|
63
55
|
insert = f
|
64
56
|
f.xpath(".//figure").each do |a|
|
57
|
+
title = f.at("./name") and a.children.first.previous = title.remove
|
65
58
|
insert.next = a.remove
|
66
59
|
insert = insert.next_element
|
67
60
|
end
|
61
|
+
f.remove
|
68
62
|
end
|
69
63
|
end
|
70
64
|
|
@@ -134,8 +128,10 @@ module IsoDoc::Ietf
|
|
134
128
|
|
135
129
|
def make_endnotes(docxml)
|
136
130
|
return unless docxml.at("//fn")
|
137
|
-
|
138
|
-
|
131
|
+
|
132
|
+
unless endnotes = docxml.at("//back")
|
133
|
+
docxml << "<back/>" and endnotes = docxml.at("//back")
|
134
|
+
end
|
139
135
|
endnotes << "<section><name>Endnotes</name></section>"
|
140
136
|
endnotes = docxml.at("//back/section[last()]")
|
141
137
|
end
|
@@ -146,7 +142,7 @@ module IsoDoc::Ietf
|
|
146
142
|
t.xpath(".//artwork").each_with_index do |a, i|
|
147
143
|
insert.next = a.dup
|
148
144
|
insert = insert.next
|
149
|
-
a.replace("[IMAGE #{i+1}]")
|
145
|
+
a.replace("[IMAGE #{i + 1}]")
|
150
146
|
end
|
151
147
|
end
|
152
148
|
end
|
@@ -154,8 +150,8 @@ module IsoDoc::Ietf
|
|
154
150
|
# for markup in pseudocode
|
155
151
|
def sourcecode_cleanup(docxml)
|
156
152
|
docxml.xpath("//sourcecode").each do |s|
|
157
|
-
s.children = s.children.to_xml.gsub(%r{<br/>\n}, "\n")
|
158
|
-
gsub(%r{\s+(<t[ >])}, "\\1").gsub(%r{</t>\s+}, "</t>")
|
153
|
+
s.children = s.children.to_xml.gsub(%r{<br/>\n}, "\n")
|
154
|
+
.gsub(%r{\s+(<t[ >])}, "\\1").gsub(%r{</t>\s+}, "</t>")
|
159
155
|
sourcecode_remove_markup(s)
|
160
156
|
text = HTMLEntities.new.decode(s.children.to_xml.sub(/\A\n+/, ""))
|
161
157
|
s.children = "<![CDATA[#{text}]]>"
|
@@ -166,8 +162,10 @@ module IsoDoc::Ietf
|
|
166
162
|
s.traverse do |n|
|
167
163
|
next if n.text?
|
168
164
|
next if %w(name callout annotation note sourcecode).include? n.name
|
169
|
-
|
170
|
-
|
165
|
+
|
166
|
+
case n.name
|
167
|
+
when "br" then n.replace("\n")
|
168
|
+
when "t" then n.replace("\n\n#{n.children}")
|
171
169
|
else
|
172
170
|
n.replace(n.children)
|
173
171
|
end
|
@@ -177,6 +175,7 @@ module IsoDoc::Ietf
|
|
177
175
|
def annotation_cleanup(docxml)
|
178
176
|
docxml.xpath("//reference").each do |r|
|
179
177
|
next unless r&.next_element&.name == "aside"
|
178
|
+
|
180
179
|
aside = r.next_element
|
181
180
|
aside.name = "annotation"
|
182
181
|
aside.traverse do |n|
|
@@ -184,7 +183,7 @@ module IsoDoc::Ietf
|
|
184
183
|
end
|
185
184
|
r << aside
|
186
185
|
end
|
187
|
-
docxml.xpath("//references/aside").each
|
186
|
+
docxml.xpath("//references/aside").each(&:remove)
|
188
187
|
end
|
189
188
|
|
190
189
|
def deflist_cleanup(docxml)
|
@@ -211,9 +210,7 @@ module IsoDoc::Ietf
|
|
211
210
|
end
|
212
211
|
|
213
212
|
def bookmark_cleanup(docxml)
|
214
|
-
docxml.xpath("//bookmark").each
|
215
|
-
b.remove
|
216
|
-
end
|
213
|
+
docxml.xpath("//bookmark").each(&:remove)
|
217
214
|
end
|
218
215
|
|
219
216
|
def aside_cleanup(docxml)
|
data/lib/isodoc/ietf/front.rb
CHANGED
@@ -137,6 +137,7 @@ module IsoDoc::Ietf
|
|
137
137
|
def postal(addr, out)
|
138
138
|
out.postal do |p|
|
139
139
|
if line = addr.at(ns("./formattedAddress"))
|
140
|
+
line.xpath(ns(".//br")).each { |br| br.replace("\n") }
|
140
141
|
line.text.split(/\n/).each do |l|
|
141
142
|
p.postalLine l, **attr_code(ascii: l.transliterate)
|
142
143
|
end
|
data/lib/isodoc/ietf/inline.rb
CHANGED
@@ -156,7 +156,7 @@ module IsoDoc::Ietf
|
|
156
156
|
end
|
157
157
|
|
158
158
|
def index_parse(node, out)
|
159
|
-
out.iref nil, **attr_code(item: node.at(ns("./primary")).text,
|
159
|
+
out.iref nil, **attr_code(item: node.at(ns("./primary")).text, primary: node["primary"],
|
160
160
|
subitem: node&.at(ns("./secondary"))&.text)
|
161
161
|
end
|
162
162
|
|
@@ -26,7 +26,7 @@ module IsoDoc::Ietf
|
|
26
26
|
make_back(html, docxml)
|
27
27
|
end
|
28
28
|
end.join("\n").sub(/<!DOCTYPE[^>]+>\n/, "")
|
29
|
-
|
29
|
+
set_pis(docxml, Nokogiri::XML(xml))
|
30
30
|
end
|
31
31
|
|
32
32
|
def metadata_init(lang, script, i18n)
|
@@ -34,8 +34,8 @@ module IsoDoc::Ietf
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def xref_init(lang, script, klass, i18n, options)
|
37
|
-
|
38
|
-
|
37
|
+
@xrefs = Xref.new(lang, script, klass, i18n, options)
|
38
|
+
end
|
39
39
|
|
40
40
|
def extract_delims(text)
|
41
41
|
@openmathdelim = "$$"
|
@@ -57,9 +57,14 @@ module IsoDoc::Ietf
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
|
60
|
+
def omit_docid_prefix(prefix)
|
61
|
+
return true if prefix == "IETF"
|
62
|
+
super
|
63
|
+
end
|
64
|
+
|
65
|
+
def textcleanup(docxml)
|
61
66
|
passthrough_cleanup(docxml)
|
62
|
-
|
67
|
+
end
|
63
68
|
|
64
69
|
def postprocess(result, filename, _dir)
|
65
70
|
result = from_xhtml(cleanup(to_xhtml(textcleanup(result)))).
|
data/metanorma-ietf.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
lib = File.expand_path("
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
require "metanorma/ietf/version"
|
6
6
|
|
@@ -35,17 +35,18 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.require_paths = ["lib"]
|
36
36
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
37
37
|
|
38
|
-
spec.add_dependency "
|
39
|
-
spec.add_dependency "isodoc", "~> 1.4.2"
|
38
|
+
spec.add_dependency "isodoc", "~> 1.6.0"
|
40
39
|
spec.add_dependency "mathml2asciimath"
|
40
|
+
spec.add_dependency "metanorma-standoc", "~> 1.9.0"
|
41
|
+
spec.add_dependency "nokogiri", "~> 1.10.4"
|
41
42
|
|
42
43
|
spec.add_development_dependency "byebug"
|
43
44
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
44
45
|
spec.add_development_dependency "guard", "~> 2.14"
|
45
46
|
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
46
|
-
spec.add_development_dependency "rake", "~>
|
47
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
47
48
|
spec.add_development_dependency "rspec", "~> 3.6"
|
48
|
-
spec.add_development_dependency "rubocop", "~>
|
49
|
+
spec.add_development_dependency "rubocop", "~> 1.5.2"
|
49
50
|
spec.add_development_dependency "simplecov", "~> 0.15"
|
50
51
|
spec.add_development_dependency "timecop", "~> 0.9"
|
51
52
|
spec.add_development_dependency "vcr", "~> 5.0.0"
|
metadata
CHANGED
@@ -1,57 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-ietf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: isodoc
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.6.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.6.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: mathml2asciimath
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: metanorma-standoc
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
47
|
+
version: 1.9.0
|
34
48
|
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
54
|
+
version: 1.9.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
56
|
+
name: nokogiri
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- - "
|
59
|
+
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
61
|
+
version: 1.10.4
|
48
62
|
type: :runtime
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- - "
|
66
|
+
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
68
|
+
version: 1.10.4
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: byebug
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,14 +128,14 @@ dependencies:
|
|
114
128
|
requirements:
|
115
129
|
- - "~>"
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
131
|
+
version: '13.0'
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
136
|
- - "~>"
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
138
|
+
version: '13.0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: rspec
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,14 +156,14 @@ dependencies:
|
|
142
156
|
requirements:
|
143
157
|
- - "~>"
|
144
158
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
159
|
+
version: 1.5.2
|
146
160
|
type: :development
|
147
161
|
prerelease: false
|
148
162
|
version_requirements: !ruby/object:Gem::Requirement
|
149
163
|
requirements:
|
150
164
|
- - "~>"
|
151
165
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
166
|
+
version: 1.5.2
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: simplecov
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -228,8 +242,6 @@ files:
|
|
228
242
|
- ".hound.yml"
|
229
243
|
- ".oss-guides.rubocop.yml"
|
230
244
|
- ".rspec"
|
231
|
-
- ".rubocop.ribose.yml"
|
232
|
-
- ".rubocop.tb.yml"
|
233
245
|
- ".rubocop.yml"
|
234
246
|
- CODE_OF_CONDUCT.md
|
235
247
|
- Gemfile
|
@@ -301,7 +313,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
301
313
|
- !ruby/object:Gem::Version
|
302
314
|
version: '0'
|
303
315
|
requirements: []
|
304
|
-
rubygems_version: 3.
|
316
|
+
rubygems_version: 3.1.4
|
305
317
|
signing_key:
|
306
318
|
specification_version: 4
|
307
319
|
summary: metanorma-ietf lets you write IETF documents, such as Internet-Drafts and
|