metanorma-ietf 3.2.2 → 3.2.3
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 +4 -4
- data/lib/isodoc/ietf/cleanup.rb +50 -9
- data/lib/isodoc/ietf/references.rb +36 -7
- data/lib/isodoc/ietf/validation.rb +1 -0
- data/lib/metanorma/ietf/basicdoc.rng +18 -2
- data/lib/metanorma/ietf/biblio.rng +1 -1
- data/lib/metanorma/ietf/cleanup.rb +1 -1
- data/lib/metanorma/ietf/isodoc.rng +26 -1
- data/lib/metanorma/ietf/processor.rb +1 -0
- data/lib/metanorma/ietf/version.rb +1 -1
- data/lib/relaton/render/config.yml +59 -0
- data/lib/relaton/render/fields.rb +26 -0
- data/lib/relaton/render/general.rb +23 -0
- data/lib/relaton/render/parse.rb +86 -0
- data/lib/relaton/render/template.rb +29 -0
- data/metanorma-ietf.gemspec +1 -0
- metadata +21 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44f82a2e2531457841566622014de866954e414a6fcdb4a21ca279ab21d4254e
|
4
|
+
data.tar.gz: ccfb59ff0df711e0994398124e61ad7d132a9142e53fb53b6feb75a5c8c3feac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3cf1a3627c0dc5a7a380c9cf0c3504941d6e23bf8a23d6d7c2b3430b1ef27039fd9b37cfb40a383ce0ef3714dfa5462f8d70acd471debe474e90b14c6ebfd2d
|
7
|
+
data.tar.gz: 75321da1a28864666a818e95130e16156aa7ebf582a5d184106aa8ccb798ae50cf3d10cec0379ed3a3cb48e6b24cc495adef8d5400d19d9825f0b1579f8a93ce
|
data/lib/isodoc/ietf/cleanup.rb
CHANGED
@@ -9,17 +9,54 @@ 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
|
+
annotation_cleanup(xmldoc)
|
27
|
+
end
|
28
|
+
|
29
|
+
def biblio_date_cleanup(xmldoc)
|
30
|
+
xmldoc.xpath("//date[@cleanme]").each do |a|
|
31
|
+
a.delete("cleanme")
|
32
|
+
d = @c.decode(a.text).gsub(/–/, "-").sub(/-\d\d\d\d.*$/, "")
|
33
|
+
if attrs = date_attr(d)
|
34
|
+
attrs.each do |k, v|
|
35
|
+
a[k] = v
|
36
|
+
end
|
37
|
+
a.children.remove
|
38
|
+
else a.remove end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def biblio_abstract_cleanup(xmldoc)
|
43
|
+
xmldoc.xpath("//abstract[@cleanme]").each do |a|
|
44
|
+
a.delete("cleanme")
|
45
|
+
ret = reparse_abstract(a)
|
46
|
+
a.children = if a.at("./p") then ret
|
47
|
+
else "<t>#{ret}</t>"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def reparse_abstract(abstract)
|
53
|
+
a1 = Nokogiri::XML(abstract.dup.to_xml
|
54
|
+
.sub("<abstract>", "<abstract xmlns='http://www.example.com'>")).root
|
55
|
+
noko do |xml|
|
56
|
+
a1.children.each { |n| parse(n, xml) }
|
57
|
+
end.join
|
58
|
+
end
|
59
|
+
|
23
60
|
def li_cleanup(xmldoc)
|
24
61
|
xmldoc.xpath("//li[t]").each do |li|
|
25
62
|
next unless li.elements.size == 1
|
@@ -151,18 +188,22 @@ module IsoDoc
|
|
151
188
|
|
152
189
|
def annotation_cleanup(docxml)
|
153
190
|
docxml.xpath("//reference").each do |r|
|
154
|
-
|
155
|
-
|
156
|
-
aside = r.next_element
|
157
|
-
aside.name = "annotation"
|
158
|
-
aside.traverse do |n|
|
159
|
-
n.name == "t" and n.replace(n.children)
|
191
|
+
while r.next_element&.name == "aside"
|
192
|
+
annotation_cleanup1(r)
|
160
193
|
end
|
161
|
-
r << aside
|
162
194
|
end
|
163
195
|
docxml.xpath("//references/aside").each(&:remove)
|
164
196
|
end
|
165
197
|
|
198
|
+
def annotation_cleanup1(ref)
|
199
|
+
aside = ref.next_element
|
200
|
+
aside.name = "annotation"
|
201
|
+
aside.traverse do |n|
|
202
|
+
n.name == "t" and n.replace(n.children)
|
203
|
+
end
|
204
|
+
ref << aside
|
205
|
+
end
|
206
|
+
|
166
207
|
def deflist_cleanup(docxml)
|
167
208
|
dt_cleanup(docxml)
|
168
209
|
dd_cleanup(docxml)
|
@@ -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(
|
5
|
-
|
6
|
-
|
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,
|
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,11 +46,30 @@ 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
|
-
|
49
|
+
ietf_bibitem(div, b, i)
|
41
50
|
end
|
42
51
|
end
|
43
52
|
end
|
44
53
|
|
54
|
+
def ietf_bibitem(list, bib, _ordinal)
|
55
|
+
uris = bib.xpath(ns("./uri"))
|
56
|
+
target = nil
|
57
|
+
uris&.each { |u| target = u.text if u["type"] == "src" }
|
58
|
+
list.reference **attr_code(target: target,
|
59
|
+
anchor: bib["id"]) do |r|
|
60
|
+
bibitem_render(r, bib)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
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)
|
69
|
+
end
|
70
|
+
|
71
|
+
=begin
|
72
|
+
|
45
73
|
def nonstd_bibitem(list, bib, _ordinal, _bibliography)
|
46
74
|
uris = bib.xpath(ns("./uri"))
|
47
75
|
target = nil
|
@@ -165,6 +193,7 @@ module IsoDoc
|
|
165
193
|
end
|
166
194
|
end
|
167
195
|
end
|
196
|
+
=end
|
168
197
|
end
|
169
198
|
end
|
170
199
|
end
|
@@ -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
|
-
<
|
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
|
-
<
|
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>
|
@@ -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.
|
20
|
+
<!-- VERSION v1.2.6 -->
|
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>
|
@@ -1047,6 +1064,8 @@
|
|
1047
1064
|
<ref name="keyword"/>
|
1048
1065
|
<ref name="xref"/>
|
1049
1066
|
<ref name="hyperlink"/>
|
1067
|
+
<ref name="index"/>
|
1068
|
+
<ref name="index-xref"/>
|
1050
1069
|
</choice>
|
1051
1070
|
</element>
|
1052
1071
|
</define>
|
@@ -1060,6 +1079,8 @@
|
|
1060
1079
|
<ref name="keyword"/>
|
1061
1080
|
<ref name="xref"/>
|
1062
1081
|
<ref name="hyperlink"/>
|
1082
|
+
<ref name="index"/>
|
1083
|
+
<ref name="index-xref"/>
|
1063
1084
|
</choice>
|
1064
1085
|
</element>
|
1065
1086
|
</define>
|
@@ -1126,6 +1147,8 @@
|
|
1126
1147
|
<choice>
|
1127
1148
|
<ref name="PureTextElement"/>
|
1128
1149
|
<ref name="stem"/>
|
1150
|
+
<ref name="index"/>
|
1151
|
+
<ref name="index-xref"/>
|
1129
1152
|
</choice>
|
1130
1153
|
</zeroOrMore>
|
1131
1154
|
</element>
|
@@ -1136,6 +1159,8 @@
|
|
1136
1159
|
<choice>
|
1137
1160
|
<ref name="PureTextElement"/>
|
1138
1161
|
<ref name="stem"/>
|
1162
|
+
<ref name="index"/>
|
1163
|
+
<ref name="index-xref"/>
|
1139
1164
|
</choice>
|
1140
1165
|
</zeroOrMore>
|
1141
1166
|
</element>
|
@@ -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] | dfhdsjfhsajdkfgkj }}'{% 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_formatted %}{{ series_formatted }}{%else%}{% if series_abbr %}{{series_abbr}}{% else %}{{series_title}}{% endif %} ({{series_run}}) {{series_num}}|({{series_partnumber}}){%endif%}"
|
18
|
+
journaltemplate: "<em>{% if series_abbr %}{{series_abbr}}{% else %}{{series_title}}{% endif %}</em> ({{series_run}}) {{ labels['volume'] }}_{{series_num}} {{ labels['part'] }}_{{series_partnumber}}"
|
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 %} {%for d in doi %}<seriesInfo value='{{ d | replace: ' ', ' ' | remove_first: 'DOI' | strip }}' name='DOI'/>{% endfor %} {%if authoritative_identifier[0]%}{%if home_standard %}<seriesInfo value='{{ authoritative_identifier[0] | remove_first: 'IETF' | remove_first: 'RFC' | remove_first: 'I-D.' | replace: ' ', ' ' | strip}}' name='{%if authoritative_identifier[0] contains 'RFC'%}RFC{%endif%}{%if authoritative_identifier[0] contains 'I-D.'%}Internet-Draft{%endif%}'/>{% else %}<refcontent>{{authoritative_identifier[0]}}</refcontent>{% endif %}{%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,86 @@
|
|
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"]
|
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 uris(doc)
|
26
|
+
doc.link.map { |u| { content: u.content.to_s.strip, type: u.type } }
|
27
|
+
end
|
28
|
+
|
29
|
+
def keywords(doc)
|
30
|
+
doc.keyword.map { |u| content(u) }
|
31
|
+
end
|
32
|
+
|
33
|
+
def abstract(doc)
|
34
|
+
doc.abstract.join
|
35
|
+
end
|
36
|
+
|
37
|
+
def extractname(contributor)
|
38
|
+
org = contributor.entity if contributor.entity
|
39
|
+
.is_a?(RelatonBib::Organization)
|
40
|
+
person = contributor.entity if contributor.entity
|
41
|
+
.is_a?(RelatonBib::Person)
|
42
|
+
if org
|
43
|
+
return { nonpersonal: extract_orgname(org),
|
44
|
+
nonpersonalabbrev: extract_orgabbrev(org) }
|
45
|
+
end
|
46
|
+
return extract_personname(person) if person
|
47
|
+
|
48
|
+
nil
|
49
|
+
end
|
50
|
+
|
51
|
+
def extract_orgabbrev(org)
|
52
|
+
content(org.abbreviation)
|
53
|
+
end
|
54
|
+
|
55
|
+
def extract_personname(person)
|
56
|
+
surname = person.name.surname
|
57
|
+
completename = person.name.completename
|
58
|
+
given, middle, initials = given_and_middle_name(person)
|
59
|
+
{ surname: content(surname),
|
60
|
+
completename: content(completename),
|
61
|
+
given: given,
|
62
|
+
middle: middle,
|
63
|
+
initials: initials }.compact
|
64
|
+
end
|
65
|
+
|
66
|
+
# not just year-only
|
67
|
+
def date(doc, host)
|
68
|
+
ret = date1(doc.date)
|
69
|
+
host and ret ||= date1(host.date)
|
70
|
+
datepick(ret)
|
71
|
+
end
|
72
|
+
|
73
|
+
# return authors and editors together
|
74
|
+
def creatornames1(doc)
|
75
|
+
return [] if doc.nil?
|
76
|
+
|
77
|
+
add1 = pick_contributor(doc, "author") || []
|
78
|
+
add2 = pick_contributor(doc, "editor") || []
|
79
|
+
cr = add1 + add2
|
80
|
+
cr.empty? or return cr
|
81
|
+
super
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
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
|
data/metanorma-ietf.gemspec
CHANGED
@@ -38,6 +38,7 @@ Gem::Specification.new do |spec|
|
|
38
38
|
|
39
39
|
spec.add_dependency "metanorma-ietf-data"
|
40
40
|
spec.add_dependency "metanorma-standoc", "~> 2.6.0"
|
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.
|
4
|
+
version: 3.2.3
|
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-
|
11
|
+
date: 2023-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: metanorma-ietf-data
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.6.0
|
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
|