metanorma-ietf 2.4.0 → 2.4.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: 9a0a93b0a29195d775f23e2ba37414870b8e708a006bba0498b3113aebe787c9
4
- data.tar.gz: 53a29d58e5c0c601c29de23d0515d43e690458b8b848f67cacf5064403c3b834
3
+ metadata.gz: 68f7c56e995bd19565266c00a76aa97a0e7a02e348d34f53d7d9288b63fb8663
4
+ data.tar.gz: 83866142dd9d484e04f7f34b7df0a2a405d1aee18063d0c5d87612e5b336920c
5
5
  SHA512:
6
- metadata.gz: e89e41ec81886905668543d6f24ad31ef6ea9cf0a38551f56f1fa3e8007bb6068421b221d0d835951054894146d218b47ae0fe9d1cc1a621f7df6f85a7442e3d
7
- data.tar.gz: 11d9d25373f48d7fb3197e5107168c64b8230d519f1e45b410dec5403aab6158f81c8f0e34c2553aff7fa1f32f5974d7a8d7a77a6e5233fb0ef65aa1a300a2c6
6
+ metadata.gz: 26bf8e60e859a2875c84c8ca90ad6f33e2100de0b381e51da5fb461a9cce3276e52b8a21d090d9639b9003ad2762aa69a3c5abd0154ecc489c56ab9e5660b240
7
+ data.tar.gz: '0891c85154fc7fdc7b53d66307fe7c9179336f45cabecd1c902f772db770e356b17027ac4d16b17fa2270dace7ff7767460788de5706c45febf7be292a96a1d0'
@@ -624,6 +624,9 @@
624
624
  <choice>
625
625
  <ref name="PureTextElement"/>
626
626
  <ref name="stem"/>
627
+ <ref name="eref"/>
628
+ <ref name="xref"/>
629
+ <ref name="hyperlink"/>
627
630
  </choice>
628
631
  </zeroOrMore>
629
632
  </element>
@@ -634,6 +637,9 @@
634
637
  <choice>
635
638
  <ref name="PureTextElement"/>
636
639
  <ref name="stem"/>
640
+ <ref name="eref"/>
641
+ <ref name="xref"/>
642
+ <ref name="hyperlink"/>
637
643
  </choice>
638
644
  </zeroOrMore>
639
645
  </element>
@@ -641,7 +647,12 @@
641
647
  <define name="tt">
642
648
  <element name="tt">
643
649
  <zeroOrMore>
644
- <ref name="PureTextElement"/>
650
+ <choice>
651
+ <ref name="PureTextElement"/>
652
+ <ref name="eref"/>
653
+ <ref name="xref"/>
654
+ <ref name="hyperlink"/>
655
+ </choice>
645
656
  </zeroOrMore>
646
657
  </element>
647
658
  </define>
@@ -822,7 +833,9 @@
822
833
  <attribute name="alt"/>
823
834
  </optional>
824
835
  <ref name="CitationType"/>
825
- <text/>
836
+ <oneOrMore>
837
+ <ref name="PureTextElement"/>
838
+ </oneOrMore>
826
839
  </define>
827
840
  <define name="hyperlink">
828
841
  <element name="link">
@@ -835,7 +848,9 @@
835
848
  <optional>
836
849
  <attribute name="alt"/>
837
850
  </optional>
838
- <text/>
851
+ <oneOrMore>
852
+ <ref name="PureTextElement"/>
853
+ </oneOrMore>
839
854
  </element>
840
855
  </define>
841
856
  <define name="xref">
@@ -849,7 +864,9 @@
849
864
  <optional>
850
865
  <attribute name="alt"/>
851
866
  </optional>
852
- <text/>
867
+ <oneOrMore>
868
+ <ref name="PureTextElement"/>
869
+ </oneOrMore>
853
870
  </element>
854
871
  </define>
855
872
  <define name="fn">
@@ -6,6 +6,8 @@ module Asciidoctor
6
6
  abstract_cleanup(xmldoc)
7
7
  super
8
8
  rfc_anchor_cleanup(xmldoc)
