metanorma-ietf 2.3.3 → 2.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 158e5eef3f87d8f6ce1242339d819343ea8b8ab744f522eafb9c7f16e20f6c55
4
- data.tar.gz: '089428469df3542fa94fcb535aa54d0a899b74b3aea35567239f5a24b4525366'
3
+ metadata.gz: 9a0a93b0a29195d775f23e2ba37414870b8e708a006bba0498b3113aebe787c9
4
+ data.tar.gz: 53a29d58e5c0c601c29de23d0515d43e690458b8b848f67cacf5064403c3b834
5
5
  SHA512:
6
- metadata.gz: 33db0a9a909d0253f3b91fed431e7194c53abab8ae396cea3a6944bcc56d1f2fbade0c79444d7b5d87deeab75a8e33ed1771e574a21fbf77884d9052a3b69a30
7
- data.tar.gz: 9217f91cfb840cafb5dcdda4520dfcf378634d568960a02580760fd182f0d7f4f47f23b90b143aeff3209135fc62e3c782eb5d6383b39932149666cbbdc3d7c9
6
+ metadata.gz: e89e41ec81886905668543d6f24ad31ef6ea9cf0a38551f56f1fa3e8007bb6068421b221d0d835951054894146d218b47ae0fe9d1cc1a621f7df6f85a7442e3d
7
+ data.tar.gz: 11d9d25373f48d7fb3197e5107168c64b8230d519f1e45b410dec5403aab6158f81c8f0e34c2553aff7fa1f32f5974d7a8d7a77a6e5233fb0ef65aa1a300a2c6
@@ -16,7 +16,7 @@ jobs:
16
16
  strategy:
17
17
  fail-fast: false
18
18
  matrix:
19
- ruby: [ '3.0', '2.7', '2.6', '2.5', '2.4' ]
19
+ ruby: [ '3.0', '2.7', '2.6', '2.5' ]
20
20
  os: [ ubuntu-latest, windows-latest, macos-latest ]
21
21
  experimental: [ false ]
22
22
 
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
@@ -0,0 +1,81 @@
1
+ module Asciidoctor
2
+ module Ietf
3
+ class Converter < ::Asciidoctor::Standoc::Converter
4
+ def cleanup(xmldoc)
5
+ bcp14_cleanup(xmldoc)
6
+ abstract_cleanup(xmldoc)
7
+ super
8
+ rfc_anchor_cleanup(xmldoc)
9
+ end
10
+
11
+ def abstract_cleanup(xmldoc)
12
+ xmldoc.xpath("//abstract[not(text())]").each do |x|
13
+ x.remove
14
+ warn "Empty abstract section removed"
15
+ end
16
+ end
17
+
18
+ def bcp14_cleanup(xmldoc)
19
+ return unless @bcp_bold
20
+
21
+ xmldoc.xpath("//strong").each do |s|
22
+ next unless BCP_KEYWORDS.include?(s.text)
23
+
24
+ s.name = "bcp14"
25
+ end
26
+ end
27
+
28
+ def rfc_anchor_cleanup(xmldoc)
29
+ map = {}
30
+ xmldoc.xpath("//bibitem[docidentifier/@type = 'rfc-anchor']").each do |b|
31
+ next if b.at("./ancestor::bibdata")
32
+
33
+ map[b["id"]] = b.at("./docidentifier[@type = 'rfc-anchor']").text
34
+ b["id"] = b.at("./docidentifier[@type = 'rfc-anchor']").text
35
+ end
36
+ xmldoc.xpath("//eref | //origin").each do |x|
37
+ map[x["bibitemid"]] and x["bibitemid"] = map[x["bibitemid"]]
38
+ end
39
+ xmldoc
40
+ end
41
+
42
+ def smartquotes_cleanup(xmldoc)
43
+ xmldoc.traverse do |n|
44
+ next unless n.text?
45
+
46
+ n.replace(HTMLEntities.new.encode(
47
+ n.text.gsub(/\u2019|\u2018|\u201a|\u201b/, "'")
48
+ .gsub(/\u201c|\u201d|\u201e|\u201f/, '"'), :basic
49
+ ))
50
+ end
51
+ xmldoc
52
+ end
53
+
54
+ def xref_to_eref(xref)
55
+ super
56
+ xref.delete("format")
57
+ end
58
+
59
+ def xref_cleanup(xmldoc)
60
+ super
61
+ xmldoc.xpath("//xref").each do |x|
62
+ x.delete("displayFormat")
63
+ x.delete("relative")
64
+ end
65
+ end
66
+
67
+ def quotesource_cleanup(xmldoc)
68
+ xmldoc.xpath("//quote/source | //terms/source").each do |x|
69
+ if x["target"]&.match?(URI::DEFAULT_PARSER.make_regexp)
70
+ x["uri"] = x["target"]
71
+ x.delete("target")
72
+ else
73
+ xref_to_eref(x)
74
+ end
75
+ end
76
+ end
77
+
78
+ def section_names_refs_cleanup(xml); end
79
+ end
80
+ end
81
+ end
@@ -4,6 +4,7 @@ require "isodoc/ietf/rfc_convert"
4
4
  require_relative "./front"
