metanorma-ietf 3.2.2 → 3.2.4

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: 3c1762cf1c04cf88835f2e0a18c9779cff01a8a6d342241e7e72a756072ab9c8
4
- data.tar.gz: 54954987db100a47a4d443fed697637d0fa90748fdbed6a4bcfe35ae677c22ac
3
+ metadata.gz: 15679fd3c253726b9f401c099a73c02f242a946eb358b4c7dc025f13d5aa0ed8
4
+ data.tar.gz: c2fef641bba26aff816757f36a6f61642190f0120874c2a01165a2513b5bb5db
5
5
  SHA512:
6
- metadata.gz: f989c4cbf195de5c2f2f8b4afda5611cdad02f910f9b38aa1f31c58e33ba97aa5128e09aed2cf92720578deaeebfab26479450a181955b7d0084e7700d772ab9
7
- data.tar.gz: 4004434ec7add5c7c0084ee10f9bd6fad254edcf176fc4ba72436e8461af870b4b94ae10f66926ece58be4b4e95982e353c3cdae8a086620196ae206194bbbfb
6
+ metadata.gz: 25c51c60d9b85a0693db8c21f3159b4875fbb0cb430a0cdbf17b33d527d1ace7106bc118d9dde7f0b607953c1c459b43688c4121e110379ef7420336822d0861
7
+ data.tar.gz: ca609bafe3ade87598fd0b87de4de63e6649a2c1e976f0f94768e778c98c0163561eac55a2d20d6872e8b48cb46ac5c0791ee2590827047e83c4b018521a0557
@@ -9,17 +9,64 @@ module IsoDoc
9
9
  table_cleanup(docxml)
10
10
  footnote_cleanup(docxml)
11
11
  sourcecode_cleanup(docxml)
12
- annotation_cleanup(docxml)
13
12
  li_cleanup(docxml)
14
13
  deflist_cleanup(docxml)
15
14
  bookmark_cleanup(docxml)
16
15
  cref_cleanup(docxml)
17
- aside_cleanup(docxml)
18
16
  front_cleanup(docxml)
19
17
  u_cleanup(docxml)
18
+ biblio_cleanup(docxml) # feeds aside
19
+ aside_cleanup(docxml)
20
20
  docxml
21
21
  end
22
22
 
23
+ def biblio_cleanup(xmldoc)
24
+ biblio_abstract_cleanup(xmldoc)
25
+ biblio_date_cleanup(xmldoc)
26
+ biblio_refcontent_cleanup(xmldoc)
27
+ annotation_cleanup(xmldoc)
28
+ end
29
+
30
+ def biblio_date_cleanup(xmldoc)
31
+ xmldoc.xpath("//date[@cleanme]").each do |a|
32
+ a.delete("cleanme")
33
+ d = @c.decode(a.text).gsub(/–/, "-").sub(/-\d\d\d\d.*$/, "")
34
+ if attrs = date_attr(d)
35
+ attrs.each do |k, v|
36
+ a[k] = v
37
+ end
38
+ a.children.remove
39
+ else a.remove end
40
+ end
41
+ end
42
+
43
+ def biblio_abstract_cleanup(xmldoc)
44
+ xmldoc.xpath("//abstract[@cleanme]").each do |a|
45
+ a.delete("cleanme")
46
+ ret = reparse_abstract(a)
47
+ a.children = if a.at("./p") then ret
48
+ else "<t>#{ret}</t>"
49
+ end
50
+ end
51
+ end
52
+
53
+ def biblio_refcontent_cleanup(xmldoc)
54
+ xmldoc.xpath("//refcontent").each do |a|
55
+ val = a.text.strip
56
+ if val.empty? then a.remove
57
+ else a.children = val
58
+ end
59
+ end
60
+ end
61
+
62
+ def reparse_abstract(abstract)
63
+ a1 = Nokogiri::XML(abstract.dup.to_xml
64
+ .sub("<abstract>", "<abstract xmlns='http://www.example.com'>")).root
65
+ noko do |xml|
66
+ a1.children.each { |n| parse(n, xml) }
67
+ end.join
68
+ end
69
+
23
70
  def li_cleanup(xmldoc)
24
71
  xmldoc.xpath("//li[t]").each do |li|
25
72
  next unless li.elements.size == 1
@@ -93,10 +140,10 @@ module IsoDoc
93
140
 
94
141
  def make_postamble(docxml)
95
142
  docxml.xpath("//figure").each do |f|
96
- a = f&.at("./artwork | ./sourcecode") || next
97
- name = f&.at("./name")&.remove
98
- b = a&.xpath("./preceding-sibling::*")&.remove
99
- c = a&.xpath("./following-sibling::*")&.remove
143
+ a = f.at("./artwork | ./sourcecode") || next
144
+ name = f.at("./name")&.remove
145
+ b = a.xpath("./preceding-sibling::*")&.remove
146
+ c = a.xpath("./following-sibling::*")&.remove
100
147
  a = a.remove
101
148
  name and f << name
102
149
  b.empty? or f << "<preamble>#{to_xml(b)}</preamble>"
@@ -151,18 +198,22 @@ module IsoDoc
151
198
 
152
199
  def annotation_cleanup(docxml)
153
200
  docxml.xpath("//reference").each do |r|
154
- next unless r&.next_element&.name == "aside"
155
-
156
- aside = r.next_element
157
- aside.name = "annotation"
158
- aside.traverse do |n|
159
- n.name == "t" and n.replace(n.children)
201
+ while r.next_element&.name == "aside"
202
+ annotation_cleanup1(r)
160
203
  end
