metanorma-ietf 2.3.3 → 2.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 158e5eef3f87d8f6ce1242339d819343ea8b8ab744f522eafb9c7f16e20f6c55
4
- data.tar.gz: '089428469df3542fa94fcb535aa54d0a899b74b3aea35567239f5a24b4525366'
3
+ metadata.gz: 7a12328cf063937699b9e4713e4f02ecb83baed14af90b6cb8c05e44d68361f0
4
+ data.tar.gz: e89e8c1aa57a7341298ac5a3b01c17ecdab3ed746e9fcb915730dade6a8241db
5
5
  SHA512:
6
- metadata.gz: 33db0a9a909d0253f3b91fed431e7194c53abab8ae396cea3a6944bcc56d1f2fbade0c79444d7b5d87deeab75a8e33ed1771e574a21fbf77884d9052a3b69a30
7
- data.tar.gz: 9217f91cfb840cafb5dcdda4520dfcf378634d568960a02580760fd182f0d7f4f47f23b90b143aeff3209135fc62e3c782eb5d6383b39932149666cbbdc3d7c9
6
+ metadata.gz: 3279c11e5298c25e7fd5d45d441416156bbf051791cd8883675c101a1b153455c01a3b14b62cd341f29fb3c2be0c58b2273eeb501dfa7dd5e1e56d7388941c19
7
+ data.tar.gz: 6662f000dadd312542ba8e57023237bfd9036055df0c53c235fcc0dc7b7ac8b131023139fa4c029d27d5a4d0ea7929f0a2850dd3a1d747f57cd3b50cf2dbcd12
data/.rubocop.yml CHANGED
@@ -7,4 +7,4 @@ inherit_from:
7
7
  # ...
8
8
 
9
9
  AllCops:
10
- TargetRubyVersion: 2.4
10
+ TargetRubyVersion: 2.5
@@ -48,6 +48,17 @@ module IsoDoc::Ietf
48
48
  figure_postamble(docxml)
49
49
  figure_unnest(docxml)
50
50
  figure_footnote_cleanup(docxml)
51
+ figure_data_uri(docxml)
52
+ end
53
+
54
+ def figure_data_uri(docxml)
55
+ docxml.xpath("//artwork").each do |a|
56
+ next unless %r{^data:image/svg\+xml;base64}.match?(a["src"])
57
+
58
+ f = Metanorma::Utils::save_dataimage(a["src"])
59
+ a.delete("src")
60
+ a.children = File.read(f).sub(%r{<\?.+\?>}, "")
61
+ end
51
62
  end
52
63
 
53
64
  def figure_unnest(docxml)
@@ -133,7 +144,7 @@ module IsoDoc::Ietf
133
144
  docxml << "<back/>" and endnotes = docxml.at("//back")
134
145
  end
135
146
  endnotes << "<section><name>Endnotes</name></section>"
136
- endnotes = docxml.at("//back/section[last()]")
147
+ docxml.at("//back/section[last()]")
137
148
  end
138
149
 
139
150
  def image_cleanup(docxml)
@@ -153,13 +164,13 @@ module IsoDoc::Ietf
153
164
  s.children = s.children.to_xml.gsub(%r{<br/>\n}, "\n")
154
165
  .gsub(%r{\s+(<t[ >])}, "\\1").gsub(%r{</t>\s+}, "</t>")
155
166
  sourcecode_remove_markup(s)
156
- text = HTMLEntities.new.decode(s.children.to_xml.sub(/\A\n+/, ""))
157
- s.children = "<![CDATA[#{text}]]>"
167
+ s.children = "<![CDATA[#{HTMLEntities.new.decode(s
168
+ .children.to_xml.sub(/\A\n+/, ''))}]]>"
158
169
  end
159
170
  end
160
171
 
161
- def sourcecode_remove_markup(s)
162
- s.traverse do |n|
172
+ def sourcecode_remove_markup(node)
173
+ node.traverse do |n|
163
174
  next if n.text?
164
175
  next if %w(name callout annotation note sourcecode).include? n.name
165
176
 
@@ -3,6 +3,9 @@ module IsoDoc::Ietf
3
3
  # TODO displayreference will be implemented as combination of autofetch and user-provided citations
4
4
 
5
5
  def bibliography(isoxml, out)