5
5
  require_relative "./blocks"
6
6
  require_relative "./validate"
7
+ require_relative "./cleanup"
7
8
 
8
9
  module Asciidoctor
9
10
  module Ietf
@@ -22,13 +23,13 @@ module Asciidoctor
22
23
  @draft = node.attributes.has_key?("draft")
23
24
  @workgroups = cache_workgroup(node)
24
25
  @bcp_bold = !node.attr?("no-rfc-bold-bcp14")
25
- @xinclude = node.attr?("use-xinclude")
26
+ @xinclude = node.attr?("use-xinclude")
26
27
  super
27
28
  end
28
29
 
29
30
  def outputs(node, ret)
30
- File.open(@filename + ".xml", "w:UTF-8") { |f| f.write(ret) }
31
- rfc_converter(node).convert(@filename + ".xml")
31
+ File.open("#{@filename}.xml", "w:UTF-8") { |f| f.write(ret) }
32
+ rfc_converter(node).convert("#{@filename}.xml")
32
33
  end
33
34
 
34
35
  def doctype(node)
@@ -63,12 +64,12 @@ module Asciidoctor
63
64
  f, c = xref_text(node)
64
65
  f1, c = eref_text(node) if f.nil?
65
66
  t, rel = xref_rel(node)
67
+ attrs = { target: t, type: "inline", displayFormat: f1, format: f,
68
+ relative: rel }
66
69
  noko do |xml|
67
- xml.xref **attr_code(target: t, type: "inline",
68
- displayFormat: f1, format: f,
69
- relative: rel ) do |x|
70
- x << c
71
- end
70
+ xml.xref **attr_code(attrs) do |x|
71
+ x << c
72
+ end
72
73
  end.join
73
74
  end
74
75
 
@@ -140,7 +141,8 @@ module Asciidoctor
140
141
  def rfc_anchor_cleanup(xmldoc)
141
142
  map = {}
142
143
  xmldoc.xpath("//bibitem[docidentifier/@type = 'rfc-anchor']").each do |b|
143
- next if b.at("./ancestor::bibdata")
144
+ next if b.at("./ancestor::bibdata | ./ancestor::bibitem")
145
+
144
146
  map[b["id"]] = b.at("./docidentifier[@type = 'rfc-anchor']").text
145
147
  b["id"] = b.at("./docidentifier[@type = 'rfc-anchor']").text
146
148
  end
@@ -194,34 +196,24 @@ module Asciidoctor
194
196
  clause_parse(attrs, xml, node)
195
197
  end
196
198
 
197
- def quotesource_cleanup(xmldoc)
198
- xmldoc.xpath("//quote/source | //terms/source").each do |x|
199
- if x["target"] =~ URI::DEFAULT_PARSER.make_regexp
200
- x["uri"] = x["target"]
201
- x.delete("target")
202
- else
203
- xref_to_eref(x)
204
- end
205
- end
206
- end
207
-
208
199
  def inline_indexterm(node)