9
+ cref_cleanup(xmldoc)
10
+ xmldoc
9
11
  end
10
12
 
11
13
  def abstract_cleanup(xmldoc)
@@ -15,6 +17,21 @@ module Asciidoctor
15
17
  end
16
18
  end
17
19
 
20
+ def cref_cleanup(xmldoc)
21
+ xmldoc.xpath("//crefref").each do |r|
22
+ if c = xmldoc.at("//review[@id = '#{r.text}']")
23
+ r.replace(c.remove)
24
+ else
25
+ @log.add("Crossrefences", r,
26
+ "No matching review for cref:[#{r.text}]")
27
+ end
28
+ end
29
+ end
30
+
31
+ BCP_KEYWORDS = ["MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
32
+ "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY",
33
+ "OPTIONAL"].freeze
34
+
18
35
  def bcp14_cleanup(xmldoc)
19
36
  return unless @bcp_bold
20
37
 
@@ -26,12 +43,13 @@ module Asciidoctor
26
43
  end
27
44
 
28
45
  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")
46
+ map = xmldoc.xpath("//bibitem[docidentifier/@type = 'rfc-anchor']")
47
+ .each_with_object({}) do |b, m|
48
+ next if b.at("./ancestor::bibdata | ./ancestor::bibitem")
32
49
 
33
- map[b["id"]] = b.at("./docidentifier[@type = 'rfc-anchor']").text
34
- b["id"] = b.at("./docidentifier[@type = 'rfc-anchor']").text
50
+ id = b.at("./docidentifier[@type = 'rfc-anchor']").text
51
+ m[b["id"]] = id
52
+ b["id"] = id
35
53
  end
36
54
  xmldoc.xpath("//eref | //origin").each do |x|
37
55
  map[x["bibitemid"]] and x["bibitemid"] = map[x["bibitemid"]]
@@ -45,7 +63,12 @@ module Asciidoctor
45
63
 
46
64
  n.replace(HTMLEntities.new.encode(
47
65
  n.text.gsub(/\u2019|\u2018|\u201a|\u201b/, "'")
48
- .gsub(/\u201c|\u201d|\u201e|\u201f/, '"'), :basic
66
+ .gsub(/\u201c|\u201d|\u201e|\u201f/, '"')
67
+ .gsub(/[\u2010-\u2015]/, "-")
68
+ .gsub(/\u2026/, "...")
69
+ .gsub(/[\u200b-\u200c]/, "")
70
+ .gsub(/[\u2000-\u200a]|\u202f|\u205f/, " "),
71
+ :basic,
49
72
  ))
50
73
  end
51
74
  xmldoc
@@ -5,10 +5,15 @@ require_relative "./front"
5
5
  require_relative "./blocks"
6
6
  require_relative "./validate"
7
7
  require_relative "./cleanup"
8
+ require_relative "./macros"
8
9
 
9
10
  module Asciidoctor
10
11
  module Ietf
11
12
  class Converter < ::Asciidoctor::Standoc::Converter
13
+ Asciidoctor::Extensions.register do
14
+ inline_macro Asciidoctor::Ietf::InlineCrefMacro
15
+ end
16
+
12
17
  XML_ROOT_TAG = "ietf-standard".freeze
13
18
  XML_NAMESPACE = "https://www.metanorma.org/ns/ietf".freeze
14
19
 
@@ -113,70 +118,7 @@ module Asciidoctor
113
118
  [t, rel]
114
119
  end
115
120
 
