metanorma-standoc 2.1.2 → 2.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/metanorma/standoc/biblio.rng +102 -5
- data/lib/metanorma/standoc/blocks.rb +3 -6
- data/lib/metanorma/standoc/blocks_notes.rb +1 -1
- data/lib/metanorma/standoc/cleanup.rb +3 -1
- data/lib/metanorma/standoc/cleanup_block.rb +41 -1
- data/lib/metanorma/standoc/cleanup_footnotes.rb +19 -17
- data/lib/metanorma/standoc/cleanup_ref.rb +16 -0
- data/lib/metanorma/standoc/cleanup_section.rb +6 -0
- data/lib/metanorma/standoc/cleanup_terms.rb +6 -2
- data/lib/metanorma/standoc/cleanup_xref.rb +2 -1
- data/lib/metanorma/standoc/converter.rb +2 -0
- data/lib/metanorma/standoc/isodoc.rng +33 -0
- data/lib/metanorma/standoc/macros_note.rb +26 -0
- data/lib/metanorma/standoc/ref.rb +3 -1
- data/lib/metanorma/standoc/ref_sect.rb +5 -2
- data/lib/metanorma/standoc/ref_utility.rb +20 -6
- data/lib/metanorma/standoc/section.rb +3 -1
- data/lib/metanorma/standoc/term_lookup_cleanup.rb +1 -1
- data/lib/metanorma/standoc/utils.rb +1 -1
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +1 -1
- data/spec/examples/datamodel/address_class_profile.presentation.xml +14 -0
- data/spec/metanorma/blocks_spec.rb +55 -0
- data/spec/metanorma/cleanup_blocks_spec.rb +83 -0
- data/spec/metanorma/cleanup_sections_spec.rb +55 -4
- data/spec/metanorma/cleanup_spec.rb +1 -1
- data/spec/metanorma/isobib_cache_spec.rb +6 -4
- data/spec/metanorma/macros_spec.rb +36 -8
- data/spec/metanorma/refs_dl_spec.rb +18 -7
- data/spec/metanorma/refs_spec.rb +252 -281
- data/spec/metanorma/validate_spec.rb +60 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/vcr_cassettes/bsi16341.yml +58 -72
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +98 -98
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +14 -14
- data/spec/vcr_cassettes/hide_refs.yml +57 -57
- data/spec/vcr_cassettes/isobib_get_123.yml +13 -13
- data/spec/vcr_cassettes/isobib_get_123_1.yml +27 -27
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +36 -36
- data/spec/vcr_cassettes/isobib_get_123_2.yml +295 -0
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +13 -13
- data/spec/vcr_cassettes/isobib_get_124.yml +13 -13
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +228 -52
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +46 -46
- data/spec/vcr_cassettes/std-link.yml +13 -71
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9487b5701cc86946c27e560e244cc4f84fceb61b0a93dd271068875654eb49a0
|
4
|
+
data.tar.gz: c647cf6fb530aba3bc96c9087e7a9d49408ce239a6c6aa3a4a46a0e8cf1a5763
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8356539be6d28f5dc6d4d148cfcabb8ed7dbc033392544d382d36e1e392e33da6b29a64b535f6c24cdab85a4d17d1dc5698367f0edff8f45eb02b1f8ed97330
|
7
|
+
data.tar.gz: 13c49550edea0d6169fef67357a5030e146cdf62fec3cb41900db7490d95c09f9dbb1c4f4b55bea4836651ba11fcaf0714b20f37fc3a96a48dd31596cf564549
|
@@ -623,6 +623,97 @@
|
|
623
623
|
<zeroOrMore>
|
624
624
|
<ref name="bsource"/>
|
625
625
|
</zeroOrMore>
|
626
|
+
<oneOrMore>
|
627
|
+
<ref name="docidentifier"/>
|
628
|
+
</oneOrMore>
|
629
|
+
<optional>
|
630
|
+
<ref name="docnumber"/>
|
631
|
+
</optional>
|
632
|
+
<zeroOrMore>
|
633
|
+
<ref name="bdate"/>
|
634
|
+
</zeroOrMore>
|
635
|
+
<zeroOrMore>
|
636
|
+
<ref name="contributor"/>
|
637
|
+
</zeroOrMore>
|
638
|
+
<optional>
|
639
|
+
<ref name="edition"/>
|
640
|
+
</optional>
|
641
|
+
<zeroOrMore>
|
642
|
+
<ref name="version"/>
|
643
|
+
</zeroOrMore>
|
644
|
+
<zeroOrMore>
|
645
|
+
<ref name="biblionote"/>
|
646
|
+
</zeroOrMore>
|
647
|
+
<zeroOrMore>
|
648
|
+
<ref name="language"/>
|
649
|
+
</zeroOrMore>
|
650
|
+
<zeroOrMore>
|
651
|
+
<ref name="script"/>
|
652
|
+
</zeroOrMore>
|
653
|
+
<zeroOrMore>
|
654
|
+
<ref name="bibabstract"/>
|
655
|
+
</zeroOrMore>
|
656
|
+
<optional>
|
657
|
+
<ref name="status"/>
|
658
|
+
</optional>
|
659
|
+
<zeroOrMore>
|
660
|
+
<ref name="copyright"/>
|
661
|
+
</zeroOrMore>
|
662
|
+
<zeroOrMore>
|
663
|
+
<ref name="docrelation"/>
|
664
|
+
</zeroOrMore>
|
665
|
+
<zeroOrMore>
|
666
|
+
<ref name="series"/>
|
667
|
+
</zeroOrMore>
|
668
|
+
<optional>
|
669
|
+
<ref name="medium"/>
|
670
|
+
</optional>
|
671
|
+
<zeroOrMore>
|
672
|
+
<ref name="bplace"/>
|
673
|
+
</zeroOrMore>
|
674
|
+
<zeroOrMore>
|
675
|
+
<ref name="bprice"/>
|
676
|
+
</zeroOrMore>
|
677
|
+
<zeroOrMore>
|
678
|
+
<ref name="extent"/>
|
679
|
+
</zeroOrMore>
|
680
|
+
<optional>
|
681
|
+
<ref name="bibliographic_size"/>
|
682
|
+
</optional>
|
683
|
+
<zeroOrMore>
|
684
|
+
<ref name="accesslocation"/>
|
685
|
+
</zeroOrMore>
|
686
|
+
<zeroOrMore>
|
687
|
+
<ref name="license"/>
|
688
|
+
</zeroOrMore>
|
689
|
+
<zeroOrMore>
|
690
|
+
<ref name="bclassification"/>
|
691
|
+
</zeroOrMore>
|
692
|
+
<zeroOrMore>
|
693
|
+
<ref name="bkeyword"/>
|
694
|
+
</zeroOrMore>
|
695
|
+
<optional>
|
696
|
+
<ref name="validity"/>
|
697
|
+
</optional>
|
698
|
+
</define>
|
699
|
+
<define name="ReducedBibliographicItem">
|
700
|
+
<optional>
|
701
|
+
<attribute name="type">
|
702
|
+
<ref name="BibItemType"/>
|
703
|
+
</attribute>
|
704
|
+
</optional>
|
705
|
+
<optional>
|
706
|
+
<ref name="fetched"/>
|
707
|
+
</optional>
|
708
|
+
<optional>
|
709
|
+
<ref name="formattedref"/>
|
710
|
+
</optional>
|
711
|
+
<zeroOrMore>
|
712
|
+
<ref name="btitle"/>
|
713
|
+
</zeroOrMore>
|
714
|
+
<zeroOrMore>
|
715
|
+
<ref name="bsource"/>
|
716
|
+
</zeroOrMore>
|
626
717
|
<zeroOrMore>
|
627
718
|
<ref name="docidentifier"/>
|
628
719
|
</zeroOrMore>
|
@@ -638,9 +729,9 @@
|
|
638
729
|
<optional>
|
639
730
|
<ref name="edition"/>
|
640
731
|
</optional>
|
641
|
-
<
|
732
|
+
<zeroOrMore>
|
642
733
|
<ref name="version"/>
|
643
|
-
</
|
734
|
+
</zeroOrMore>
|
644
735
|
<zeroOrMore>
|
645
736
|
<ref name="biblionote"/>
|
646
737
|
</zeroOrMore>
|
@@ -833,6 +924,12 @@
|
|
833
924
|
<data type="boolean"/>
|
834
925
|
</attribute>
|
835
926
|
</optional>
|
927
|
+
<optional>
|
928
|
+
<attribute name="language"/>
|
929
|
+
</optional>
|
930
|
+
<optional>
|
931
|
+
<attribute name="script"/>
|
932
|
+
</optional>
|
836
933
|
<text/>
|
837
934
|
</element>
|
838
935
|
</define>
|
@@ -1172,7 +1269,7 @@
|
|
1172
1269
|
</element>
|
1173
1270
|
</optional>
|
1174
1271
|
<element name="bibitem">
|
1175
|
-
<ref name="
|
1272
|
+
<ref name="ReducedBibliographicItem"/>
|
1176
1273
|
</element>
|
1177
1274
|
<choice>
|
1178
1275
|
<zeroOrMore>
|
@@ -1197,9 +1294,9 @@
|
|
1197
1294
|
<optional>
|
1198
1295
|
<ref name="revision-date"/>
|
1199
1296
|
</optional>
|
1200
|
-
<
|
1297
|
+
<optional>
|
1201
1298
|
<ref name="draft"/>
|
1202
|
-
</
|
1299
|
+
</optional>
|
1203
1300
|
</element>
|
1204
1301
|
</define>
|
1205
1302
|
<define name="vedition">
|
@@ -38,9 +38,7 @@ module Metanorma
|
|
38
38
|
role == "form" and return form(node)
|
39
39
|
role == "definition" and return termdefinition(node)
|
40
40
|
result = []
|
41
|
-
node.blocks.each
|
42
|
-
result << send(b.context, b)
|
43
|
-
end
|
41
|
+
node.blocks.each { |b| result << send(b.context, b) }
|
44
42
|
result
|
45
43
|
end
|
46
44
|
|
@@ -82,7 +80,7 @@ module Metanorma
|
|
82
80
|
noko do |xml|
|
83
81
|
xml.termexample **attr_code(id_attr(node)
|
84
82
|
.merge(
|
85
|
-
keepasterm: node.option?("termexample")
|
83
|
+
keepasterm: node.option?("termexample") || nil,
|
86
84
|
)) do |ex|
|
87
85
|
wrap_in_para(node, ex)
|
88
86
|
end
|
@@ -244,8 +242,7 @@ module Metanorma
|
|
244
242
|
noko do |xml|
|
245
243
|
xml.passthrough **attr_code(formats:
|
246
244
|
node.attr("format") || "metanorma") do |p|
|
247
|
-
p << c.encode(c.decode(node.content),
|
248
|
-
:basic, :hexadecimal)
|
245
|
+
p << c.encode(c.decode(node.content), :basic, :hexadecimal)
|
249
246
|
end
|
250
247
|
end
|
251
248
|
end
|
@@ -94,7 +94,7 @@ module Metanorma
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def admonition(node)
|
97
|
-
return termnote(node) if in_terms?
|
97
|
+
return termnote(node) if in_terms? && node.attr("name") == "note"
|
98
98
|
return note(node) if node.attr("name") == "note"
|
99
99
|
return todo(node) if node.attr("name") == "todo"
|
100
100
|
|
@@ -28,6 +28,8 @@ module Metanorma
|
|
28
28
|
passthrough_cleanup(xmldoc)
|
29
29
|
sections_cleanup(xmldoc)
|
30
30
|
obligations_cleanup(xmldoc)
|
31
|
+
para_index_cleanup(xmldoc)
|
32
|
+
block_index_cleanup(xmldoc)
|
31
33
|
table_cleanup(xmldoc)
|
32
34
|
formula_cleanup(xmldoc)
|
33
35
|
form_cleanup(xmldoc)
|
@@ -51,7 +53,7 @@ module Metanorma
|
|
51
53
|
termdef_cleanup(xmldoc)
|
52
54
|
RelatonIev::iev_cleanup(xmldoc, @bibdb)
|
53
55
|
element_name_cleanup(xmldoc)
|
54
|
-
|
56
|
+
term_index_cleanup(xmldoc)
|
55
57
|
bpart_cleanup(xmldoc)
|
56
58
|
quotesource_cleanup(xmldoc)
|
57
59
|
callout_cleanup(xmldoc)
|
@@ -66,7 +66,7 @@ module Metanorma
|
|
66
66
|
def subfigure_cleanup(xmldoc)
|
67
67
|
xmldoc.xpath("//example[figure]").each do |e|
|
68
68
|
next unless e.elements.map(&:name).reject do |m|
|
69
|
-
%w(name figure).include? m
|
69
|
+
%w(name figure index).include? m
|
70
70
|
end.empty?
|
71
71
|
|
72
72
|
e.name = "figure"
|
@@ -178,6 +178,46 @@ module Metanorma
|
|
178
178
|
end
|
179
179
|
end
|
180
180
|
end
|
181
|
+
|
182
|
+
def block_index_cleanup(xmldoc)
|
183
|
+
xmldoc.xpath("//quote | //td | //th | //formula | //li | //dt | "\
|
184
|
+
"//dd | //example | //note | //figure | //sourcecode | "\
|
185
|
+
"//admonition | //termnote | //termexample | //form | "\
|
186
|
+
"//requirement | //recommendation | //permission | "\
|
187
|
+
"//imagemap | //svgmap").each do |b|
|
188
|
+
b.xpath("./p[indexterm]").each do |p|
|
189
|
+
indexterm_para?(p) or next
|
190
|
+
p.replace(p.children)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
def indexterm_para?(para)
|
196
|
+
p = para.dup
|
197
|
+
p.xpath("./index").each(&:remove)
|
198
|
+
p.text.strip.empty?
|
199
|
+
end
|
200
|
+
|
201
|
+
def include_indexterm?(elem)
|
202
|
+
return false if elem.nil?
|
203
|
+
|
204
|
+
!%w(image literal sourcecode).include?(elem.name)
|
205
|
+
end
|
206
|
+
|
207
|
+
def para_index_cleanup(xmldoc)
|
208
|
+
xmldoc.xpath("//p[index]").select { |p| indexterm_para?(p) }
|
209
|
+
.each do |p|
|
210
|
+
para_index_cleanup1(p, p.previous_element, p.next_element)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
def para_index_cleanup1(para, prev, foll)
|
215
|
+
if include_indexterm?(prev)
|
216
|
+
prev << para.remove.children
|
217
|
+
elsif include_indexterm?(foll) && !foll.children.empty?
|
218
|
+
foll.children.first.previous = para.remove.children
|
219
|
+
end
|
220
|
+
end
|
181
221
|
end
|
182
222
|
end
|
183
223
|
end
|
@@ -13,14 +13,16 @@ module Metanorma
|
|
13
13
|
c.gsub(/ id="[^"]+"/, "")
|
14
14
|
end
|
15
15
|
|
16
|
+
FIGURE_FN_XPATH =
|
17
|
+
"//figure/following-sibling::*[1][self::p and *[1][self::fn]]".freeze
|
18
|
+
|
16
19
|
# include footnotes inside figure if they are the only content
|
17
20
|
# of the paras following
|
18
21
|
def figure_footnote_cleanup(xmldoc)
|
19
22
|
nomatches = false
|
20
23
|
until nomatches
|
21
|
-
q = "//figure/following-sibling::*[1][self::p and *[1][self::fn]]"
|
22
24
|
nomatches = true
|
23
|
-
xmldoc.xpath(
|
25
|
+
xmldoc.xpath(FIGURE_FN_XPATH).each do |s|
|
24
26
|
next if s.children.map do |c|
|
25
27
|
c.text? && /[[:alpha:]]/.match(c.text)
|
26
28
|
end.any?
|
@@ -32,17 +34,17 @@ module Metanorma
|
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
35
|
-
def table_footnote_renumber1(fnote,
|
37
|
+
def table_footnote_renumber1(fnote, idx, seen)
|
36
38
|
content = footnote_content(fnote)
|
37
39
|
if seen[content] then outnum = seen[content]
|
38
40
|
else
|
39
|
-
|
40
|
-
outnum =
|
41
|
+
idx += 1
|
42
|
+
outnum = idx
|
41
43
|
seen[content] = outnum
|
42
44
|
end
|
43
45
|
fnote["reference"] = (outnum - 1 + "a".ord).chr
|
44
46
|
fnote["table"] = true
|
45
|
-
[
|
47
|
+
[idx, seen]
|
46
48
|
end
|
47
49
|
|
48
50
|
def table_footnote_renumber(xmldoc)
|
@@ -55,18 +57,18 @@ module Metanorma
|
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
58
|
-
def other_footnote_renumber1(
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
fn["reference"] = outnum.to_s
|
60
|
+
def other_footnote_renumber1(fnote, idx, seen)
|
61
|
+
return [idx, seen] if fnote["table"]
|
62
|
+
|
63
|
+
content = footnote_content(fnote)
|
64
|
+
if seen[content] then outnum = seen[content]
|
65
|
+
else
|
66
|
+
idx += 1
|
67
|
+
outnum = idx
|
68
|
+
seen[content] = outnum
|
68
69
|
end
|
69
|
-
[
|
70
|
+
fnote["reference"] = outnum.to_s
|
71
|
+
[idx, seen]
|
70
72
|
end
|
71
73
|
|
72
74
|
def other_footnote_renumber(xmldoc)
|
@@ -80,6 +80,7 @@ module Metanorma
|
|
80
80
|
|
81
81
|
def biblio_cleanup(xmldoc)
|
82
82
|
biblio_reorder(xmldoc)
|
83
|
+
biblio_annex(xmldoc)
|
83
84
|
biblio_nested(xmldoc)
|
84
85
|
biblio_renumber(xmldoc)
|
85
86
|
biblio_linkonly(xmldoc)
|
@@ -119,6 +120,16 @@ module Metanorma
|
|
119
120
|
xmldoc.xpath("//bibitem/ext").each(&:remove)
|
120
121
|
end
|
121
122
|
|
123
|
+
def biblio_annex(xmldoc)
|
124
|
+
xmldoc.xpath("//annex[references/references]").each do |t|
|
125
|
+
next unless t.xpath("./clause | ./references | ./terms").size == 1
|
126
|
+
|
127
|
+
r = t.at("./references")
|
128
|
+
r.xpath("./references").each { |b| b["normative"] = r["normative"] }
|
129
|
+
r.replace(r.elements)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
122
133
|
def biblio_nested(xmldoc)
|
123
134
|
xmldoc.xpath("//references[references]").each do |t|
|
124
135
|
t.name = "clause"
|
@@ -143,6 +154,11 @@ module Metanorma
|
|
143
154
|
def reference_names(xmldoc)
|
144
155
|
xmldoc.xpath("//bibitem[not(ancestor::bibitem)]").each do |ref|
|
145
156
|
docid = ref.at("./docidentifier[@type = 'metanorma']") ||
|
157
|
+
ref.at("./docidentifier[@primary = 'true'][@language = '#{@lang}']") ||
|
158
|
+
ref.at("./docidentifier[@primary = 'true'][not(@language)]") ||
|
159
|
+
ref.at("./docidentifier[@primary = 'true']") ||
|
160
|
+
ref.at("./docidentifier[not(@type = 'DOI')][@language = '#{@lang}']") ||
|
161
|
+
ref.at("./docidentifier[not(@type = 'DOI')][not(@language)]") ||
|
146
162
|
ref.at("./docidentifier[not(@type = 'DOI')]") or next
|
147
163
|
reference = format_ref(docid.children.to_xml, docid["type"])
|
148
164
|
@anchors[ref["id"]] = { xref: reference }
|
@@ -118,6 +118,12 @@ module Metanorma
|
|
118
118
|
change_clauses(xml)
|
119
119
|
end
|
120
120
|
|
121
|
+
def single_clause_annex(xml)
|
122
|
+
xml.xpath("//annex").each do |a|
|
123
|
+
single_clause_annex1(a)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
121
127
|
def obligations_cleanup(xml)
|
122
128
|
obligations_cleanup_info(xml)
|
123
129
|
obligations_cleanup_norm(xml)
|
@@ -100,9 +100,13 @@ module Metanorma
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
+
def termlookup_cleanup(xmldoc)
|
104
|
+
Metanorma::Standoc::TermLookupCleanup.new(xmldoc, @log).call
|
105
|
+
end
|
106
|
+
|
103
107
|
def termdef_cleanup(xmldoc)
|
104
108
|
termdef_unnest_cleanup(xmldoc)
|
105
|
-
|
109
|
+
termlookup_cleanup(xmldoc)
|
106
110
|
term_nonverbal_designations(xmldoc)
|
107
111
|
term_dl_to_metadata(xmldoc)
|
108
112
|
term_termsource_to_designation(xmldoc)
|
@@ -117,7 +121,7 @@ module Metanorma
|
|
117
121
|
termdocsource_cleanup(xmldoc)
|
118
122
|
end
|
119
123
|
|
120
|
-
def
|
124
|
+
def term_index_cleanup(xmldoc)
|
121
125
|
return unless @index_terms
|
122
126
|
|
123
127
|
xmldoc.xpath("//preferred").each do |p|
|
@@ -68,9 +68,10 @@ module Metanorma
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def xref_to_eref(elem)
|
71
|
+
c = HTMLEntities.new
|
71
72
|
elem["bibitemid"] = elem["target"]
|
72
73
|
if ref = @anchors&.dig(elem["target"], :xref)
|
73
|
-
elem["citeas"] =
|
74
|
+
elem["citeas"] = c.decode(ref)
|
74
75
|
else
|
75
76
|
elem["citeas"] = ""
|
76
77
|
xref_to_eref1(elem)
|
@@ -59,6 +59,8 @@ module Metanorma
|
|
59
59
|
inline_macro Metanorma::Plugin::Lutaml::LutamlTableInlineMacro
|
60
60
|
block_macro Metanorma::Plugin::Lutaml::LutamlDiagramBlockMacro
|
61
61
|
block Metanorma::Standoc::ToDoAdmonitionBlock
|
62
|
+
block Metanorma::Standoc::EditorAdmonitionBlock
|
63
|
+
treeprocessor Metanorma::Standoc::EditorInlineAdmonitionBlock
|
62
64
|
treeprocessor Metanorma::Standoc::ToDoInlineAdmonitionBlock
|
63
65
|
block Metanorma::Standoc::PlantUMLBlockMacro
|
64
66
|
block Metanorma::Plugin::Lutaml::LutamlDiagramBlock
|
@@ -69,6 +69,17 @@
|
|
69
69
|
</zeroOrMore>
|
70
70
|
</element>
|
71
71
|
</define>
|
72
|
+
<define name="AdmonitionType">
|
73
|
+
<choice>
|
74
|
+
<value>warning</value>
|
75
|
+
<value>note</value>
|
76
|
+
<value>tip</value>
|
77
|
+
<value>important</value>
|
78
|
+
<value>caution</value>
|
79
|
+
<value>statement</value>
|
80
|
+
<value>editorial</value>
|
81
|
+
</choice>
|
82
|
+
</define>
|
72
83
|
<define name="index">
|
73
84
|
<element name="index">
|
74
85
|
<optional>
|
@@ -116,6 +127,11 @@
|
|
116
127
|
<data type="boolean"/>
|
117
128
|
</attribute>
|
118
129
|
</optional>
|
130
|
+
<optional>
|
131
|
+
<attribute name="suppress_identifier">
|
132
|
+
<data type="boolean"/>
|
133
|
+
</attribute>
|
134
|
+
</optional>
|
119
135
|
<ref name="BibliographicItem"/>
|
120
136
|
</element>
|
121
137
|
</define>
|
@@ -703,6 +719,9 @@
|
|
703
719
|
<optional>
|
704
720
|
<attribute name="tag"/>
|
705
721
|
</optional>
|
722
|
+
<optional>
|
723
|
+
<attribute name="type"/>
|
724
|
+
</optional>
|
706
725
|
<optional>
|
707
726
|
<attribute name="multilingual-rendering">
|
708
727
|
<ref name="MultilingualRenderingType"/>
|
@@ -738,6 +757,9 @@
|
|
738
757
|
<optional>
|
739
758
|
<attribute name="tag"/>
|
740
759
|
</optional>
|
760
|
+
<optional>
|
761
|
+
<attribute name="type"/>
|
762
|
+
</optional>
|
741
763
|
<optional>
|
742
764
|
<attribute name="multilingual-rendering">
|
743
765
|
<ref name="MultilingualRenderingType"/>
|
@@ -2059,6 +2081,7 @@
|
|
2059
2081
|
<value>compare</value>
|
2060
2082
|
<value>contrast</value>
|
2061
2083
|
<value>see</value>
|
2084
|
+
<value>seealso</value>
|
2062
2085
|
</choice>
|
2063
2086
|
</define>
|
2064
2087
|
<define name="deprecates">
|
@@ -2481,6 +2504,16 @@
|
|
2481
2504
|
<text/>
|
2482
2505
|
</element>
|
2483
2506
|
</optional>
|
2507
|
+
<optional>
|
2508
|
+
<element name="amendment">
|
2509
|
+
<text/>
|
2510
|
+
</element>
|
2511
|
+
</optional>
|
2512
|
+
<optional>
|
2513
|
+
<element name="corrigendum">
|
2514
|
+
<text/>
|
2515
|
+
</element>
|
2516
|
+
</optional>
|
2484
2517
|
<optional>
|
2485
2518
|
<element name="language">
|
2486
2519
|
<text/>
|
@@ -37,5 +37,31 @@ module Metanorma
|
|
37
37
|
%{<footnoteblock>#{out}</footnoteblock>}
|
38
38
|
end
|
39
39
|
end
|
40
|
+
|
41
|
+
class EditorAdmonitionBlock < Asciidoctor::Extensions::BlockProcessor
|
42
|
+
use_dsl
|
43
|
+
named :EDITOR
|
44
|
+
on_contexts :example, :paragraph
|
45
|
+
|
46
|
+
def process(parent, reader, attrs)
|
47
|
+
attrs["name"] = "editorial"
|
48
|
+
attrs["caption"] = "EDITOR"
|
49
|
+
create_block(parent, :admonition, reader.lines, attrs,
|
50
|
+
content_model: :compound)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class EditorInlineAdmonitionBlock < Asciidoctor::Extensions::Treeprocessor
|
55
|
+
def process(document)
|
56
|
+
(document.find_by context: :paragraph).each do |para|
|
57
|
+
next unless /^EDITOR: /.match? para.lines[0]
|
58
|
+
|
59
|
+
para.set_attr("name", "editorial")
|
60
|
+
para.set_attr("caption", "EDITOR")
|
61
|
+
para.lines[0].sub!(/^EDITOR: /, "")
|
62
|
+
para.context = :admonition
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
40
66
|
end
|
41
67
|
end
|
@@ -82,7 +82,8 @@ module Metanorma
|
|
82
82
|
def isorefmatches3out(item, xml)
|
83
83
|
if item[:doc] then use_retrieved_relaton(item, xml)
|
84
84
|
else
|
85
|
-
isorefmatches3_1(xml, item[:ref][:match],
|
85
|
+
isorefmatches3_1(xml, item[:ref][:match],
|
86
|
+
item[:ref][:yr],
|
86
87
|
item[:ref][:hasyr], item[:doc])
|
87
88
|
end
|
88
89
|
end
|
@@ -117,6 +118,7 @@ module Metanorma
|
|
117
118
|
|
118
119
|
def refitem_render(xml, match, code)
|
119
120
|
xml.bibitem **attr_code(id: match[:anchor],
|
121
|
+
suppress_identifier: code[:dropid],
|
120
122
|
hidden: code[:hidden]) do |t|
|
121
123
|
t.formattedref **{ format: "application/x-isodoc+xml" } do |i|
|
122
124
|
i << ref_normalise_no_format(match[:text])
|
@@ -84,7 +84,8 @@ module Metanorma
|
|
84
84
|
if ref[:code].nil? || ref[:no_year] || @bibdb.nil?
|
85
85
|
res << [ref, idx, nil]
|
86
86
|
else
|
87
|
-
@bibdb.fetch_async(ref[:code],
|
87
|
+
@bibdb.fetch_async(HTMLEntities.new.decode(ref[:code]),
|
88
|
+
ref[:year], ref) do |doc|
|
88
89
|
res << [ref, idx, doc]
|
89
90
|
end
|
90
91
|
end
|
@@ -119,7 +120,9 @@ module Metanorma
|
|
119
120
|
def use_retrieved_relaton(item, xml)
|
120
121
|
xml.parent.add_child(smart_render_xml(item[:doc], item[:ref][:code],
|
121
122
|
item[:ref]))
|
122
|
-
use_my_anchor(xml, item[:ref][:match][:anchor],
|
123
|
+
use_my_anchor(xml, item[:ref][:match][:anchor],
|
124
|
+
hidden: item.dig(:ref, :analyse_code, :hidden),
|
125
|
+
dropid: item.dig(:ref, :analyse_code, :dropid))
|
123
126
|
end
|
124
127
|
|
125
128
|
def init_bib_caches(node)
|
@@ -31,9 +31,11 @@ module Metanorma
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def use_my_anchor(ref, id,
|
34
|
+
def use_my_anchor(ref, id, opt)
|
35
35
|
ref.parent.elements.last["id"] = id
|
36
|
-
hidden and ref.parent.elements.last["hidden"] = hidden
|
36
|
+
opt[:hidden] and ref.parent.elements.last["hidden"] = opt[:hidden]
|
37
|
+
opt[:dropid] and
|
38
|
+
ref.parent.elements.last["suppress_identifier"] = opt[:dropid]
|
37
39
|
ref
|
38
40
|
end
|
39
41
|
|
@@ -57,6 +59,7 @@ module Metanorma
|
|
57
59
|
|
58
60
|
def mn_code(code)
|
59
61
|
code.sub(/^\(/, "[").sub(/\).*$/, "]")
|
62
|
+
.sub(/^dropid\((.+)\)$/, "\\1")
|
60
63
|
.sub(/^hidden\((.+)\)$/, "\\1")
|
61
64
|
.sub(/^nofetch\((.+)\)$/, "\\1")
|
62
65
|
end
|
@@ -73,6 +76,12 @@ module Metanorma
|
|
73
76
|
ret.merge(id: m[:id], hidden: true)
|
74
77
|
end
|
75
78
|
|
79
|
+
def analyse_ref_dropid(ret)
|
80
|
+
return ret unless m = /^dropid\((?<id>.+)\)$/.match(ret[:id])
|
81
|
+
|
82
|
+
ret.merge(id: m[:id], dropid: true)
|
83
|
+
end
|
84
|
+
|
76
85
|
def analyse_ref_repo_path(ret)
|
77
86
|
return ret unless m =
|
78
87
|
/^(?<type>repo|path):\((?<key>[^,]+),?(?<id>.*)\)$/
|
@@ -89,14 +98,16 @@ module Metanorma
|
|
89
98
|
end
|
90
99
|
|
91
100
|
# ref id = (usrlbl)code[:-]year
|
92
|
-
# code = nofetch(code) | hidden(code) | (repo|path):(key,code) |
|
101
|
+
# code = nofetch(code) | hidden(code) | dropid(code) | (repo|path):(key,code) |
|
93
102
|
# \[? number \]? | ident
|
94
103
|
def analyse_ref_code(code)
|
95
104
|
ret = { id: code }
|
96
105
|
return ret if code.blank?
|
97
106
|
|
98
|
-
|
99
|
-
|
107
|
+
analyse_ref_numeric(
|
108
|
+
analyse_ref_repo_path(
|
109
|
+
analyse_ref_dropid(analyse_ref_hidden(analyse_ref_nofetch(ret))),
|
110
|
+
),
|
100
111
|
)
|
101
112
|
end
|
102
113
|
|
@@ -110,7 +121,10 @@ module Metanorma
|
|
110
121
|
end
|
111
122
|
|
112
123
|
def ref_attributes(match)
|
113
|
-
|
124
|
+
code = analyse_ref_code(match[:code])
|
125
|
+
|
126
|
+
{ id: match[:anchor], type: "standard",
|
127
|
+
suppress_identifier: code[:dropid] || nil }
|
114
128
|
end
|
115
129
|
|
116
130
|
MALFORMED_REF = <<~REF.freeze
|
@@ -38,6 +38,8 @@ module Metanorma
|
|
38
38
|
when "symbols and abbreviated terms",
|
39
39
|
"symbols", "abbreviated terms", "abbreviations"
|
40
40
|
"symbols and abbreviated terms"
|
41
|
+
when "acknowledgements", "acknowledgments"
|
42
|
+
"acknowledgements"
|
41
43
|
else
|
42
44
|
ret
|
43
45
|
end
|
@@ -152,7 +154,7 @@ module Metanorma
|
|
152
154
|
attrs[:bibitem] = true if node.option? "bibitem"
|
153
155
|
attrs[:level] = node.attr("level")
|
154
156
|
set_obligation(attrs, node)
|
155
|
-
xml.send
|
157
|
+
xml.send :clause, **attr_code(attrs) do |xml_section|
|
156
158
|
xml_section.title { |n| n << node.title } unless node.title.nil?
|
157
159
|
xml_section << node.content
|
158
160
|
end
|