209
200
  noko do |xml|
210
201
  node.type == :visible and xml << node.text.sub(/^primary:(?=\S)/, "")
211
202
  terms = (node.attr("terms") || [node.text]).map { |x| xml_encode(x) }
212
- if /^primary:\S/.match(terms[0])
203
+ if /^primary:\S/.match?(terms[0])
213
204
  terms[0].sub!(/^primary:/, "")
214
205
  has_primary = true
215
206
  end
216
- xml.index **attr_code(primary: has_primary) do |i|
217
- i.primary { |x| x << terms[0] }
218
- a = terms.dig(1) and i.secondary { |x| x << a }
219
- a = terms.dig(2) and i.tertiary { |x| x << a }
220
- end
207
+ inline_indexterm1(has_primary, terms, xml)
221
208
  end.join
222
209
  end
223
210
 
224
- def section_names_refs_cleanup(x)
211
+ def inline_indexterm1(has_primary, terms, xml)
212
+ xml.index **attr_code(primary: has_primary) do |i|
213
+ i.primary { |x| x << terms[0] }
214
+ a = terms[1] and i.secondary { |x| x << a }
215
+ a = terms[2] and i.tertiary { |x| x << a }
216
+ end
225
217
  end
226
218
 
227
219
  def html_extract_attributes(node)
@@ -119,7 +119,7 @@ module Asciidoctor
119
119
  strict: node.attr("strict"),
120
120
  compact: node.attr("compact"),
121
121
  subcompact: node.attr("subcompact"),
122
- toc: node.attr("toc-include") == "false" ? "no" : "yes",
122
+ tocinclude: node.attr("toc-include") == "false" ? "no" : "yes",
123
123
  tocdepth: node.attr("toc-depth"),
124
124
  symrefs: node.attr("sym-refs"),
125
125
  sortrefs: node.attr("sort-refs"),
@@ -842,7 +842,7 @@
842
842
  </element>
843
843
  </optional>
844
844
  <optional>
845
- <element name="toc">
845
+ <element name="tocinclude">
846
846
  <text/>
847
847
  </element>
848
848
  </optional>
@@ -204,6 +204,18 @@
204
204
  </zeroOrMore>
205
205
  </element>
206
206
  </define>
207
+ <define name="dt">
208
+ <element name="dt">
209
+ <optional>
210
+ <attribute name="id">
211
+ <data type="ID"/>
212
+ </attribute>
213
+ </optional>
214
+ <zeroOrMore>
215
+ <ref name="TextElement"/>
216
+ </zeroOrMore>
217
+ </element>
218
+ </define>
207
219
  <define name="example">
208
220
  <element name="example">
209
221
  <attribute name="id">
@@ -899,7 +911,7 @@
899
911
  </include>
900
912
  <!-- end overrides -->
901
913
  <define name="docsubtype">
902
- <element name="docsubtype">
914
+ <element name="subdoctype">
903
915
  <ref name="DocumentSubtype"/>
904
916
  </element>
905
917
  </define>
@@ -955,7 +967,34 @@
955
967
  <define name="concept">
956
968
  <element name="concept">
957
969
  <optional>
958
- <attribute name="term"/>
970
+ <attribute name="ital">
971
+ <data type="boolean"/>
972
+ </attribute>
973
+ </optional>
974
+ <optional>
975
+ <attribute name="ref">
976
+ <data type="boolean"/>
977
+ </attribute>
978
+ </optional>
979
+ <optional>
980
+ <element name="refterm">
981
+ <zeroOrMore>
982
+ <choice>
983
+ <ref name="PureTextElement"/>
984
+ <ref name="stem"/>
985
+ </choice>
986
+ </zeroOrMore>
987
+ </element>
988
+ </optional>
989
+ <optional>
990
+ <element name="renderterm">
991
+ <zeroOrMore>
992
+ <choice>
993
+ <ref name="PureTextElement"/>
994
+ <ref name="stem"/>
995
+ </choice>
996
+ </zeroOrMore>
997
+ </element>
959
998
  </optional>
960
999
  <choice>