116
- def cleanup(xmldoc)
117
- bcp14_cleanup(xmldoc)
118
- abstract_cleanup(xmldoc)
119
- super
120
- rfc_anchor_cleanup(xmldoc)
121
- end
122
-
123
- BCP_KEYWORDS = ["MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
124
- "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", "OPTIONAL"].freeze
125
-
126
- def abstract_cleanup(xmldoc)
127
- xmldoc.xpath("//abstract[not(text())]").each do |x|
128
- x.remove
129
- warn "Empty abstract section removed"
130
- end
131
- end
132
-
133
- def bcp14_cleanup(xmldoc)
134
- return unless @bcp_bold
135
- xmldoc.xpath("//strong").each do |s|
136
- next unless BCP_KEYWORDS.include?(s.text)
137
- s.name = "bcp14"
138
- end
139
- end
140
-
141
- def rfc_anchor_cleanup(xmldoc)
142
- map = {}
143
- xmldoc.xpath("//bibitem[docidentifier/@type = 'rfc-anchor']").each do |b|
144
- next if b.at("./ancestor::bibdata | ./ancestor::bibitem")
145
-
146
- map[b["id"]] = b.at("./docidentifier[@type = 'rfc-anchor']").text
147
- b["id"] = b.at("./docidentifier[@type = 'rfc-anchor']").text
148
- end
149
- xmldoc.xpath("//eref | //origin").each do |x|
150
- map[x["bibitemid"]] and x["bibitemid"] = map[x["bibitemid"]]
151
- end
152
- xmldoc
153
- end
154
-
155
- def smartquotes_cleanup(xmldoc)
156
- xmldoc.traverse do |n|
157
- next unless n.text?
158
- n.replace(HTMLEntities.new.encode(
159
- n.text.gsub(/\u2019|\u2018|\u201a|\u201b/, "'").
160
- gsub(/\u201c|\u201d|\u201e|\u201f/, '"'), :basic))
161
- end
162
- xmldoc
163
- end
164
-
165
- def xref_to_eref(x)
166
- super
167
- x.delete("format")
168
- end
169
-
170
- def xref_cleanup(xmldoc)
171
- super
172
- xmldoc.xpath("//xref").each do |x|
173
- x.delete("displayFormat")
174
- x.delete("relative")
175
- end
176
- end
177
-
178
- def norm_ref_preface(f)
179
- end
121
+ def norm_ref_preface(sect); end
180
122
 
181
123
  def clause_parse(attrs, xml, node)
182
124
  attrs[:numbered] = node.attr("numbered")
@@ -459,14 +459,9 @@
459
459
  <ref name="section-title"/>
460
460
  </optional>
461
461
  <group>
462
- <group>
463
- <zeroOrMore>
464
- <ref name="BasicBlock"/>
465
- </zeroOrMore>
466
- <zeroOrMore>
467
- <ref name="note"/>
468
- </zeroOrMore>
469
- </group>
462
+ <zeroOrMore>
463
+ <ref name="BasicBlock"/>
464
+ </zeroOrMore>
470
465
  <zeroOrMore>
471
466
  <choice>
472
467
  <ref name="clause-subsection"/>
@@ -508,14 +503,9 @@
508
503
  <ref name="section-title"/>
509
504
  </optional>
510
505
  <group>
511
- <group>
512
- <zeroOrMore>
513
- <ref name="BasicBlock"/>
514
- </zeroOrMore>
515
- <zeroOrMore>
516
- <ref name="note"/>
517
- </zeroOrMore>
518
- </group>
506
+ <zeroOrMore>
507
+ <ref name="BasicBlock"/>
508
+ </zeroOrMore>
519
509
  <zeroOrMore>
520
510
  <ref name="clause-subsection"/>
521
511
  </zeroOrMore>
@@ -547,14 +537,9 @@
547
537
  <ref name="section-title"/>
548
538
  </optional>
549
539
  <group>
550
- <group>
551
- <zeroOrMore>
552
- <ref name="BasicBlock"/>
553
- </zeroOrMore>
554
- <zeroOrMore>
555
- <ref name="note"/>
556
- </zeroOrMore>
557
- </group>
540
+ <zeroOrMore>
541
+ <ref name="BasicBlock"/>
542
+ </zeroOrMore>
558
543
  <zeroOrMore>
559
544
  <ref name="content-subsection"/>
560
545
  </zeroOrMore>
@@ -602,7 +587,10 @@
602
587
  </define>
603
588
  </include>
604
589
  <define name="TextElement" combine="choice">
605
- <ref name="bcp14"/>
590
+ <choice>
591
+ <ref name="bcp14"/>
592
+ <ref name="review"/>
593
+ </choice>
606
594
  </define>
607
595
  <define name="bcp14">
608
596
  <element name="bcp14">