6
+ isoxml.xpath(ns("//references/bibitem/docidentifier")).each do |i|
7
+ i.children = docid_prefix(i["type"], i.text)
8
+ end
6
9
  isoxml.xpath(ns("//bibliography/references | "\
7
10
  "//bibliography/clause[.//references] | "\
8
11
  "//annex/clause[.//references] | "\
@@ -31,22 +34,21 @@ module IsoDoc::Ietf
31
34
  i = 0
32
35
  f.xpath(ns("./bibitem | ./note")).each do |b|
33
36
  next if implicit_reference(b)
37
+
34
38
  i += 1 if b.name == "bibitem"
35
39
  if b.name == "note" then note_parse(b, div)
36
- elsif(is_ietf(b)) then ietf_bibitem_entry(div, b, i)
40
+ elsif is_ietf(b) then ietf_bibitem_entry(div, b, i)
37
41
  else
38
42
  nonstd_bibitem(div, b, i, biblio)
39
43
  end
40
44
  end
41
45
  end
42
46
 
43
- def nonstd_bibitem(list, b, ordinal, bibliography)
47
+ def nonstd_bibitem(list, b, _ordinal, _bibliography)
44
48
  uris = b.xpath(ns("./uri"))
45
49
  target = nil
46
50
  uris&.each do |u|
47
- if u["type"] == "src" then
48
- target = u.text
49
- end
51
+ target = u.text if u["type"] == "src"
50
52
  end
51
53
  list.reference **attr_code(target: target,
52
54
  anchor: b["id"]) do |r|
@@ -66,7 +68,8 @@ module IsoDoc::Ietf
66
68
  r.refcontent id[1]
67
69
  docidentifiers&.each do |u|
68
70
  if %w(DOI IETF).include? u["type"]
69
- r.seriesInfo nil, **attr_code(value: u.text, name: u["type"])
71
+ r.seriesInfo nil, **attr_code(value: u.text.sub(/^DOI /, ""),
72
+ name: u["type"])
70
73
  end
71
74
  end
72
75
  end
@@ -86,7 +89,7 @@ module IsoDoc::Ietf
86
89
  "'publisher']"))
87
90
  auths.each do |a|
88
91
  role = a.at(ns("./role[@type = 'editor']")) ? "editor" : nil
89
- p = a&.at(ns("./person/name")) and
92
+ p = a&.at(ns("./person/name")) and
90
93
  relaton_person_to_author(p, role, f) or
91
94
  relaton_org_to_author(a&.at(ns("./organization")), role, f)
92
95
  end
@@ -99,17 +102,17 @@ module IsoDoc::Ietf
99
102
  p&.xpath(ns("./forename"))&.map { |i| i.text[0] }&.join(" ")
100
103
  initials = nil if initials.empty?
101
104
  f.author nil,
102
- **attr_code(fullname: fullname, asciiFullname: fullname&.transliterate,
103
- role: role, surname: surname, initials: initials,
104
- asciiSurname: fullname ? surname&.transliterate : nil,
105
- asciiInitials: fullname ? initials&.transliterate : nil)
105
+ **attr_code(fullname: fullname, asciiFullname: fullname&.transliterate,
106
+ role: role, surname: surname, initials: initials,
107
+ asciiSurname: fullname ? surname&.transliterate : nil,
108
+ asciiInitials: fullname ? initials&.transliterate : nil)
106
109
  end
107
110
 
108
- def relaton_org_to_author(o, role, f)
111
+ def relaton_org_to_author(o, _role, f)
109
112
  name = o&.at(ns("./name"))&.text
110
113
  abbrev = o&.at(ns("./abbreviation"))&.text
111
- f.author do |a|
112
- f.organization name, **attr_code(ascii: name&.transliterate,
114
+ f.author do |_a|
115
+ f.organization name, **attr_code(ascii: name&.transliterate,
113
116
  abbrev: abbrev)
114
117
  end
115
118
  end
@@ -119,6 +122,7 @@ module IsoDoc::Ietf
119
122
  b.at(ns("./date[@type = 'issued']")) ||
120
123
  b.at(ns("./date[@type = 'circulated']"))
121
124
  return unless date
125
+
122
126
  attr = date_attr(date&.at(ns("./on | ./from"))&.text) || return
123
127
  f.date **attr_code(attr)
124
128
  end
@@ -145,13 +149,14 @@ module IsoDoc::Ietf
145
149
  end
146
150
  end
147
151
 
148
- def ietf_bibitem_entry(div, b, i)
152
+ def ietf_bibitem_entry(div, b, _i)
149
153
  url = b&.at(ns("./uri[@type = 'xml']"))&.text
150
154
  div << "<xi:include href='#{url}'/>"
151
155
  end
152
156
 
153
157
  def is_ietf(b)
154
158
  return false if !@xinclude
159
+
155
160
  url = b.at(ns("./uri[@type = 'xml']")) or return false
156
161
  /xml2rfc\.tools\.ietf\.org/.match(url)
157
162
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ietf
3
- VERSION = "2.3.3".freeze
3
+ VERSION = "2.3.4".freeze
4
4
  end
5
5
  end
@@ -33,7 +33,7 @@ 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.4.0")
36
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
37
37
 
38
38
  spec.add_dependency "isodoc", "~> 1.6.0"
39
39
  spec.add_dependency "mathml2asciimath"
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.3
4
+ version: 2.3.4
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-06-07 00:00:00.000000000 Z
11
+ date: 2021-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: isodoc
@@ -320,7 +320,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
320
320
  requirements:
321
321
  - - ">="
322
322
  - !ruby/object:Gem::Version
323
- version: 2.4.0
323
+ version: 2.5.0
324
324
  required_rubygems_version: !ruby/object:Gem::Requirement
325
325
  requirements:
326
326
  - - ">="