961
1000
  <ref name="eref"/>
@@ -972,8 +1011,14 @@
972
1011
  <ref name="imagemap"/>
973
1012
  <ref name="svgmap"/>
974
1013
  <ref name="inputform"/>
1014
+ <ref name="toc"/>
975
1015
  </choice>
976
1016
  </define>
1017
+ <define name="toc">
1018
+ <element name="toc">
1019
+ <ref name="ul"/>
1020
+ </element>
1021
+ </define>
977
1022
  <define name="inputform">
978
1023
  <element name="form">
979
1024
  <attribute name="id">
@@ -981,6 +1026,9 @@
981
1026
  </attribute>
982
1027
  <attribute name="name"/>
983
1028
  <attribute name="action"/>
1029
+ <optional>
1030
+ <attribute name="class"/>
1031
+ </optional>
984
1032
  <zeroOrMore>
985
1033
  <choice>
986
1034
  <ref name="TextElement"/>
@@ -1212,6 +1260,12 @@
1212
1260
  <optional>
1213
1261
  <attribute name="type"/>
1214
1262
  </optional>
1263
+ <optional>
1264
+ <attribute name="identifier"/>
1265
+ </optional>
1266
+ <optional>
1267
+ <attribute name="prefix"/>
1268
+ </optional>
1215
1269
  <text/>
1216
1270
  </define>
1217
1271
  <define name="ics">
@@ -1473,26 +1527,26 @@
1473
1527
  <optional>
1474
1528
  <ref name="section-title"/>
1475
1529
  </optional>
1476
- <group>
1530
+ <choice>
1477
1531
  <choice>
1478
1532
  <group>
1479
- <zeroOrMore>
1533
+ <oneOrMore>
1480
1534
  <ref name="BasicBlock"/>
1481
- </zeroOrMore>
1535
+ </oneOrMore>
1482
1536
  <zeroOrMore>
1483
1537
  <ref name="note"/>
1484
1538
  </zeroOrMore>
1485
1539
  </group>
1486
1540
  <ref name="amend"/>
1487
1541
  </choice>
1488
- <zeroOrMore>
1542
+ <oneOrMore>
1489
1543
  <choice>
1490
1544
  <ref name="clause-subsection"/>
1491
1545
  <ref name="terms"/>
1492
1546
  <ref name="definitions"/>
1493
1547
  </choice>
1494
- </zeroOrMore>
1495
- </group>
1548
+ </oneOrMore>
1549
+ </choice>
1496
1550
  </define>
1497
1551
  <define name="Annex-Section">
1498
1552
  <optional>
@@ -1,4 +1,4 @@
1
- require "open-uri"
1
+ require "metanorma/ietf/data/workgroups"
2
2
 
3
3
  module Asciidoctor
4
4
  module Ietf
@@ -34,59 +34,8 @@ module Asciidoctor
34
34
  File.join(File.dirname(__FILE__), "ietf.rng"))
35
35
  end
36
36
 
37
- def wgcache_name
38
- "#{Dir.home}/.metanorma-ietf-workgroup-cache.json"
39
- end
40
-
41
- def open_wg_cache(node)
42
- node.attr("flush-caches") == "true" and
43
- FileUtils.rm wgcache_name, force: true
44
- wg = []
45
- if Pathname.new(wgcache_name).file?
46
- begin
47
- File.open(wgcache_name, "r") { |f| wg = JSON.parse(f.read) }
48
- rescue Exception => e
49
- warn "Cache #{wgcache_name} is invalid, drop it"
50
- end
51
- end
52
- [wg, wgcache_name]
53
- end
54
-
55
- def cache_workgroup_ietf(wg, _b)
56
- warn "Reading workgroups from https://tools.ietf.org/wg/..."
57
- URI.open("https://tools.ietf.org/wg/") do |f|
58
- f.each_line do |l|
59
- l.scan(%r{<td width="50%" style='padding: 0 1ex'>([^<]+)</td>}) do |w|
60
- wg << w[0].gsub(/\s+$/, "").gsub(/ Working Group$/, "")
61
- end
62
- end
63
- end
64
- wg
65
- end
66
-
67
- def cache_workgroup_irtf(wg, _b)
68
- warn "Reading workgroups from https://irtf.org/groups..."
69
- URI.open("https://irtf.org/groups", ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE) do |f|
70
- f.each_line do |l|
71
- l.scan(%r{<a title="([^"]+) Research Group"[^>]+>([^<]+)<}) do |w|
72
- wg << w[0].gsub(/\s+$/, "")
73
- wg << w[1].gsub(/\s+$/, "") # abbrev
74
- end
75
- end
76
- end
77
- wg
78
- end
79
-
80
- def cache_workgroup(node)
81
- wg, wgcache_name = open_wg_cache(node)
82
- if wg.empty?
83
- File.open(wgcache_name, "w") do |b|
84
- wg = cache_workgroup_ietf(wg, b)
85
- wg = cache_workgroup_irtf(wg, b)
86
- b << wg.to_json
87
- end
88
- end
89
- wg
37
+ def cache_workgroup(_node)
38
+ Metanorma::Ietf::Data::WORKGROUPS
90
39
  end