161
- r << aside
162
204
  end
163
205
  docxml.xpath("//references/aside").each(&:remove)
164
206
  end
165
207
 
208
+ def annotation_cleanup1(ref)
209
+ aside = ref.next_element
210
+ aside.name = "annotation"
211
+ aside.traverse do |n|
212
+ n.name == "t" and n.replace(n.children)
213
+ end
214
+ ref << aside
215
+ end
216
+
166
217
  def deflist_cleanup(docxml)
167
218
  dt_cleanup(docxml)
168
219
  dd_cleanup(docxml)
@@ -170,7 +221,7 @@ module IsoDoc
170
221
 
171
222
  def dt_cleanup(docxml)
172
223
  docxml.xpath("//dt").each do |d|
173
- d&.first_element_child&.name == "bookmark" and
224
+ d.first_element_child&.name == "bookmark" and
174
225
  d["anchor"] ||= d.first_element_child["anchor"]
175
226
  d.xpath(".//t").each do |t|
176
227
  d["anchor"] ||= t["anchor"]
@@ -1,11 +1,11 @@
1
+ require_relative "../../relaton/render/general"
2
+
1
3
  module IsoDoc
2
4
  module Ietf
3
5
  class RfcConvert < ::IsoDoc::Convert
4
- def bibliography(isoxml, out)
5
- isoxml.xpath(ns("//references/bibitem/docidentifier")).each do |i|
6
- i.children = docid_prefix(i["type"], i.text)
7
- end
8
- isoxml.xpath(ns("//bibliography/references | " \
6
+ def bibliography(docxml, out)
7
+ bibliography_prep(docxml)
8
+ docxml.xpath(ns("//bibliography/references | " \
9
9
  "//bibliography/clause[.//references] | " \
10
10
  "//annex/clause[.//references] | " \
11
11
  "//annex/references | " \
@@ -14,6 +14,15 @@ module IsoDoc
14
14
  end
15
15
  end
16
16
 
17
+ def bibliography_prep(docxml)
18
+ docxml.xpath(ns("//references/bibitem/docidentifier")).each do |i|
19
+ i.children = docid_prefix(i["type"], i.text)
20
+ end
21
+ @bibrenderer =
22
+ ::Relaton::Render::Ietf::General.new(language: @lang,
23
+ i18nhash: @i18n.get)
24
+ end
25
+
17
26
  def bibliography1(node, out)
18
27
  out.references **attr_code(anchor: node["id"]) do |div|
19
28
  title = node.at(ns("./title")) and div.name do |name|
@@ -29,7 +38,7 @@ module IsoDoc
29
38
  end
30
39
  end
31
40
 
32
- def biblio_list(node, div, biblio)
41
+ def biblio_list(node, div, _biblio)
33
42
  i = 0
34
43
  node.xpath(ns("./bibitem | ./note")).each do |b|
35
44
  next if implicit_reference(b)
@@ -37,133 +46,26 @@ module IsoDoc
37
46
  i += 1 if b.name == "bibitem"
38
47
  if b.name == "note" then note_parse(b, div)
39
48
  else
40
- nonstd_bibitem(div, b, i, biblio)
49
+ ietf_bibitem(div, b, i)
41
50
  end
42
51
  end
43
52
  end
44
53
 
45
- def nonstd_bibitem(list, bib, _ordinal, _bibliography)
54
+ def ietf_bibitem(list, bib, _ordinal)
46
55
  uris = bib.xpath(ns("./uri"))
47
56
  target = nil
48
57
  uris&.each { |u| target = u.text if u["type"] == "src" }
49
58
  list.reference **attr_code(target: target,
50
59
  anchor: bib["id"]) do |r|
51
- nonstd_bibitem_front(r, bib)
52
- uris&.each do |u|
53
- r.format nil, **attr_code(target: u.text, type: u["type"])
54
- end
55
- docidentifier_render(bib, r)
56
- end
60
+ bibitem_render(r, bib)
61
+ end
57
62
  end
58
63
 
59
- def docidentifier_render(bib, out)
60
- docidentifiers = bib.xpath(ns("./docidentifier"))
61
- id = render_identifier(bibitem_ref_code(bib))
62
- !id[:sdo].nil? && id[:sdo] != "(NO ID)" and out.refcontent id[:sdo]
63
- docidentifiers&.each do |u|
64
- u["type"] == "DOI" and
65
- out.seriesInfo nil, **attr_code(value: u.text.sub(/^DOI[  ]/, ""),
66
- name: "DOI")
67
- %w(IETF RFC).include?(u["type"]) and docidentifier_ietf(u, out)
68
- end
69
- end
70
-
71
- def docidentifier_ietf(ident, out)
72
- if /^RFC[  ]/.match?(ident.text)
73
- out.seriesInfo nil, **attr_code(value: ident.text.sub(/^RFC[  ]0*/, ""),
74
- name: "RFC")
75
- elsif /^I-D\./.match?(ident.text)
76
- out.seriesInfo nil, **attr_code(value: ident.text.sub(/^I-D\./, ""),
77
- name: "Internet-Draft")
78
- end
79
- end
80
-
81
- def nonstd_bibitem_front(ref, bib)
82
- ref.front do |f|
83
- relaton_to_title(bib, f)
84
- relaton_to_author(bib, f)
85
- relaton_to_date(bib, f)
86
- relaton_to_keyword(bib, f)
87
- relaton_to_abstract(bib, f)
88
- end
89
- end
90
-
91
- def relaton_to_title(bib, node)
92
- title = bib&.at(ns("./title")) || bib&.at(ns("./formattedref")) or
93
- return
94
- node.title do |t|
95
- title.children.each { |n| parse(n, t) }
96
- end
97
- end
98
-
99
- def relaton_to_author(bib, node)
100
- auths = bib.xpath(ns("./contributor[xmlns:role/@type = 'author' or " \
101
- "xmlns:role/@type = 'editor']"))
102
- auths.empty? and
103
- auths = bib.xpath(ns("./contributor[xmlns:role/@type = " \
104
- "'publisher']"))
105
- auths.each do |a|
106
- role = a.at(ns("./role[@type = 'editor']")) ? "editor" : nil
107
- (p = a&.at(ns("./person/name")) and
108
- relaton_person_to_author(p, role, node)) or
109
- relaton_org_to_author(a&.at(ns("./organization")), role, node)
110
- end
111
- end
112
-
113
- def relaton_person_to_author(pers, role, node)
114
- full = pers.at(ns("./completename"))&.text
115
- surname = pers.at(ns("./surname"))&.text
116
- initials = pers.xpath(ns("./initial"))&.map(&:text)&.join(" ") ||
117
- pers.xpath(ns("./forename"))&.map { |i| i.text[0] }&.join(" ")
118
- initials = nil if initials.empty?
119
- node.author nil, **attr_code(
120
- fullname: full,
121
- asciiFullname: full&.transliterate,
122
- role: role, surname: surname,
123
- initials: initials,
124
- asciiSurname: full ? surname&.transliterate : nil,
125
- asciiInitials: full ? initials&.transliterate : nil
126
- )
127
- end
128
-
129
- def relaton_org_to_author(org, _role, node)
130
- name = org&.at(ns("./name"))&.text
131
- abbrev = org&.at(ns("./abbreviation"))&.text
132
- node.author do |_a|
133
- node.organization name, **attr_code(ascii: name&.transliterate,
134
- abbrev: abbrev)
135
- end
136
- end
137
-
138
- def relaton_to_date(bib, node)
139
- date = bib.at(ns("./date[@type = 'published']")) ||
140
- bib.at(ns("./date[@type = 'issued']")) ||
141
- bib.at(ns("./date[@type = 'circulated']"))
142
- date or return
143
- attr = date_attr(date.at(ns("./on | ./from"))&.text) or return
144
- node.date **attr_code(attr)
145
- end
146
-
147
- def relaton_to_keyword(bib, node)
148
- bib.xpath(ns("./keyword")).each do |k|
149
- node.keyword do |keyword|
150
- k.children.each { |n| parse(n, keyword) }
151
- end
152
- end
153
- end
154
-
155
- def relaton_to_abstract(bib, node)
156
- bib.xpath(ns("./abstract")).each do |k|
157
- node.abstract do |abstract|
158
- if k.at(ns("./p"))
159
- k.children.each { |n| parse(n, abstract) }
160
- else
161
- abstract.t do |t|
162
- k.children.each { |n| parse(n, t) }
163
- end
164
- end
165
- end
166
- end
64
+ def bibitem_render(ref, bib)
65
+ bib1 = bib.clone
66
+ @isodoc.prep_for_rendering(bib1)
67
+ bib1.namespace = nil
68
+ ref << @bibrenderer.render(bib1.to_xml, embedded: true)
167
69
  end
168
70
  end
169
71
  end
@@ -16,6 +16,7 @@ module IsoDoc
16
16
  end
17
17
 
18
18
  def content_validate(xml, filename)
19
+ #return
19
20
  err = []
20
21
  err += numbered_sections_check(xml)
21
22
  err += toc_sections_check(xml)
@@ -346,6 +346,8 @@
346
346
  <ref name="keyword"/>
347
347
  <ref name="xref"/>
348
348
  <ref name="hyperlink"/>
349
+ <ref name="index"/>
350
+ <ref name="index-xref"/>
349
351
  </choice>
350
352
  </oneOrMore>
351
353
  </element>
@@ -623,6 +625,8 @@
623
625
  <ref name="eref"/>
624
626
  <ref name="xref"/>
625
627
  <ref name="hyperlink"/>
628
+ <ref name="index"/>
629
+ <ref name="index-xref"/>
626
630
  </choice>
627
631
  </zeroOrMore>
628
632
  </element>
@@ -636,6 +640,8 @@
636
640
  <ref name="eref"/>
637
641
  <ref name="xref"/>
638
642
  <ref name="hyperlink"/>
643
+ <ref name="index"/>
644
+ <ref name="index-xref"/>
639
645
  </choice>
640
646
  </zeroOrMore>
641
647
  </element>
@@ -648,6 +654,8 @@
648
654
  <ref name="eref"/>
649
655
  <ref name="xref"/>
650
656
  <ref name="hyperlink"/>
657
+ <ref name="index"/>
658
+ <ref name="index-xref"/>
651
659
  </choice>
652
660
  </zeroOrMore>
653
661
  </element>
@@ -655,7 +663,11 @@
655
663
  <define name="keyword">
656
664
  <element name="keyword">
657
665
  <zeroOrMore>
658
- <ref name="PureTextElement"/>
666
+ <choice>
667
+ <ref name="PureTextElement"/>
668
+ <ref name="index"/>
669
+ <ref name="index-xref"/>
670
+ </choice>
659
671
  </zeroOrMore>
660
672
  </element>
661
673
  </define>
@@ -676,7 +688,11 @@
676
688
  <define name="strike">
677
689
  <element name="strike">
678
690
  <zeroOrMore>
679
- <ref name="PureTextElement"/>
691
+ <choice>
692
+ <ref name="PureTextElement"/>
693
+ <ref name="index"/>
694
+ <ref name="index-xref"/>
695
+ </choice>
680
696
  </zeroOrMore>
681
697
  </element>
682
698
  </define>
@@ -898,44 +914,47 @@
898
914
  -->
899
915
  <define name="image">
900
916
  <element name="image">
901
- <attribute name="id">
902
- <data type="ID"/>
917
+ <ref name="Image"/>
918
+ </element>
919
+ </define>
920
+ <define name="Image">
921
+ <attribute name="id">
922
+ <data type="ID"/>
923
+ </attribute>
924
+ <attribute name="src">
925
+ <data type="anyURI"/>
926
+ </attribute>
927
+ <attribute name="mimetype"/>
928
+ <optional>
929
+ <attribute name="filename"/>
930
+ </optional>
931
+ <optional>
932
+ <attribute name="width">
933
+ <choice>
934
+ <data type="int"/>
935
+ <value>auto</value>
936
+ </choice>
903
937
  </attribute>
904
- <attribute name="src">
938
+ </optional>
939
+ <optional>
940
+ <attribute name="height">
941
+ <choice>
942
+ <data type="int"/>
943
+ <value>auto</value>
944
+ </choice>
945
+ </attribute>
946
+ </optional>
947
+ <optional>
948
+ <attribute name="alt"/>
949
+ </optional>
950
+ <optional>
951
+ <attribute name="title"/>
952
+ </optional>
953
+ <optional>
954
+ <attribute name="longdesc">
905
955
  <data type="anyURI"/>
906
956
  </attribute>
907
- <attribute name="mimetype"/>
908
- <optional>
909
- <attribute name="filename"/>
910
- </optional>
911
- <optional>
912
- <attribute name="width">
913
- <choice>
914
- <data type="int"/>
915
- <value>auto</value>
916
- </choice>
917
- </attribute>
918
- </optional>
919
- <optional>
920
- <attribute name="height">
921
- <choice>
922
- <data type="int"/>
923
- <value>auto</value>
924
- </choice>
925
- </attribute>
926
- </optional>
927
- <optional>
928
- <attribute name="alt"/>
929
- </optional>
930
- <optional>
931
- <attribute name="title"/>
932
- </optional>
933
- <optional>
934
- <attribute name="longdesc">
935
- <data type="anyURI"/>
936
- </attribute>
937
- </optional>
938
- </element>
957
+ </optional>
939
958
  </define>
940
959
  <define name="video">
941
960
  <element name="video">
@@ -348,6 +348,9 @@
348
348
  <zeroOrMore>
349
349
  <ref name="contact"/>
350
350
  </zeroOrMore>
351
+ <optional>
352
+ <ref name="logo"/>
353
+ </optional>
351
354
  </element>
352
355
  </define>
353
356
  <define name="orgname">
@@ -366,6 +369,11 @@
366
369
  </choice>
367
370
  </element>
368
371
  </define>
372
+ <define name="logo">
373
+ <element name="logo">
374
+ <ref name="image"/>
375
+ </element>
376
+ </define>
369
377
  <define name="NameWithVariants">
370
378
  <element name="primary">
371
379
  <ref name="LocalizedString"/>
@@ -942,6 +950,7 @@
942
950
  <value>obsoleted</value>
943
951
  <value>confirmed</value>
944
952
  <value>updated</value>
953
+ <value>corrected</value>
945
954
  <value>issued</value>
946
955
  <value>transmitted</value>
947
956
  <value>copied</value>
@@ -1283,7 +1292,7 @@
1283
1292
  <value>mergedInto</value>
1284
1293
  <value>splits</value>
1285
1294
  <value>splitInto</value>
1286
- <value>instance</value>
1295
+ <value>instanceOf</value>
1287
1296
  <value>hasInstance</value>
1288
1297
  <value>exemplarOf</value>
1289
1298
  <value>hasExemplar</value>
@@ -29,7 +29,7 @@ module Metanorma
29
29
 
30
30
  BCP_KEYWORDS = ["MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
31
31
  "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY",
32
- "OPTIONAL"].freeze
32
+ "NOT RECOMMENDED", "OPTIONAL"].freeze
33
33
 
34
34
  def bcp14_cleanup(xmldoc)
35
35
  return unless @bcp_bold
@@ -17,7 +17,7 @@
17
17
  these elements; we just want one namespace for any child grammars
18
18
  of this.
19
19
  -->
20
- <!-- VERSION v1.2.4 -->
20
+ <!-- VERSION v1.2.8 -->
21
21
  <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
22
22
  <include href="reqt.rng"/>
23
23
  <include href="basicdoc.rng">
@@ -485,6 +485,8 @@
485
485
  <choice>
486
486
  <text/>
487
487
  <ref name="callout"/>
488
+ <ref name="xref"/>
489
+ <ref name="eref"/>
488
490
  </choice>
489
491
  </oneOrMore>
490
492
  <zeroOrMore>
@@ -865,6 +867,7 @@
865
867
  <ref name="PureTextElement"/>
866
868
  <ref name="stem"/>
867
869
  <ref name="index"/>
870
+ <ref name="index-xref"/>
868
871
  <ref name="eref"/>
869
872
  <ref name="erefstack"/>
870
873
  <ref name="xref"/>
@@ -880,6 +883,7 @@
880
883
  <ref name="PureTextElement"/>
881
884
  <ref name="stem"/>
882
885
  <ref name="index"/>
886
+ <ref name="index-xref"/>
883
887
  <ref name="eref"/>
884
888
  <ref name="erefstack"/>
885
889
  <ref name="xref"/>
@@ -894,6 +898,7 @@
894
898
  <choice>
895
899
  <ref name="PureTextElement"/>
896
900
  <ref name="index"/>
901
+ <ref name="index-xref"/>
897
902
  <ref name="eref"/>
898
903
  <ref name="erefstack"/>
899
904
  <ref name="xref"/>
@@ -908,6 +913,7 @@
908
913
  <choice>
909
914
  <ref name="PureTextElement"/>
910
915
  <ref name="index"/>
916
+ <ref name="index-xref"/>
911
917
  </choice>
912
918
  </zeroOrMore>
913
919
  </element>
@@ -918,6 +924,7 @@
918
924
  <choice>
919
925
  <ref name="PureTextElement"/>
920
926
  <ref name="index"/>
927
+ <ref name="index-xref"/>
921
928
  </choice>
922
929
  </zeroOrMore>
923
930
  </element>
@@ -928,6 +935,7 @@
928
935
  <choice>
929
936
  <ref name="PureTextElement"/>
930
937
  <ref name="index"/>
938
+ <ref name="index-xref"/>
931
939
  </choice>
932
940
  </zeroOrMore>
933
941
  </element>
@@ -938,6 +946,7 @@
938
946
  <choice>
939
947
  <ref name="PureTextElement"/>
940
948
  <ref name="index"/>
949
+ <ref name="index-xref"/>
941
950
  </choice>
942
951
  </zeroOrMore>
943
952
  </element>
@@ -1004,6 +1013,14 @@
1004
1013
  </oneOrMore>
1005
1014
  </element>
1006
1015
  </define>
1016
+ <define name="BasicBlock" combine="choice">
1017
+ <ref name="columnbreak"/>
1018
+ </define>
1019
+ <define name="columnbreak">
1020
+ <element name="columnbreak">
1021
+ <empty/>
1022
+ </element>
1023
+ </define>
1007
1024
  <define name="MultilingualRenderingType">
1008
1025
  <choice>
1009
1026
  <value>common</value>
@@ -1037,6 +1054,17 @@
1037
1054
  <ref name="date_inline"/>
1038
1055
  </choice>
1039
1056
  </define>
1057
+ <define name="PureTextElement" combine="choice">
1058
+ <ref name="passthrough_inline"/>
1059
+ </define>
1060
+ <define name="passthrough_inline">
1061
+ <element name="passthrough">
1062
+ <optional>
1063
+ <attribute name="formats"/>
1064
+ </optional>
1065
+ <text/>
1066
+ </element>
1067
+ </define>
1040
1068
  <define name="add">
1041
1069
  <element name="add">
1042
1070
  <choice>
@@ -1047,6 +1075,8 @@
1047
1075
  <ref name="keyword"/>
1048
1076
  <ref name="xref"/>
1049
1077
  <ref name="hyperlink"/>
1078
+ <ref name="index"/>
1079
+ <ref name="index-xref"/>
1050
1080
  </choice>
1051
1081
  </element>
1052
1082
  </define>
@@ -1060,6 +1090,8 @@
1060
1090
  <ref name="keyword"/>
1061
1091
  <ref name="xref"/>
1062
1092
  <ref name="hyperlink"/>
1093
+ <ref name="index"/>
1094
+ <ref name="index-xref"/>
1063
1095
  </choice>
1064
1096
  </element>
1065
1097
  </define>
@@ -1071,6 +1103,9 @@
1071
1103
  <optional>
1072
1104
  <attribute name="style"/>
1073
1105
  </optional>
1106
+ <optional>
1107
+ <attribute name="custom-charset"/>
1108
+ </optional>
1074
1109
  <oneOrMore>
1075
1110
  <ref name="TextElement"/>
1076
1111
  </oneOrMore>
@@ -1126,6 +1161,8 @@
1126
1161
  <choice>
1127
1162
  <ref name="PureTextElement"/>
1128
1163
  <ref name="stem"/>
1164
+ <ref name="index"/>
1165
+ <ref name="index-xref"/>
1129
1166
  </choice>
1130
1167
  </zeroOrMore>
1131
1168
  </element>
@@ -1136,6 +1173,8 @@
1136
1173
  <choice>
1137
1174
  <ref name="PureTextElement"/>
1138
1175
  <ref name="stem"/>
1176
+ <ref name="index"/>
1177
+ <ref name="index-xref"/>
1139
1178
  </choice>
1140
1179
  </zeroOrMore>
1141
1180
  </element>
@@ -1369,6 +1408,9 @@
1369
1408
  <optional>
1370
1409
  <attribute name="number"/>
1371
1410
  </optional>
1411
+ <optional>
1412
+ <attribute name="branch-number"/>
1413
+ </optional>
1372
1414
  <optional>
1373
1415
  <attribute name="obligation">
1374
1416
  <choice>
@@ -1592,6 +1634,9 @@
1592
1634
  <optional>
1593
1635
  <attribute name="number"/>
1594
1636
  </optional>
1637
+ <optional>
1638
+ <attribute name="branch-number"/>
1639
+ </optional>
1595
1640
  <optional>
1596
1641
  <attribute name="type"/>
1597
1642
  </optional>
@@ -1643,6 +1688,9 @@
1643
1688
  <optional>
1644
1689
  <attribute name="number"/>
1645
1690
  </optional>
1691
+ <optional>
1692
+ <attribute name="branch-number"/>
1693
+ </optional>
1646
1694
  <optional>
1647
1695
  <ref name="section-title"/>
1648
1696
  </optional>
@@ -1740,6 +1788,9 @@
1740
1788
  <optional>
1741
1789
  <attribute name="number"/>
1742
1790
  </optional>
1791
+ <optional>
1792
+ <attribute name="branch-number"/>
1793
+ </optional>
1743
1794
  <optional>
1744
1795
  <attribute name="obligation">
1745
1796
  <choice>
@@ -58,6 +58,7 @@ module Metanorma
58
58
  end
59
59
 
60
60
  def output(isodoc_node, inname, outname, format, options = {})
61
+ options_preprocess(options)
61
62
  case format
62
63
  when :rfc
63
64
  outname ||= inname.sub(/\.xml$/, ".rfc.xml")
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ietf
3
- VERSION = "3.2.2".freeze
3
+ VERSION = "3.2.4".freeze
4
4
  end
5
5
  end
@@ -0,0 +1,59 @@
1
+ extenttemplate:
2
+ book: "{{ volume }} {{ page }}"
3
+ booklet: book
4
+ proceedings: book
5
+ journal: book
6
+ standard: book
7
+ techreport: book
8
+ inbook: "{{ volume }} {{ page }}"
9
+ misc: "{{ volume }} {{issue}} {{ page }}, {{ duration }}"
10
+ nametemplate:
11
+ one: "{% if nonpersonal[0] %}<author><organization_ascii='{{nonpersonal[0] | ascii }}'{% if nonpersonalabbrev[0] %}_abbrev='{{ nonpersonalabbrev[0]}}'{% endif %}>{{ nonpersonal[0] }}</organization></author>{% else %}{% if surname[0] %}<author_surname='{{surname[0]}}'_asciiSurname='{{surname[0] | ascii }}'_initials='{{initials[0] | join: ''}}'_asciiInitials='{{initials[0] | join: '' | ascii}}'{%if role[0] %}_role='{{role[0]}}'{%endif%}/>{% else %}{% if completename[0] %}<author_fullname='{{completename[0]}}'_asciiFullname='{{completename[0] | ascii }}'{%if role[0] %}_role='{{role[0]}}'{%endif%}/>{% endif %}{% endif %}{% endif %}"
12
+ two: "{% if nonpersonal[0] %}<author><organization_ascii='{{nonpersonal[0] | ascii }}'_abbrev='{{ nonpersonalabbrev[0]}}'>{{ nonpersonal[0] }}</organization></author>{% else %}{% if surname[0] %}<author_surname='{{surname[0]}}'_asciiSurname='{{ surname[0] | ascii }}'_initials='{{initials[0] | join: ''}}'_asciiInitials='{{initials[0] | join: '' | ascii}}'{%if role[0] %}_role='{{role[0]}}'{%endif%}/>{% else %}{% if completename[0] %}<author_fullname='{{completename[0]}}'_asciiFullname='{{completename[0] | ascii }}'{%if role[0] %}_role='{{role[0]}}'{%endif%}/>{% endif %}{% endif %}{% endif %} {% if nonpersonal[1] %}<author><organization_ascii='{{nonpersonal[1] | ascii }}'_abbrev='{{ nonpersonalabbrev[1]}}'>{{ nonpersonal[1] }}</organization></author>{% else %}{% if surname[0] %}<author_surname='{{surname[1]}}'_asciiSurname='{{ surname[1] | ascii }}'_initials='{{initials[1] | join: ''}}'_asciiInitials='{{initials[1] | join: '' | ascii}}'{%if role[1] %}_role='{{role[1]}}'{%endif%}/>{% else %}{% if completename[1] %}<author_fullname='{{completename[1]}}'_asciiFullname='{{completename[1] | ascii }}'{%if role[1] %}_role='{{role[1]}}'{%endif%}/>{% endif %}{%endif%}{% endif %}"
13
+ more: "{% if nonpersonal[0] %}<author><organization_ascii='{{nonpersonal[0] | ascii }}'_abbrev='{{ nonpersonalabbrev[0]}}'>{{ nonpersonal[0] }}</organization></author>{% else %}{% if surname[0] %}<author_surname='{{surname[0]}}'_asciiSurname='{{ surname[0] | ascii }}'_initials='{{initials[0] | join: ''}}'_asciiInitials='{{initials[0] | join: '' | ascii}}'{%if role[0] %}_role='{{role[0]}}'{%endif%}/>{% else %}{% if completename[0] %}<author_fullname='{{completename[0]}}'_asciiFullname='{{completename[0] | ascii }}'{%if role[0] %}_role='{{role[0]}}'{%endif%}/>{% endif %}{% endif %}{%endif%} {% if nonpersonal[1] %}<author><organization_ascii='{{nonpersonal[1] | ascii }}'_abbrev='{{ nonpersonalabbrev[1]}}'>{{ nonpersonal[1] }}</organization></author>{% else %}{%if surname[1] %}<author_surname='{{surname[1]}}'_asciiSurname='{{ surname[1] | ascii }}'_initials='{{initials[1] | join: ''}}'_asciiInitials='{{initials[1] | join: '' | ascii}}'{%if role[1] %}_role='{{role[1]}}'{%endif%}/>{% else %}{% if completename[1] %}<author_fullname='{{completename[1]}}'_asciiFullname='{{completename[1] | ascii }}'{%if role[1] %}_role='{{role[1]}}'{%endif%}/>{% endif %}{% endif %}{% endif %} {% if nonpersonal[2] or nonpersonalabbrev[2] %}<author><organization_ascii='{{nonpersonal[2] | ascii }}'_abbrev='{{ nonpersonalabbrev[2]}}'>{{ nonpersonal[2] }}</organization></author>{% else %}{% if surname[2] %}<author_surname='{{surname[2]}}'_asciiSurname='{{ surname[2] | ascii }}'_initials='{{initials[2] | join: ''}}'_asciiInitials='{{initials[2] | join: '' | ascii}}'{%if role[2] %}_role='{{role[2]}}'{%endif%}/>{% else %}{% if completename[2] %}<author_fullname='{{completename[2]}}'_asciiFullname='{{completename[2] | ascii }}'{%if role[2] %}_role='{{role[2]}}'{%endif%}/>{% endif %}{% endif %}{% endif %}"
14
+ # disabled the following: they should be provided in inheriting calls
15
+ # etal: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] | upcase}} ,_{%if given[0]%}{{given[0]}} {{middle[0]}}{%else%}{{initials[0] | join: ' '}}.{%endif%}{% endif %}, {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{%if given[1]%}{{given[1]}} {{middle[1]}}{%else%}{{initials[1] | join: ' '}}.{%endif%} {{surname[1] | upcase}}{% endif %} <em>et al.</em>"
16
+ # etal_count: 5
17
+ seriestemplate: "{% if series_title and series_num %}<seriesInfo_name='{{ series_title }}'_value='{{series_num}}'/>{% else %}{% if series_formatted %}<refcontent>{{ series_formatted }}</refcontent>{% else %}{% if series_title %}<refcontent> {{series_title}} {{ series_run }} ,_{{ series_org }} ,_{{ series_place }} ,_{{ series_dates }} </refcontent>{% endif %}{% endif %}{% endif %}"
18
+ journaltemplate: "{% if series_title and series_num %}<seriesInfo_name='{{ series_title }}'_value='{{series_num}}'/>{% else %}{% if series_formatted %}<refcontent>{{ series_formatted }}</refcontent>{% else %}{% if series_title %}<refcontent> {{series_title}} {{ series_run }} ,_{{ series_org }} ,_{{ series_place }} ,_{{ series_dates }} </refcontent>{% endif %}{% endif %}{% endif %}"
19
+ template:
20
+ # skip standardidentifier, it is inserted in front of formattedref within metanorma
21
+ # date is cleaned up into RFC XML formatting afterwards
22
+ standard: "<front><title>{{ title }}</title> {{ creatornames }} <date_cleanme='true'>{{date}}</date> {% for k in keywords %}<keyword>{{k}}</keyword>{%endfor%} <abstract_cleanme='true'>{{abstract}}</abstract> </front> {% for u in uris %}<format_target='{{u.content}}'_type='{%if u.type%}{{u.type}}{%else%}HTML{%endif%}'/>{% endfor %} {{ series }} {%for d in doi %}<seriesInfo_value='{{ d | replace: ' ', ' ' | remove_first: 'DOI' | strip }}'_name='DOI'/>{% endfor %} {% if home_standard %}{% for i in authoritative_identifier %} <seriesInfo_value='{{ i | replace: ' ', ' ' | strip | split: ' ' | last | remove_first: 'I-D.'}}'_name='{%if i contains 'I-D.'%}Internet-Draft{% else %}{{ i | replace: ' ', ' ' | strip | split: ' ' | slice: -2 }}{%endif%}'/> {% endfor %} {% else %} <refcontent>{{authoritative_identifier | join: ', '}}</refcontent> {% endif %}"
23
+ website: standard
24
+ book: standard
25
+ booklet: standard
26
+ manual: standard
27
+ techreport: standard
28
+ proceedings: standard
29
+ inbook: standard
30
+ inproceedings: standard
31
+ incollection: standard
32
+ journal: standard
33
+ article: standard
34
+ software: standard
35
+ electronic resource: standard
36
+ dataset: standard
37
+ webresource: standard
38
+ unpublished: standard
39
+ presentation: standard
40
+ thesis: standard
41
+ misc: standard
42
+ # following are # unsupported types:
43
+ map: misc
44
+ audiovisual: misc
45
+ film: misc
46
+ video: misc
47
+ broadcast: misc
48
+ graphic_work: misc
49
+ music: misc
50
+ performance: misc
51
+ patent: misc
52
+ archival: misc
53
+ social_media: misc
54
+ alert: misc
55
+ message: misc
56
+ conversation: misc
57
+ internal: misc
58
+
59
+
@@ -0,0 +1,26 @@
1
+ module Relaton
2
+ module Render
3
+ module Ietf
4
+ class Fields < ::Relaton::Render::Fields
5
+ def nameformat(names)
6
+ names.nil? and return names
7
+ parts = %i(surname initials given middle nonpersonal
8
+ nonpersonalabbrev completename)
9
+ names_out = names.each_with_object({}) do |n, m|
10
+ parts.each do |i|
11
+ m[i] ||= []
12
+ m[i] << n[i]
13
+ end
14
+ end
15
+ @r.nametemplate.render(names_out)
16
+ end
17
+
18
+ # do not format months
19
+ def dateformat(date, _hash)
20
+ date.nil? and return nil
21
+ date_range(date)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,23 @@
1
+ require "relaton-render"
2
+ require_relative "parse"
3
+ require_relative "template"
4
+ require_relative "fields"
5
+
6
+ module Relaton
7
+ module Render
8
+ module Ietf
9
+ class General < ::Relaton::Render::IsoDoc::General
10
+ def config_loc
11
+ YAML.load_file(File.join(File.dirname(__FILE__), "config.yml"))
12
+ end
13
+
14
+ def klass_initialize(_options)
15
+ super
16
+ @parseklass = Relaton::Render::Ietf::Parse
17
+ @nametemplateklass = Relaton::Render::Ietf::Template::Name
18
+ @fieldsklass = Relaton::Render::Ietf::Fields
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,101 @@
1
+ module Relaton
2
+ module Render
3
+ module Ietf
4
+ class Parse < ::Relaton::Render::Parse
5
+ def simple_or_host_xml2hash(doc, host)
6
+ ret = super
7
+ ret.merge(home_standard: home_standard(doc, ret[:publisher_raw]),
8
+ uris: uris(doc), keywords: keywords(doc),
9
+ abstract: abstract(doc))
10
+ end
11
+
12
+ def home_standard(_doc, pubs)
13
+ pubs&.any? do |r|
14
+ ["Internet Engineering Task Force", "IETF", "RFC Publisher"]
15
+ .include?(r[:nonpersonal])
16
+ end
17
+ end
18
+
19
+ # allow publisher for standards
20
+ def creatornames_roles_allowed
21
+ %w(author performer adapter translator editor publisher distributor
22
+ authorizer)
23
+ end
24
+
25
+ def series_xml2hash1(series, doc)
26
+ ret = super
27
+ %w(BCP RFC I-D. Internet-Draft).include?(ret[:series_title]) and return {}
28
+ ret
29
+ end
30
+
31
+ def uris(doc)
32
+ doc.link.map { |u| { content: u.content.to_s.strip, type: u.type } }
33
+ end
34
+
35
+ def keywords(doc)
36
+ doc.keyword.map { |u| content(u) }
37
+ end
38
+
39
+ def abstract(doc)
40
+ doc.abstract.join
41
+ end
42
+
43
+ def extractname(contributor)
44
+ org = contributor.entity if contributor.entity
45
+ .is_a?(RelatonBib::Organization)
46
+ person = contributor.entity if contributor.entity
47
+ .is_a?(RelatonBib::Person)
48
+ if org
49
+ return { nonpersonal: extract_orgname(org),
50
+ nonpersonalabbrev: extract_orgabbrev(org) }
51
+ end
52
+ return extract_personname(person) if person
53
+
54
+ nil
55
+ end
56
+
57
+ def extract_orgabbrev(org)
58
+ content(org.abbreviation)
59
+ end
60
+
61
+ def extract_personname(person)
62
+ surname = person.name.surname
63
+ completename = person.name.completename
64
+ given, middle, initials = given_and_middle_name(person)
65
+ { surname: content(surname),
66
+ completename: content(completename),
67
+ given: given,
68
+ middle: middle,
69
+ initials: initials }.compact
70
+ end
71
+
72
+ # not just year-only
73
+ def date(doc, host)
74
+ ret = date1(doc.date)
75
+ host and ret ||= date1(host.date)
76
+ datepick(ret)
77
+ end
78
+
79
+ # return authors and editors together
80
+ def creatornames1(doc)
81
+ return [] if doc.nil?
82
+
83
+ add1 = pick_contributor(doc, "author") || []
84
+ add2 = pick_contributor(doc, "editor") || []
85
+ cr = add1 + add2
86
+ cr.empty? or return cr
87
+ super
88
+ end
89
+
90
+ # add BCP number
91
+ def authoritative_identifier(doc)
92
+ ret = super
93
+ if bcp = doc.series.detect { |s| s.title.title.content == "BCP" }
94
+ ret.unshift("BCP #{bcp.number}")
95
+ end
96
+ ret.reject { |x| /^(rfc-anchor|Internet-Draft)/.match? (x) }
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,29 @@
1
+ require "sterile"
2
+
3
+ module Relaton
4
+ module Render
5
+ module Template
6
+ module Ascii
7
+ def ascii(ret)
8
+ ret.transliterate
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ module Relaton
16
+ module Render
17
+ module Ietf
18
+ module Template
19
+ class Name < ::Relaton::Render::Template::Name
20
+ def customise_liquid
21
+ super
22
+ ::Liquid::Template
23
+ .register_filter(::Relaton::Render::Template::Ascii)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -37,7 +37,8 @@ Gem::Specification.new do |spec|
37
37
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
38
38
 
39
39
  spec.add_dependency "metanorma-ietf-data"
40
- spec.add_dependency "metanorma-standoc", "~> 2.6.0"
40
+ spec.add_dependency "metanorma-standoc", "~> 2.6.3"
41
+ spec.add_dependency "relaton-render"
41
42
 
42
43
  spec.add_development_dependency "debug"
43
44
  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: 3.2.2
4
+ version: 3.2.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: 2023-09-11 00:00:00.000000000 Z
11
+ date: 2023-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-ietf-data
@@ -30,14 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.6.0
33
+ version: 2.6.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.6.0
40
+ version: 2.6.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: relaton-render
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: debug
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -256,6 +270,11 @@ files:
256
270
  - lib/metanorma/ietf/reqt.rng
257
271
  - lib/metanorma/ietf/validate.rb
258
272
  - lib/metanorma/ietf/version.rb
273
+ - lib/relaton/render/config.yml
274
+ - lib/relaton/render/fields.rb
275
+ - lib/relaton/render/general.rb
276
+ - lib/relaton/render/parse.rb
277
+ - lib/relaton/render/template.rb
259
278
  - metanorma-ietf.gemspec
260
279
  - rfc2629-other.ent
261
280
  - rfc2629-xhtml.ent