metanorma-ietf 2.3.0 → 2.3.5
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 +3 -13
- data/.hound.yml +3 -1
- data/.rubocop.yml +4 -8
- data/lib/asciidoctor/ietf/biblio.rng +1 -0
- data/lib/asciidoctor/ietf/front.rb +2 -2
- data/lib/asciidoctor/ietf/ietf.rng +3 -0
- data/lib/asciidoctor/ietf/isodoc.rng +209 -4
- data/lib/asciidoctor/ietf/validate.rb +22 -13
- data/lib/isodoc/ietf/blocks.rb +14 -8
- data/lib/isodoc/ietf/cleanup.rb +38 -22
- data/lib/isodoc/ietf/front.rb +56 -46
- data/lib/isodoc/ietf/references.rb +20 -15
- data/lib/isodoc/ietf/rfc_convert.rb +6 -4
- data/lib/isodoc/ietf/section.rb +51 -42
- data/lib/isodoc/ietf/terms.rb +13 -2
- data/lib/metanorma/ietf/processor.rb +32 -35
- data/lib/metanorma/ietf/version.rb +1 -1
- data/metanorma-ietf.gemspec +5 -4
- metadata +23 -9
@@ -15,7 +15,7 @@ require_relative "./init"
|
|
15
15
|
|
16
16
|
module IsoDoc::Ietf
|
17
17
|
class RfcConvert < ::IsoDoc::Convert
|
18
|
-
def convert1(docxml,
|
18
|
+
def convert1(docxml, _filename, _dir)
|
19
19
|
@xrefs.parse docxml
|
20
20
|
info docxml, nil
|
21
21
|
xml = noko do |xml|
|
@@ -51,6 +51,7 @@ module IsoDoc::Ietf
|
|
51
51
|
def error_parse(node, out)
|
52
52
|
case node.name
|
53
53
|
when "bcp14" then bcp14_parse(node, out)
|
54
|
+
when "concept" then concept_parse(node, out)
|
54
55
|
else
|
55
56
|
text = node.to_xml.gsub(/</, "<").gsub(/>/, ">")
|
56
57
|
out.t { |p| p << text }
|
@@ -59,6 +60,7 @@ module IsoDoc::Ietf
|
|
59
60
|
|
60
61
|
def omit_docid_prefix(prefix)
|
61
62
|
return true if prefix == "IETF"
|
63
|
+
|
62
64
|
super
|
63
65
|
end
|
64
66
|
|
@@ -67,9 +69,9 @@ module IsoDoc::Ietf
|
|
67
69
|
end
|
68
70
|
|
69
71
|
def postprocess(result, filename, _dir)
|
70
|
-
result = from_xhtml(cleanup(to_xhtml(textcleanup(result))))
|
71
|
-
sub(/<!DOCTYPE[^>]+>\n/, "")
|
72
|
-
sub(/(<rfc[^<]+? )lang="[^"]+"/, "\\1")
|
72
|
+
result = from_xhtml(cleanup(to_xhtml(textcleanup(result))))
|
73
|
+
.sub(/<!DOCTYPE[^>]+>\n/, "")
|
74
|
+
.sub(/(<rfc[^<]+? )lang="[^"]+"/, "\\1")
|
73
75
|
File.open(filename, "w:UTF-8") { |f| f.write(result) }
|
74
76
|
schema_validate(filename)
|
75
77
|
@files_to_delete.each { |f| FileUtils.rm_rf f }
|
data/lib/isodoc/ietf/section.rb
CHANGED
@@ -2,7 +2,7 @@ module IsoDoc::Ietf
|
|
2
2
|
class RfcConvert < ::IsoDoc::Convert
|
3
3
|
def common_rfc_pis(node)
|
4
4
|
rfc_pis = {
|
5
|
-
|
5
|
+
artworkdelimiter: node&.at(ns("//pi/artworkdelimiter"))&.text,
|
6
6
|
artworklines: node&.at(ns("//pi/artworklines"))&.text,
|
7
7
|
authorship: node&.at(ns("//pi/authorship"))&.text,
|
8
8
|
autobreaks: node&.at(ns("//pi/autobreaks"))&.text,
|
@@ -53,30 +53,32 @@ module IsoDoc::Ietf
|
|
53
53
|
|
54
54
|
def rfc_attributes(docxml)
|
55
55
|
t = Time.now.getutc
|
56
|
-
obs = xpath_comma(docxml
|
57
|
-
"//bibdata/relation[@type = 'obsoletes']/bibitem/docidentifier")))
|
58
|
-
upd = xpath_comma(docxml
|
59
|
-
"//bibdata/relation[@type = 'updates']/bibitem/docidentifier")))
|
56
|
+
obs = xpath_comma(docxml
|
57
|
+
.xpath(ns("//bibdata/relation[@type = 'obsoletes']/bibitem/docidentifier")))
|
58
|
+
upd = xpath_comma(docxml
|
59
|
+
.xpath(ns("//bibdata/relation[@type = 'updates']/bibitem/docidentifier")))
|
60
60
|
{
|
61
|
-
docName:
|
62
|
-
number:
|
63
|
-
category:
|
64
|
-
docxml&.at(ns("//bibdata/series[@type = 'intended']/title"))&.text
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
61
|
+
docName: @meta.get[:doctype] == "Internet Draft" ? @meta.get[:docnumber] : nil,
|
62
|
+
number: @meta.get[:doctype].casecmp?("rfc") ? @meta.get[:docnumber] : nil,
|
63
|
+
category: series2category(
|
64
|
+
docxml&.at(ns("//bibdata/series[@type = 'intended']/title"))&.text,
|
65
|
+
),
|
66
|
+
ipr: docxml&.at(ns("//bibdata/ext/ipr"))&.text,
|
67
|
+
consensus: docxml&.at(ns("//bibdata/ext/consensus"))&.text,
|
68
|
+
obsoletes: obs,
|
69
|
+
updates: upd,
|
70
|
+
indexInclude: docxml&.at(ns("//bibdata/ext/indexInclude"))&.text,
|
71
|
+
iprExtract: docxml&.at(ns("//bibdata/ext/iprExtract"))&.text,
|
72
|
+
sortRefs: docxml&.at(ns("//bibdata/ext/sortRefs"))&.text,
|
73
|
+
symRefs: docxml&.at(ns("//bibdata/ext/symRefs"))&.text,
|
74
|
+
tocInclude: docxml&.at(ns("//bibdata/ext/tocInclude"))&.text,
|
75
|
+
tocDepth: docxml&.at(ns("//bibdata/ext/tocDepth"))&.text,
|
75
76
|
submissionType: docxml&.at(ns(
|
76
|
-
"//bibdata/series[@type = 'stream']/title"
|
77
|
-
|
78
|
-
|
79
|
-
|
77
|
+
"//bibdata/series[@type = 'stream']/title",
|
78
|
+
))&.text || "IETF",
|
79
|
+
'xml:lang': docxml&.at(ns("//bibdata/language"))&.text,
|
80
|
+
version: "3",
|
81
|
+
'xmlns:xi': "http://www.w3.org/2001/XInclude",
|
80
82
|
}
|
81
83
|
end
|
82
84
|
|
@@ -86,7 +88,7 @@ module IsoDoc::Ietf
|
|
86
88
|
when "informational", "info" then "info"
|
87
89
|
when "experimental", "exp" then "exp"
|
88
90
|
when "bcp" then "bcp"
|
89
|
-
when "fyi"
|
91
|
+
when "fyi" then "info"
|
90
92
|
when "full-standard" then "std"
|
91
93
|
when "historic" then "historic"
|
92
94
|
else
|
@@ -96,17 +98,19 @@ module IsoDoc::Ietf
|
|
96
98
|
|
97
99
|
def xpath_comma(xpath)
|
98
100
|
return nil if xpath.empty?
|
99
|
-
|
101
|
+
|
102
|
+
xpath.map(&:text).join(", ")
|
100
103
|
end
|
101
104
|
|
102
105
|
def make_link(out, isoxml)
|
103
|
-
links = isoxml
|
104
|
-
"//bibdata/relation[@type = 'includedIn' or
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
106
|
+
links = isoxml
|
107
|
+
.xpath(ns("//bibdata/relation[@type = 'includedIn' or "\
|
108
|
+
"@type = 'describedBy' or @type = 'derivedFrom' or "\
|
109
|
+
"@type = 'instance']")) || return
|
110
|
+
links.each do |l|
|
111
|
+
out.link **{ href: l&.at(ns("./bibitem/docidentifier"))&.text,
|
112
|
+
rel: rel2iana(l["type"]) }
|
113
|
+
end
|
110
114
|
end
|
111
115
|
|
112
116
|
def rel2iana(type)
|
@@ -115,7 +119,7 @@ module IsoDoc::Ietf
|
|
115
119
|
when "describedBy" then "describedby"
|
116
120
|
when "derivedFrom" then "convertedfrom"
|
117
121
|
when "instance" then "alternate"
|
118
|
-
else
|
122
|
+
else
|
119
123
|
"alternate"
|
120
124
|
end
|
121
125
|
end
|
@@ -133,17 +137,21 @@ module IsoDoc::Ietf
|
|
133
137
|
end
|
134
138
|
end
|
135
139
|
|
136
|
-
def clause_parse_title(
|
137
|
-
return unless
|
140
|
+
def clause_parse_title(_node, div, clause, _out, _heading_attrs = {})
|
141
|
+
return unless clause
|
142
|
+
|
138
143
|
div.name do |n|
|
139
|
-
|
144
|
+
clause&.children&.each { |c2| parse(c2, n) }
|
140
145
|
end
|
141
146
|
end
|
142
147
|
|
143
148
|
def clause_parse(node, out)
|
144
149
|
return if node.at(ns(".//references"))
|
145
|
-
|
146
|
-
|
150
|
+
|
151
|
+
out.section **attr_code(
|
152
|
+
anchor: node["id"], numbered: node["numbered"],
|
153
|
+
removeInRFC: node["removeInRFC"], toc: node["toc"]
|
154
|
+
) do |div|
|
147
155
|
clause_parse_title(node, div, node.at(ns("./title")), out)
|
148
156
|
node.children.reject { |c1| c1.name == "title" }.each do |c1|
|
149
157
|
parse(c1, div)
|
@@ -152,11 +160,12 @@ module IsoDoc::Ietf
|
|
152
160
|
end
|
153
161
|
|
154
162
|
def clause(isoxml, out)
|
155
|
-
isoxml.xpath("//xmlns:preface/child::*
|
163
|
+
isoxml.xpath("//xmlns:preface/child::*"\
|
164
|
+
"[not(name() = 'abstract' or name() = 'foreword')] "\
|
156
165
|
"| //xmlns:sections/child::*").each do |c|
|
157
|
-
#cdup = c.dup
|
158
|
-
#cdup.xpath(ns(".//references")).each { |r| r.remove }
|
159
|
-
#cdup.at("./*[local-name() != 'title'][normalize-space(text()) != '']") or next
|
166
|
+
# cdup = c.dup
|
167
|
+
# cdup.xpath(ns(".//references")).each { |r| r.remove }
|
168
|
+
# cdup.at("./*[local-name() != 'title'][normalize-space(text()) != '']") or next
|
160
169
|
clause_parse(c, out)
|
161
170
|
end
|
162
171
|
end
|
data/lib/isodoc/ietf/terms.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module IsoDoc::Ietf
|
2
2
|
class RfcConvert < ::IsoDoc::Convert
|
3
|
-
|
4
3
|
def definition_parse(node, out)
|
5
4
|
node.children.each { |n| parse(n, out) }
|
6
5
|
end
|
@@ -46,7 +45,19 @@ module IsoDoc::Ietf
|
|
46
45
|
clause_parse(node, out)
|
47
46
|
end
|
48
47
|
|
49
|
-
def termdocsource_parse(_node, _out)
|
48
|
+
def termdocsource_parse(_node, _out); end
|
49
|
+
|
50
|
+
def concept_parse(node, out)
|
51
|
+
if d = node.at(ns("./renderterm"))
|
52
|
+
out.em do |em|
|
53
|
+
d.children.each { |n| parse(n, em) }
|
54
|
+
end
|
55
|
+
out << " "
|
56
|
+
end
|
57
|
+
out << "[term defined in "
|
58
|
+
r = node.at(ns("./xref | ./eref | ./termref"))
|
59
|
+
parse(r, out)
|
60
|
+
out << "]"
|
50
61
|
end
|
51
62
|
end
|
52
63
|
end
|
@@ -1,11 +1,14 @@
|
|
1
1
|
require "metanorma/processor"
|
2
2
|
require "tempfile"
|
3
3
|
|
4
|
+
require "isodoc/ietf/rfc_convert"
|
5
|
+
|
4
6
|
module Metanorma
|
5
7
|
module Ietf
|
6
|
-
|
8
|
+
RfcConvert = ::IsoDoc::Ietf::RfcConvert
|
7
9
|
|
8
|
-
|
10
|
+
class Processor < Metanorma::Processor
|
11
|
+
def initialize # rubocop:disable Lint/MissingSuper
|
9
12
|
@short = :ietf
|
10
13
|
@input_format = :asciidoc
|
11
14
|
@asciidoctor_backend = :ietf
|
@@ -18,7 +21,7 @@ module Metanorma
|
|
18
21
|
rfc: "rfc.xml",
|
19
22
|
html: "html",
|
20
23
|
txt: "txt",
|
21
|
-
pdf: "pdf"
|
24
|
+
pdf: "pdf",
|
22
25
|
}
|
23
26
|
end
|
24
27
|
|
@@ -26,15 +29,15 @@ module Metanorma
|
|
26
29
|
"Metanorma::Ietf #{::Metanorma::Ietf::VERSION}"
|
27
30
|
end
|
28
31
|
|
29
|
-
def extract_options(
|
32
|
+
def extract_options(_isodocxml)
|
30
33
|
{}
|
31
34
|
end
|
32
35
|
|
33
36
|
# From mislav: https://stackoverflow.com/questions/2108727
|
34
37
|
# /which-in-ruby-checking-if-program-exists-in-path-from-ruby
|
35
38
|
def which(cmd)
|
36
|
-
exts = ENV[
|
37
|
-
ENV[
|
39
|
+
exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]
|
40
|
+
ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
|
38
41
|
exts.each do |ext|
|
39
42
|
exe = File.join(path, "#{cmd}#{ext}")
|
40
43
|
return exe if File.executable?(exe) && !File.directory?(exe)
|
@@ -43,49 +46,43 @@ module Metanorma
|
|
43
46
|
nil
|
44
47
|
end
|
45
48
|
|
46
|
-
def use_presentation_xml(
|
49
|
+
def use_presentation_xml(_ext)
|
47
50
|
false
|
48
51
|
end
|
49
52
|
|
50
|
-
def
|
51
|
-
|
53
|
+
def check_xml2rfc_present?(format)
|
54
|
+
if which("xml2rfc").nil?
|
55
|
+
raise "[metanorma-ietf] Fatal: unable to generate #{format}," \
|
56
|
+
" the command `xml2rfc` is not found in path."
|
57
|
+
end
|
52
58
|
end
|
53
59
|
|
54
|
-
def output(isodoc_node, inname, outname, format, options={})
|
60
|
+
def output(isodoc_node, inname, outname, format, options = {})
|
55
61
|
case format
|
56
62
|
when :rfc
|
57
63
|
outname ||= inname.sub(/\.xml$/, ".rfc.xml")
|
58
|
-
|
64
|
+
RfcConvert.new(options).convert(inname, isodoc_node, nil, outname)
|
59
65
|
@done_rfc = true
|
60
|
-
|
61
66
|
when :txt, :pdf, :html
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
67
|
+
xml2rfc(isodoc_node, inname, outname, format, options)
|
68
|
+
else
|
69
|
+
super
|
70
|
+
end
|
71
|
+
end
|
66
72
|
|
67
|
-
|
68
|
-
|
69
|
-
output(isodoc_node, inname, rfcname, :rfc, options)
|
70
|
-
end
|
73
|
+
def xml2rfc(isodoc_node, inname, outname, format, options)
|
74
|
+
check_xml2rfc_present?(format)
|
71
75
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
76
|
+
rfcname = inname.sub(/\.xml$/, ".rfc.xml")
|
77
|
+
unless @done_rfc && File.exist?(rfcname)
|
78
|
+
output(isodoc_node, inname, rfcname, :rfc, options)
|
79
|
+
end
|
77
80
|
|
78
|
-
|
79
|
-
|
80
|
-
when :pdf then "--pdf"
|
81
|
-
when :html then "--html"
|
82
|
-
end
|
81
|
+
outext = { txt: ".txt", pdf: ".pdf", html: ".html" }[format]
|
82
|
+
outflag = { txt: "--text", pdf: "--pdf", html: "--html" }[format]
|
83
83
|
|
84
|
-
|
85
|
-
|
86
|
-
else
|
87
|
-
super
|
88
|
-
end
|
84
|
+
outname ||= inname.sub(/\.xml$/, outext)
|
85
|
+
system("xml2rfc #{outflag} #{rfcname} -o #{outname}")
|
89
86
|
end
|
90
87
|
end
|
91
88
|
end
|
data/metanorma-ietf.gemspec
CHANGED
@@ -33,12 +33,13 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.bindir = "exe"
|
34
34
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
35
35
|
spec.require_paths = ["lib"]
|
36
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
36
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
37
37
|
|
38
|
-
spec.add_dependency "isodoc", "~> 1.
|
38
|
+
spec.add_dependency "isodoc", "~> 1.7.0"
|
39
39
|
spec.add_dependency "mathml2asciimath"
|
40
|
-
spec.add_dependency "metanorma-standoc", "~> 1.
|
41
|
-
spec.add_dependency "nokogiri", "~> 1.
|
40
|
+
spec.add_dependency "metanorma-standoc", "~> 1.10.0"
|
41
|
+
spec.add_dependency "nokogiri", "~> 1.11.6"
|
42
|
+
spec.add_dependency "open-uri"
|
42
43
|
|
43
44
|
spec.add_development_dependency "byebug"
|
44
45
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-ietf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.5
|
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-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: isodoc
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.7.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.7.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mathml2asciimath
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,28 +44,42 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: 1.10.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: 1.10.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: nokogiri
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.11.6
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
68
|
+
version: 1.11.6
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: open-uri
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: byebug
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -306,7 +320,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
306
320
|
requirements:
|
307
321
|
- - ">="
|
308
322
|
- !ruby/object:Gem::Version
|
309
|
-
version: 2.
|
323
|
+
version: 2.5.0
|
310
324
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
311
325
|
requirements:
|
312
326
|
- - ">="
|