91
40
  end
92
41
  end
@@ -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
@@ -15,7 +15,7 @@ require_relative "./init"
15
15
 
16
16
  module IsoDoc::Ietf
17
17
  class RfcConvert < ::IsoDoc::Convert
18
- def convert1(docxml, filename, dir)
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(/</, "&lt;").gsub(/>/, "&gt;")
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 }
@@ -33,7 +33,7 @@ module IsoDoc::Ietf
33
33
  strict: node&.at(ns("//pi/strict"))&.text || "yes",
34
34
  compact: node&.at(ns("//pi/compact"))&.text || "yes",
35
35
  subcompact: node&.at(ns("//pi/subcompact"))&.text || "no",
36
- toc: node&.at(ns("//pi/toc-include"))&.text,
36
+ toc: node&.at(ns("//pi/tocinclude"))&.text,
37
37
  tocdepth: node&.at(ns("//pi/toc-depth"))&.text || "4",
38
38
  symrefs: node&.at(ns("//pi/sym-refs"))&.text || "yes",
39
39
  sortrefs: node&.at(ns("//pi/sort-refs"))&.text || "yes",
@@ -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,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ietf
3
- VERSION = "2.3.3".freeze
3
+ VERSION = "2.4.0".freeze
4
4
  end
5
5
  end
@@ -33,11 +33,12 @@ 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
- spec.add_dependency "isodoc", "~> 1.6.0"
38
+ spec.add_dependency "isodoc", "~> 1.7.0"
39
39
  spec.add_dependency "mathml2asciimath"
40
- spec.add_dependency "metanorma-standoc", "~> 1.9.0"
40
+ spec.add_dependency "metanorma-standoc", "~> 1.10.0"
41
+ spec.add_dependency "metanorma-ietf-data"
41
42
  spec.add_dependency "nokogiri", "~> 1.11.6"
42
43
  spec.add_dependency "open-uri"
43
44
 
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.4.0
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-08-02 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.6.0
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.6.0
26
+ version: 1.7.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mathml2asciimath
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.9.0
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.9.0
54
+ version: 1.10.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: metanorma-ietf-data
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: nokogiri
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -275,6 +289,7 @@ files:
275
289
  - lib/asciidoctor/ietf/basicdoc.rng
276
290
  - lib/asciidoctor/ietf/biblio.rng
277
291
  - lib/asciidoctor/ietf/blocks.rb
292
+ - lib/asciidoctor/ietf/cleanup.rb
278
293
  - lib/asciidoctor/ietf/converter.rb
279
294
  - lib/asciidoctor/ietf/front.rb
280
295
  - lib/asciidoctor/ietf/ietf.rng
@@ -320,7 +335,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
320
335
  requirements:
321
336
  - - ">="
322
337
  - !ruby/object:Gem::Version
323
- version: 2.4.0
338
+ version: 2.5.0
324
339
  required_rubygems_version: !ruby/object:Gem::Requirement
325
340
  requirements:
326
341
  - - ">="