metanorma-ietf 2.3.5 → 2.3.6

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: 7629e0ade5cff517d3fdf80296490da26a339654c338d7976d1b7f028aebb147
4
- data.tar.gz: 3add51632aeb8f9c1f06c96ca276e3bb947d129ce704c902eb918e998331914a
3
+ metadata.gz: 1a19bfaee2381bda7dd532941697aa43f6c9804940b9c2f82897f6950d195cc7
4
+ data.tar.gz: ba4c70b46014f9c41c4971e99da7608df7f2780855bbdbd005e6e4c542dda215
5
5
  SHA512:
6
- metadata.gz: 3519faef8dccfc5c474c0d3e4b12401aad30e98f666c50939aa1abf8736c9dddca67129dd6c50bc2cad77ce9f4589469d6ab93943462866d61d49b17fb888a3b
7
- data.tar.gz: 490a7fddbb7c158c746445f3607b7fe5225b9e8d082b5e0f529c30b08c7db497bf0826872d904f4c95628e630b35d3048d4f4511602cc06fb3f8169dda5812f1
6
+ metadata.gz: 4b3eafc5eccb17ceaa77851f1aef2d66ea2fd6b39213b2537643571ee4f3b827a1b5b4d2fc2f9e3622649302661285035a483567b90d32cdddc693ca0d62f86d
7
+ data.tar.gz: 41c2f933072a61553455c06ac46ce40cd49e81fa86e162740b179a3099ad033eafd9a09723cbfe05c6d7b86227bf5fbd2e4121d4c92e6f625927a535e53ee58e
@@ -0,0 +1,85 @@
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
+ BCP_KEYWORDS =
12
+ ["MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
13
+ "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", "OPTIONAL"].freeze
14
+
15
+ def abstract_cleanup(xmldoc)
16
+ xmldoc.xpath("//abstract[not(text())]").each do |x|
17
+ x.remove
18
+ warn "Empty abstract section removed"
19
+ end
20
+ end
21
+
22
+ def bcp14_cleanup(xmldoc)
23
+ return unless @bcp_bold
24
+
25
+ xmldoc.xpath("//strong").each do |s|
26
+ next unless BCP_KEYWORDS.include?(s.text)
27
+
28
+ s.name = "bcp14"
29
+ end
30
+ end
31
+
32
+ def rfc_anchor_cleanup(xmldoc)
33
+ map = {}
34
+ xmldoc.xpath("//bibitem[docidentifier/@type = 'rfc-anchor']").each do |b|
35
+ next if b.at("./ancestor::bibdata")
36
+
37
+ map[b["id"]] = b.at("./docidentifier[@type = 'rfc-anchor']").text
38
+ b["id"] = b.at("./docidentifier[@type = 'rfc-anchor']").text
39
+ end
40
+ xmldoc.xpath("//eref | //origin").each do |x|
41
+ map[x["bibitemid"]] and x["bibitemid"] = map[x["bibitemid"]]
42
+ end
43
+ xmldoc
44
+ end
45
+
46
+ def smartquotes_cleanup(xmldoc)
47
+ xmldoc.traverse do |n|
48
+ next unless n.text?
49
+
50
+ n.replace(HTMLEntities.new.encode(
51
+ n.text.gsub(/\u2019|\u2018|\u201a|\u201b/, "'")
52
+ .gsub(/\u201c|\u201d|\u201e|\u201f/, '"'), :basic
53
+ ))
54
+ end
55
+ xmldoc
56
+ end
57
+
58
+ def xref_to_eref(xref)
59
+ super
60
+ xref.delete("format")
61
+ end
62
+
63
+ def xref_cleanup(xmldoc)
64
+ super
65
+ xmldoc.xpath("//xref").each do |x|
66
+ x.delete("displayFormat")
67
+ x.delete("relative")
68
+ end
69
+ end
70
+
71
+ def quotesource_cleanup(xmldoc)
72
+ xmldoc.xpath("//quote/source | //terms/source").each do |x|
73
+ if x["target"]&.match?(URI::DEFAULT_PARSER.make_regexp)
74
+ x["uri"] = x["target"]
75
+ x.delete("target")
76
+ else
77
+ xref_to_eref(x)
78
+ end
79
+ end
80
+ end
81
+
82
+ def section_names_refs_cleanup(xml); end
83
+ end
84
+ end
85
+ 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)
@@ -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>
@@ -954,6 +966,16 @@
954
966
  </define>
955
967
  <define name="concept">
956
968
  <element name="concept">
969
+ <optional>
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>
957
979
  <optional>
958
980
  <element name="refterm">
959
981
  <zeroOrMore>
@@ -998,6 +1020,9 @@
998
1020
  </attribute>
999
1021
  <attribute name="name"/>
1000
1022
  <attribute name="action"/>
1023
+ <optional>
1024
+ <attribute name="class"/>
1025
+ </optional>
1001
1026
  <zeroOrMore>
1002
1027
  <choice>
1003
1028
  <ref name="TextElement"/>
@@ -1490,26 +1515,26 @@
1490
1515
  <optional>
1491
1516
  <ref name="section-title"/>
1492
1517
  </optional>
1493
- <group>
1518
+ <choice>
1494
1519
  <choice>
1495
1520
  <group>
1496
- <zeroOrMore>
1521
+ <oneOrMore>
1497
1522
  <ref name="BasicBlock"/>
1498
- </zeroOrMore>
1523
+ </oneOrMore>
1499
1524
  <zeroOrMore>
1500
1525
  <ref name="note"/>
1501
1526
  </zeroOrMore>
1502
1527
  </group>
1503
1528
  <ref name="amend"/>
1504
1529
  </choice>
1505
- <zeroOrMore>
1530
+ <oneOrMore>
1506
1531
  <choice>
1507
1532
  <ref name="clause-subsection"/>
1508
1533
  <ref name="terms"/>
1509
1534
  <ref name="definitions"/>
1510
1535
  </choice>
1511
- </zeroOrMore>
1512
- </group>
1536
+ </oneOrMore>
1537
+ </choice>
1513
1538
  </define>
1514
1539
  <define name="Annex-Section">
1515
1540
  <optional>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ietf
3
- VERSION = "2.3.5".freeze
3
+ VERSION = "2.3.6".freeze
4
4
  end
5
5
  end
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.5
4
+ version: 2.3.6
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-07-05 00:00:00.000000000 Z
11
+ date: 2021-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: isodoc
@@ -275,6 +275,7 @@ files:
275
275
  - lib/asciidoctor/ietf/basicdoc.rng
276
276
  - lib/asciidoctor/ietf/biblio.rng
277
277
  - lib/asciidoctor/ietf/blocks.rb
278
+ - lib/asciidoctor/ietf/cleanup.rb
278
279
  - lib/asciidoctor/ietf/converter.rb
279
280
  - lib/asciidoctor/ietf/front.rb
280
281
  - lib/asciidoctor/ietf/ietf.rng