metanorma-standoc 2.4.4 → 2.4.6
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/base.rb +2 -0
- data/lib/metanorma/standoc/blocks_notes.rb +1 -1
- data/lib/metanorma/standoc/cleanup.rb +3 -1
- data/lib/metanorma/standoc/cleanup_bibdata.rb +127 -0
- data/lib/metanorma/standoc/cleanup_block.rb +18 -15
- data/lib/metanorma/standoc/cleanup_boilerplate.rb +30 -115
- data/lib/metanorma/standoc/converter.rb +1 -0
- data/lib/metanorma/standoc/isodoc.rng +18 -0
- data/lib/metanorma/standoc/macros_inline.rb +14 -2
- data/lib/metanorma/standoc/processor.rb +2 -2
- data/lib/metanorma/standoc/table.rb +1 -1
- data/lib/metanorma/standoc/utils.rb +11 -0
- data/lib/metanorma/standoc/validate.rb +1 -1
- data/lib/metanorma/standoc/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93ecb6aeaf9ddd1f6d695e84bdc1e0fc3a916da96ec174dd2a39045c58ac3b8d
|
4
|
+
data.tar.gz: ef76e529c8d445e62e7d0d9a1ad847c91607c050d84ba3f270709968acc90116
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62a612cbc8ae3a06c659def78b581ce31f47846aae73417475b7aae1b9648f2ff56db79f0b34f5099db5a09d0b79d7e96dfd2e2c767c465654941b4e6e249b72
|
7
|
+
data.tar.gz: '08959b3bebcc9a764d8191c68228b7ab77355fec635165b21e1baf84c9908914677845a25b6a0d05d2237ec1135e95e3c222e1194dcd4cf159ddbe938026c48e'
|
@@ -73,6 +73,8 @@ module Metanorma
|
|
73
73
|
@sourcecode_markup_start = node.attr("sourcecode-markup-start") || "{{{"
|
74
74
|
@sourcecode_markup_end = node.attr("sourcecode-markup-end") || "}}}"
|
75
75
|
@datauriimage = node.attr("data-uri-image") != "false"
|
76
|
+
@blockunnumbered = (node.attr("block-unnumbered") || "").split(",")
|
77
|
+
.map(&:strip)
|
76
78
|
end
|
77
79
|
|
78
80
|
def init_reqt(node)
|
@@ -38,7 +38,7 @@ module Metanorma
|
|
38
38
|
|
39
39
|
def todo_attrs(node)
|
40
40
|
date = node.attr("date") || Date.today.iso8601.gsub(/\+.*$/, "")
|
41
|
-
date += "T00:00:00Z" unless
|
41
|
+
date += "T00:00:00Z" unless date.include?("T")
|
42
42
|
attr_code(id_attr(node)
|
43
43
|
.merge(reviewer: node.attr("reviewer") || node.attr("source") ||
|
44
44
|
"(Unknown)",
|
@@ -7,6 +7,7 @@ require_relative "./cleanup_footnotes"
|
|
7
7
|
require_relative "./cleanup_ref"
|
8
8
|
require_relative "./cleanup_asciibib"
|
9
9
|
require_relative "./cleanup_boilerplate"
|
10
|
+
require_relative "./cleanup_bibdata"
|
10
11
|
require_relative "./cleanup_section"
|
11
12
|
require_relative "./cleanup_terms"
|
12
13
|
require_relative "./cleanup_symbols"
|
@@ -26,6 +27,8 @@ module Metanorma
|
|
26
27
|
def cleanup(xmldoc)
|
27
28
|
element_name_cleanup(xmldoc)
|
28
29
|
passthrough_cleanup(xmldoc)
|
30
|
+
unnumbered_blocks_cleanup(xmldoc)
|
31
|
+
metadata_cleanup(xmldoc) # feeds: boilerplate_cleanup
|
29
32
|
sections_cleanup(xmldoc) # feeds: obligations_cleanup, toc_cleanup,
|
30
33
|
# floatingtitle_cleanup
|
31
34
|
obligations_cleanup(xmldoc)
|
@@ -70,7 +73,6 @@ module Metanorma
|
|
70
73
|
svgmap_cleanup(xmldoc) # feeds: img_cleanup
|
71
74
|
boilerplate_cleanup(xmldoc)
|
72
75
|
toc_cleanup(xmldoc)
|
73
|
-
metadata_cleanup(xmldoc)
|
74
76
|
smartquotes_cleanup(xmldoc)
|
75
77
|
variant_cleanup(xmldoc)
|
76
78
|
para_cleanup(xmldoc)
|
@@ -0,0 +1,127 @@
|
|
1
|
+
module Metanorma
|
2
|
+
module Standoc
|
3
|
+
module Cleanup
|
4
|
+
def bibdata_cleanup(xmldoc)
|
5
|
+
bibdata_anchor_cleanup(xmldoc)
|
6
|
+
bibdata_docidentifier_cleanup(xmldoc)
|
7
|
+
bibdata_embed_hdr_cleanup(xmldoc) # feeds bibdata_embed_id_cleanup
|
8
|
+
bibdata_embed_id_cleanup(xmldoc)
|
9
|
+
biblio_indirect_erefs(xmldoc, @internal_eref_namespaces&.uniq)
|
10
|
+
end
|
11
|
+
|
12
|
+
def bibdata_anchor_cleanup(xmldoc)
|
13
|
+
xmldoc.xpath("//bibdata//bibitem | //bibdata//note").each do |b|
|
14
|
+
b.delete("id")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def bibdata_docidentifier_cleanup(xmldoc)
|
19
|
+
ins = xmldoc.at("//bibdata/docidentifier")
|
20
|
+
xmldoc.xpath("//bibdata/docidentifier").each_with_index do |b, i|
|
21
|
+
i.zero? and next
|
22
|
+
ins.next = b.remove
|
23
|
+
ins = ins.next
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def gather_indirect_erefs(xmldoc, prefix)
|
28
|
+
xmldoc.xpath("//eref[@type = '#{prefix}']")
|
29
|
+
.each_with_object({}) do |e, m|
|
30
|
+
e.delete("type")
|
31
|
+
m[e["bibitemid"]] = true
|
32
|
+
end.keys
|
33
|
+
end
|
34
|
+
|
35
|
+
def insert_indirect_biblio(xmldoc, refs, prefix)
|
36
|
+
i = xmldoc.at("bibliography") or
|
37
|
+
xmldoc.root << "<bibliography/>" and i = xmldoc.at("bibliography")
|
38
|
+
i = i.add_child("<references hidden='true' normative='false'/>").first
|
39
|
+
refs.each do |x|
|
40
|
+
i << <<~BIB
|
41
|
+
<bibitem id="#{x}" type="internal">
|
42
|
+
<docidentifier type="repository">#{x.sub(/^#{prefix}_/, "#{prefix}/")}</docidentifier>
|
43
|
+
</bibitem>
|
44
|
+
BIB
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def indirect_eref_to_xref(eref, ident)
|
49
|
+
loc = eref.at("./localityStack[locality[@type = 'anchor']]")
|
50
|
+
&.remove&.text ||
|
51
|
+
eref.at("./locality[@type = 'anchor']")&.remove&.text || ident
|
52
|
+
eref.name = "xref"
|
53
|
+
eref.delete("bibitemid")
|
54
|
+
eref.delete("citeas")
|
55
|
+
eref["target"] = loc
|
56
|
+
unless eref.document.at("//*[@id = '#{loc}']")
|
57
|
+
eref.children = %(** Missing target #{loc})
|
58
|
+
eref["target"] = ident
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def resolve_local_indirect_erefs(xmldoc, refs, prefix)
|
63
|
+
refs.each_with_object([]) do |r, m|
|
64
|
+
id = r.sub(/^#{prefix}_/, "")
|
65
|
+
n = xmldoc.at("//*[@id = '#{id}']")
|
66
|
+
if n&.at("./ancestor-or-self::*[@type = '#{prefix}']")
|
67
|
+
xmldoc.xpath("//eref[@bibitemid = '#{r}']").each do |e|
|
68
|
+
indirect_eref_to_xref(e, id)
|
69
|
+
end
|
70
|
+
else m << r
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def biblio_indirect_erefs(xmldoc, prefixes)
|
76
|
+
prefixes&.each do |prefix|
|
77
|
+
refs = gather_indirect_erefs(xmldoc, prefix)
|
78
|
+
refs = resolve_local_indirect_erefs(xmldoc, refs, prefix)
|
79
|
+
refs.empty? and next
|
80
|
+
insert_indirect_biblio(xmldoc, refs, prefix)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def bibdata_embed_hdr_cleanup(xmldoc)
|
85
|
+
(@embed_hdr.nil? || @embed_hdr.empty?) and return
|
86
|
+
xmldoc.at("//bibdata") << "<relation type='derivedFrom'>" \
|
87
|
+
"#{hdr2bibitem(@embed_hdr.first)}</relation>"
|
88
|
+
end
|
89
|
+
|
90
|
+
def hdr2bibitem(hdr)
|
91
|
+
xml = Asciidoctor
|
92
|
+
.convert(hdr[:text], backend: hdr2bibitem_type(hdr),
|
93
|
+
header_footer: true)
|
94
|
+
b = Nokogiri::XML(xml).at("//xmlns:bibdata")
|
95
|
+
b.name = "bibitem"
|
96
|
+
b.delete("type")
|
97
|
+
embed_recurse(b, hdr)
|
98
|
+
b.to_xml
|
99
|
+
end
|
100
|
+
|
101
|
+
def hdr2bibitem_type(hdr)
|
102
|
+
m = /:mn-document-class: (\S+)/.match(hdr[:text])
|
103
|
+
if m then m[1].to_sym
|
104
|
+
else Processor.new.asciidoctor_backend
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def embed_recurse(bibitem, node)
|
109
|
+
node[:child].map { |x| hdr2bibitem(x) }.each do |x|
|
110
|
+
bibitem << "<relation type='derivedFrom'>#{x}</relation>"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def bibdata_embed_id_cleanup(xmldoc)
|
115
|
+
@embed_id.nil? and return
|
116
|
+
bibdata = xmldoc.at("//bibdata")
|
117
|
+
@embed_id.each do |d|
|
118
|
+
bibdata = bibdata.at("./relation[@type = 'derivedFrom']/bibitem")
|
119
|
+
ident = bibdata.at("./docidentifier[@primary = 'true']") ||
|
120
|
+
bibdata.at("./docidentifier")
|
121
|
+
xmldoc.xpath("//xref[@target = '#{d}'][normalize-space(text()) = '']")
|
122
|
+
.each { |x| x << ident.text }
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -12,6 +12,7 @@ module Metanorma
|
|
12
12
|
"ancestor::table or ancestor::bibdata)]"].each do |w|
|
13
13
|
inject_id(xmldoc, w)
|
14
14
|
end
|
15
|
+
xmldoc.xpath("//p[not(text()) and not(node())]").each(&:remove)
|
15
16
|
end
|
16
17
|
|
17
18
|
def inject_id(xmldoc, path)
|
@@ -67,11 +68,10 @@ module Metanorma
|
|
67
68
|
# examples containing only figures become subfigures of figures
|
68
69
|
def subfigure_cleanup(xmldoc)
|
69
70
|
xmldoc.xpath("//example[figure]").each do |e|
|
70
|
-
|
71
|
+
e.elements.reject do |m|
|
71
72
|
%w(name figure index note).include?(m.name) ||
|
72
73
|
(m.name == "dl" && m["key"] == "true")
|
73
|
-
end.empty?
|
74
|
-
|
74
|
+
end.empty? or next
|
75
75
|
e.name = "figure"
|
76
76
|
end
|
77
77
|
end
|
@@ -100,8 +100,7 @@ module Metanorma
|
|
100
100
|
# (so there was no way of making that block include the note)
|
101
101
|
def note_cleanup(xmldoc)
|
102
102
|
xmldoc.xpath("//note").each do |n|
|
103
|
-
|
104
|
-
|
103
|
+
n["keep-separate"] == "true" || !n.ancestors("table").empty? and next
|
105
104
|
prev = n.previous_element || next
|
106
105
|
n.parent = prev if ELEMS_ALLOW_NOTES.include? prev.name
|
107
106
|
end
|
@@ -129,7 +128,7 @@ module Metanorma
|
|
129
128
|
|
130
129
|
def merge_annotations_into_sourcecode(xmldoc)
|
131
130
|
xmldoc.xpath("//sourcecode").each do |x|
|
132
|
-
while x
|
131
|
+
while x.next_element&.name == "annotation"
|
133
132
|
x.next_element.parent = x
|
134
133
|
end
|
135
134
|
end
|
@@ -143,10 +142,8 @@ module Metanorma
|
|
143
142
|
def sourcecode_cleanup(xmldoc)
|
144
143
|
xmldoc.xpath("//sourcecode").each do |x|
|
145
144
|
x.traverse do |n|
|
146
|
-
|
147
|
-
|
148
|
-
.match?(n.text)
|
149
|
-
|
145
|
+
n.text? or next
|
146
|
+
/#{Regexp.escape(@sourcecode_markup_start)}/.match?(n.text) or next
|
150
147
|
n.replace(sourcecode_markup(n))
|
151
148
|
end
|
152
149
|
end
|
@@ -164,8 +161,7 @@ module Metanorma
|
|
164
161
|
#{Regexp.escape(@sourcecode_markup_end)})/x)
|
165
162
|
.each_slice(4).map.with_object([]) do |a, acc|
|
166
163
|
acc << safe_noko(a[0], node.document)
|
167
|
-
|
168
|
-
|
164
|
+
a.size == 4 or next
|
169
165
|
acc << Asciidoctor.convert(
|
170
166
|
a[2], doctype: :inline, backend: (self&.backend&.to_sym || :standoc)
|
171
167
|
)
|
@@ -174,7 +170,7 @@ module Metanorma
|
|
174
170
|
|
175
171
|
def form_cleanup(xmldoc)
|
176
172
|
xmldoc.xpath("//select").each do |s|
|
177
|
-
while s
|
173
|
+
while s.next_element&.name == "option"
|
178
174
|
s << s.next_element
|
179
175
|
end
|
180
176
|
end
|
@@ -200,8 +196,7 @@ module Metanorma
|
|
200
196
|
end
|
201
197
|
|
202
198
|
def include_indexterm?(elem)
|
203
|
-
|
204
|
-
|
199
|
+
elem.nil? and return false
|
205
200
|
!%w(image literal sourcecode).include?(elem.name)
|
206
201
|
end
|
207
202
|
|
@@ -234,6 +229,14 @@ module Metanorma
|
|
234
229
|
s.delete("type")
|
235
230
|
end
|
236
231
|
end
|
232
|
+
|
233
|
+
def unnumbered_blocks_cleanup(xmldoc)
|
234
|
+
@blockunnumbered&.each do |b|
|
235
|
+
xmldoc.xpath("//#{b}").each do |e|
|
236
|
+
e["unnumbered"] ||= "true"
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
237
240
|
end
|
238
241
|
end
|
239
242
|
end
|
@@ -118,132 +118,47 @@ module Metanorma
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def boilerplate(xml, conv)
|
121
|
+
# prevent infinite recursion of asciidoc boilerplate processing
|
122
|
+
xml.at("//metanorma-extension/semantic-metadata/" \
|
123
|
+
"headless[text() = 'true']") and return nil
|
121
124
|
file = boilerplate_file(xml)
|
122
|
-
@boilerplateauthority and
|
123
|
-
|
125
|
+
@boilerplateauthority and file = File.join(@localdir,
|
126
|
+
@boilerplateauthority)
|
124
127
|
(!file.nil? and File.exist?(file)) or return
|
125
|
-
conv.populate_template(
|
128
|
+
b = conv.populate_template(boilerplate_read(file), nil)
|
129
|
+
boilerplate_file_convert(b)
|
126
130
|
end
|
127
131
|
|
128
|
-
def
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
biblio_indirect_erefs(xmldoc, @internal_eref_namespaces&.uniq)
|
132
|
+
def boilerplate_read(file)
|
133
|
+
ret = File.read(file, encoding: "UTF-8")
|
134
|
+
/\.adoc$/.match?(file) and
|
135
|
+
ret.gsub!(/(?<!\{)(\{\{[^{}]+\}\})(?!\})/, "pass:[\\1]")
|
136
|
+
ret
|
134
137
|
end
|
135
138
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
end
|
141
|
-
|
142
|
-
def bibdata_docidentifier_cleanup(xmldoc)
|
143
|
-
ins = xmldoc.at("//bibdata/docidentifier")
|
144
|
-
xmldoc.xpath("//bibdata/docidentifier").each_with_index do |b, i|
|
145
|
-
i.zero? and next
|
146
|
-
ins.next = b.remove
|
147
|
-
ins = ins.next
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
def gather_indirect_erefs(xmldoc, prefix)
|
152
|
-
xmldoc.xpath("//eref[@type = '#{prefix}']")
|
153
|
-
.each_with_object({}) do |e, m|
|
154
|
-
e.delete("type")
|
155
|
-
m[e["bibitemid"]] = true
|
156
|
-
end.keys
|
157
|
-
end
|
158
|
-
|
159
|
-
def insert_indirect_biblio(xmldoc, refs, prefix)
|
160
|
-
i = xmldoc.at("bibliography") or
|
161
|
-
xmldoc.root << "<bibliography/>" and i = xmldoc.at("bibliography")
|
162
|
-
i = i.add_child("<references hidden='true' normative='false'/>").first
|
163
|
-
refs.each do |x|
|
164
|
-
i << <<~BIB
|
165
|
-
<bibitem id="#{x}" type="internal">
|
166
|
-
<docidentifier type="repository">#{x.sub(/^#{prefix}_/, "#{prefix}/")}</docidentifier>
|
167
|
-
</bibitem>
|
168
|
-
BIB
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
def indirect_eref_to_xref(eref, ident)
|
173
|
-
loc = eref.at("./localityStack[locality[@type = 'anchor']]")
|
174
|
-
&.remove&.text ||
|
175
|
-
eref.at("./locality[@type = 'anchor']")&.remove&.text || ident
|
176
|
-
eref.name = "xref"
|
177
|
-
eref.delete("bibitemid")
|
178
|
-
eref.delete("citeas")
|
179
|
-
eref["target"] = loc
|
180
|
-
unless eref.document.at("//*[@id = '#{loc}']")
|
181
|
-
eref.children = %(** Missing target #{loc})
|
182
|
-
eref["target"] = ident
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
def resolve_local_indirect_erefs(xmldoc, refs, prefix)
|
187
|
-
refs.each_with_object([]) do |r, m|
|
188
|
-
id = r.sub(/^#{prefix}_/, "")
|
189
|
-
n = xmldoc.at("//*[@id = '#{id}']")
|
190
|
-
if n&.at("./ancestor-or-self::*[@type = '#{prefix}']")
|
191
|
-
xmldoc.xpath("//eref[@bibitemid = '#{r}']").each do |e|
|
192
|
-
indirect_eref_to_xref(e, id)
|
193
|
-
end
|
194
|
-
else m << r
|
195
|
-
end
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
def biblio_indirect_erefs(xmldoc, prefixes)
|
200
|
-
prefixes&.each do |prefix|
|
201
|
-
refs = gather_indirect_erefs(xmldoc, prefix)
|
202
|
-
refs = resolve_local_indirect_erefs(xmldoc, refs, prefix)
|
203
|
-
refs.empty? and next
|
204
|
-
insert_indirect_biblio(xmldoc, refs, prefix)
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
def bibdata_embed_hdr_cleanup(xmldoc)
|
209
|
-
(@embed_hdr.nil? || @embed_hdr.empty?) and return
|
210
|
-
xmldoc.at("//bibdata") << "<relation type='derivedFrom'>" \
|
211
|
-
"#{hdr2bibitem(@embed_hdr.first)}</relation>"
|
212
|
-
end
|
213
|
-
|
214
|
-
def hdr2bibitem(hdr)
|
215
|
-
xml = Asciidoctor
|
216
|
-
.convert(hdr[:text], backend: hdr2bibitem_type(hdr),
|
217
|
-
header_footer: true)
|
218
|
-
b = Nokogiri::XML(xml).at("//xmlns:bibdata")
|
219
|
-
b.name = "bibitem"
|
220
|
-
b.delete("type")
|
221
|
-
embed_recurse(b, hdr)
|
222
|
-
b.to_xml
|
223
|
-
end
|
224
|
-
|
225
|
-
def hdr2bibitem_type(hdr)
|
226
|
-
m = /:mn-document-class: (\S+)/.match(hdr[:text])
|
227
|
-
if m then m[1].to_sym
|
228
|
-
else Processor.new.asciidoctor_backend
|
229
|
-
end
|
139
|
+
# If Asciidoctor, convert top clauses to tags and wrap in <boilerplate>
|
140
|
+
def boilerplate_file_convert(file)
|
141
|
+
Nokogiri::XML(file).root and return file
|
142
|
+
to_xml(boilerplate_file_restructure(file))
|
230
143
|
end
|
231
144
|
|
232
|
-
|
233
|
-
|
234
|
-
|
145
|
+
# If Asciidoctor, convert top clauses to tags and wrap in <boilerplate>
|
146
|
+
def boilerplate_file_restructure(file)
|
147
|
+
ret = adoc2xml(file, backend.to_sym)
|
148
|
+
ns = ret.namespace.href
|
149
|
+
ret.traverse do |n|
|
150
|
+
n.element? and n.namespace.href == ns and n.namespace = nil
|
235
151
|
end
|
152
|
+
ret.name = "boilerplate"
|
153
|
+
boilerplate_top_elements(ret)
|
154
|
+
ret
|
236
155
|
end
|
237
156
|
|
238
|
-
def
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
ident = bibdata.at("./docidentifier[@primary = 'true']") ||
|
244
|
-
bibdata.at("./docidentifier")
|
245
|
-
xmldoc.xpath("//xref[@target = '#{d}'][normalize-space(text()) = '']")
|
246
|
-
.each { |x| x << ident.text }
|
157
|
+
def boilerplate_top_elements(xml)
|
158
|
+
xml.elements.each do |e|
|
159
|
+
(t = e.at("./title") and /-statement$/.match?(t.text)) or next
|
160
|
+
e.name = t.remove.text
|
161
|
+
e.keys.each { |a| e.delete(a) } # rubocop:disable Style/HashEachMethods
|
247
162
|
end
|
248
163
|
end
|
249
164
|
end
|
@@ -26,6 +26,7 @@ module Metanorma
|
|
26
26
|
preprocessor Metanorma::Plugin::Datastruct::Json2TextPreprocessor
|
27
27
|
preprocessor Metanorma::Plugin::Datastruct::Yaml2TextPreprocessor
|
28
28
|
inline_macro Metanorma::Standoc::PreferredTermInlineMacro
|
29
|
+
inline_macro Metanorma::Standoc::DateInlineMacro
|
29
30
|
inline_macro Metanorma::Standoc::SpanInlineMacro
|
30
31
|
inline_macro Metanorma::Standoc::AltTermInlineMacro
|
31
32
|
inline_macro Metanorma::Standoc::AdmittedTermInlineMacro
|
@@ -1012,6 +1012,7 @@
|
|
1012
1012
|
<ref name="del"/>
|
1013
1013
|
<ref name="span"/>
|
1014
1014
|
<ref name="erefstack"/>
|
1015
|
+
<ref name="date_inline"/>
|
1015
1016
|
</choice>
|
1016
1017
|
</define>
|
1017
1018
|
<define name="add">
|
@@ -1053,6 +1054,23 @@
|
|
1053
1054
|
</oneOrMore>
|
1054
1055
|
</element>
|
1055
1056
|
</define>
|
1057
|
+
<define name="date_inline">
|
1058
|
+
<element name="date">
|
1059
|
+
<attribute name="value"/>
|
1060
|
+
<optional>
|
1061
|
+
<attribute name="format"/>
|
1062
|
+
</optional>
|
1063
|
+
<optional>
|
1064
|
+
<attribute name="language"/>
|
1065
|
+
</optional>
|
1066
|
+
<optional>
|
1067
|
+
<attribute name="script"/>
|
1068
|
+
</optional>
|
1069
|
+
<optional>
|
1070
|
+
<attribute name="locale"/>
|
1071
|
+
</optional>
|
1072
|
+
</element>
|
1073
|
+
</define>
|
1056
1074
|
<define name="concept">
|
1057
1075
|
<element name="concept">
|
1058
1076
|
<optional>
|
@@ -27,7 +27,7 @@ module Metanorma
|
|
27
27
|
|
28
28
|
def process(_parent, target, attr)
|
29
29
|
args = preprocess_attrs(attr) or return
|
30
|
-
ret = "<index-xref also='#{target == 'also'}'>"\
|
30
|
+
ret = "<index-xref also='#{target == 'also'}'>" \
|
31
31
|
"<primary>#{args[:primary]}</primary>"
|
32
32
|
ret += "<secondary>#{args[:secondary]}</secondary>" if args[:secondary]
|
33
33
|
ret += "<tertiary>#{args[:tertiary]}</tertiary>" if args[:tertiary]
|
@@ -69,7 +69,7 @@ module Metanorma
|
|
69
69
|
rpend = attributes["rpend"]
|
70
70
|
end
|
71
71
|
|
72
|
-
"<ruby>#{target}<rp>#{rpbegin}</rp><rt>#{rt}</rt>"\
|
72
|
+
"<ruby>#{target}<rp>#{rpbegin}</rp><rt>#{rt}</rt>" \
|
73
73
|
"<rp>#{rpend}</rp></ruby>"
|
74
74
|
end
|
75
75
|
end
|
@@ -101,6 +101,18 @@ module Metanorma
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
+
class DateInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
105
|
+
use_dsl
|
106
|
+
named :date
|
107
|
+
using_format :short
|
108
|
+
|
109
|
+
def process(_parent, _target, attrs)
|
110
|
+
format = "%F"
|
111
|
+
attrs.size >= 2 and format = attrs[2]
|
112
|
+
%{<date format='#{format}' value='#{attrs[1]}'/>}
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
104
116
|
class AddMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
105
117
|
use_dsl
|
106
118
|
named :add
|
@@ -5,7 +5,7 @@ module Metanorma
|
|
5
5
|
class Processor < Metanorma::Processor
|
6
6
|
class << self
|
7
7
|
attr_reader :asciidoctor_backend
|
8
|
-
|
8
|
+
end
|
9
9
|
|
10
10
|
def initialize # rubocop:disable Lint/MissingSuper
|
11
11
|
@short = :standoc
|
@@ -22,7 +22,7 @@ module Metanorma
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def version
|
25
|
-
"Metanorma::Standoc #{Metanorma::Standoc::VERSION}/"\
|
25
|
+
"Metanorma::Standoc #{Metanorma::Standoc::VERSION}/" \
|
26
26
|
"IsoDoc #{IsoDoc::VERSION}"
|
27
27
|
end
|
28
28
|
|
@@ -76,6 +76,17 @@ module Metanorma
|
|
76
76
|
.gsub(/'/, "'")
|
77
77
|
end
|
78
78
|
|
79
|
+
# wrapped in <sections>
|
80
|
+
def adoc2xml(text, flavour)
|
81
|
+
Nokogiri::XML(text).root and return text
|
82
|
+
c = Asciidoctor.convert("= X\nA\n:semantic-metadata-headless: true\n" \
|
83
|
+
":novalid:\n\n#{text}\n",
|
84
|
+
backend: flavour, header_footer: true)
|
85
|
+
Nokogiri::XML(c).at("//xmlns:sections")
|
86
|
+
end
|
87
|
+
|
88
|
+
module_function :adoc2xml
|
89
|
+
|
79
90
|
class EmptyAttr
|
80
91
|
def attr(_any_attribute)
|
81
92
|
nil
|
@@ -122,7 +122,7 @@ module Metanorma
|
|
122
122
|
err2 = "There is a crossreference to an instance of #{inner.name} " \
|
123
123
|
"nested within #{outer.name}: #{i.to_xml}"
|
124
124
|
@log.add("Style", i, err2)
|
125
|
-
@fatalerror << err2
|
125
|
+
# @fatalerror << err2
|
126
126
|
end
|
127
127
|
|
128
128
|
def concept_validate(doc, tag, refterm)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-standoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -475,6 +475,7 @@ files:
|
|
475
475
|
- lib/metanorma/standoc/cleanup.rb
|
476
476
|
- lib/metanorma/standoc/cleanup_amend.rb
|
477
477
|
- lib/metanorma/standoc/cleanup_asciibib.rb
|
478
|
+
- lib/metanorma/standoc/cleanup_bibdata.rb
|
478
479
|
- lib/metanorma/standoc/cleanup_block.rb
|
479
480
|
- lib/metanorma/standoc/cleanup_boilerplate.rb
|
480
481
|
- lib/metanorma/standoc/cleanup_footnotes.rb
|