metanorma-standoc 3.4.6 → 3.4.7
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/metanorma/cleanup/block.rb +79 -24
- data/lib/metanorma/converter/blocks_examples.rb +2 -1
- data/lib/metanorma/converter/front_title.rb +3 -1
- data/lib/metanorma/converter/init.rb +1 -0
- data/lib/metanorma/converter/log.rb +3 -0
- data/lib/metanorma/converter/ref_queue.rb +19 -0
- data/lib/metanorma/converter/render.rb +2 -0
- data/lib/metanorma/standoc/version.rb +1 -1
- data/lib/metanorma/validate/isodoc.rng +6 -0
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b1dfc55e13dc35cba30f131721a669b4d8f4373d9afea12d2a1fd19c178ab9b1
|
|
4
|
+
data.tar.gz: b1c07c99802d3018f9205e3b68574d2e6557380d81b51f6d33fec5026da355d4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 501724517b1124aab3b9be9dc9eece4c4da9671e8ca13b6c4a86f52e45487772ed50b51418cc334280f183241c0d244acc4b7f63040a6b8ecf0ac5e48676e458
|
|
7
|
+
data.tar.gz: 3b6a32f1e821f68243cc01f3833f6f8fa26f14ac5f6b686e10cf872c6f4cdd968324579540dea0ee481d06ecaa04695390a601888d72977ea1375dabb1b4b789
|
|
@@ -166,13 +166,22 @@ module Metanorma
|
|
|
166
166
|
align_callouts_to_annotations(xmldoc)
|
|
167
167
|
end
|
|
168
168
|
|
|
169
|
+
# State threaded through {{{ ... }}} sourcecode-markup processing.
|
|
170
|
+
# open: inside a span; inline: that span opened in the current text node
|
|
171
|
+
# (so its content is convertible, not merely delimiter-stripped);
|
|
172
|
+
# buf: the open span's content so far; out: the rebuilt node content.
|
|
173
|
+
SourcecodeMarkup = Struct.new(:open, :inline, :buf, :out, :node)
|
|
174
|
+
|
|
175
|
+
# {{{ ... }}} injects Asciidoc markup into otherwise-verbatim sourcecode.
|
|
176
|
+
# A span's delimiters can be split across separate text nodes by an
|
|
177
|
+
# element that subs="macros" injected between them (e.g. an inline
|
|
178
|
+
# image), so we walk the sourcecode's text nodes in order and carry the
|
|
179
|
+
# open state across them, rather than processing each node in isolation.
|
|
169
180
|
def sourcecode_cleanup(xmldoc)
|
|
170
181
|
xmldoc.xpath("//sourcecode").each do |x|
|
|
171
|
-
x.
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
n.replace(sourcecode_markup(n))
|
|
175
|
-
end
|
|
182
|
+
open = x.xpath(".//text()")
|
|
183
|
+
.inject(false) { |acc, node| sourcecode_markup(node, acc) }
|
|
184
|
+
open and @log.add("STANDOC_65", x, params: [@sourcecode_markup_start])
|
|
176
185
|
end
|
|
177
186
|
end
|
|
178
187
|
|
|
@@ -183,32 +192,78 @@ module Metanorma
|
|
|
183
192
|
)
|
|
184
193
|
end
|
|
185
194
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
end.join
|
|
195
|
+
# @return [Boolean] whether a {{{ span is still open after this node
|
|
196
|
+
def sourcecode_markup(node, open)
|
|
197
|
+
open || sourcecode_markup?(node.text) or return open
|
|
198
|
+
state = SourcecodeMarkup.new(open, false, [], [], node)
|
|
199
|
+
sourcecode_markup_split(node.text)
|
|
200
|
+
.each { |tok| sourcecode_markup_token(tok, state) }
|
|
201
|
+
sourcecode_markup_flush(state)
|
|
202
|
+
state.open
|
|
195
203
|
end
|
|
196
204
|
|
|
197
|
-
def
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
ret
|
|
205
|
+
def sourcecode_markup_flush(state)
|
|
206
|
+
state.open and
|
|
207
|
+
state.out << safe_noko(state.buf.join, state.node.document)
|
|
208
|
+
state.node.replace(state.out.join)
|
|
202
209
|
end
|
|
203
210
|
|
|
204
|
-
def
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
211
|
+
def sourcecode_markup?(text)
|
|
212
|
+
text.include?(@sourcecode_markup_start) ||
|
|
213
|
+
text.include?(@sourcecode_markup_end)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def sourcecode_markup_split(text)
|
|
217
|
+
text.split(/(#{Regexp.escape(@sourcecode_markup_start)}|
|
|
218
|
+
#{Regexp.escape(@sourcecode_markup_end)})/x)
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def sourcecode_markup_token(tok, state)
|
|
222
|
+
case tok
|
|
223
|
+
when @sourcecode_markup_start then sourcecode_markup_open(state)
|
|
224
|
+
when @sourcecode_markup_end then sourcecode_markup_close(state)
|
|
225
|
+
else sourcecode_markup_content(tok, state)
|
|
209
226
|
end
|
|
210
227
|
end
|
|
211
228
|
|
|
229
|
+
# a nested {{{ is improper nesting: STANDOC_61 is fatal
|
|
230
|
+
def sourcecode_markup_open(state)
|
|
231
|
+
state.open and
|
|
232
|
+
return @log.add("STANDOC_61", state.node, params: [state.node.text])
|
|
233
|
+
state.open = state.inline = true
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
def sourcecode_markup_close(state)
|
|
237
|
+
state.open or return sourcecode_markup_stray(state)
|
|
238
|
+
state.out << sourcecode_markup_closed(state)
|
|
239
|
+
state.open = state.inline = false
|
|
240
|
+
state.buf = []
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
# a stray }}} with no opener is left as literal text
|
|
244
|
+
def sourcecode_markup_stray(state)
|
|
245
|
+
state.out << safe_noko(@sourcecode_markup_end, state.node.document)
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
# a span closed within one node is converted; one split across nodes
|
|
249
|
+
# (already holding a processed element) is delimiter-stripped only
|
|
250
|
+
def sourcecode_markup_closed(state)
|
|
251
|
+
state.inline and return sourcecode_markup_convert(state.buf.join)
|
|
252
|
+
safe_noko(state.buf.join, state.node.document)
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
def sourcecode_markup_content(tok, state)
|
|
256
|
+
state.open and return state.buf << tok
|
|
257
|
+
state.out << safe_noko(tok, state.node.document)
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
def sourcecode_markup_convert(span)
|
|
261
|
+
@conv.isolated_asciidoctor_convert(
|
|
262
|
+
"{blank} #{span}", doctype: :inline,
|
|
263
|
+
backend: @conv.backend&.to_sym || :standoc
|
|
264
|
+
).strip
|
|
265
|
+
end
|
|
266
|
+
|
|
212
267
|
def form_cleanup(xmldoc)
|
|
213
268
|
xmldoc.xpath("//select").each do |s|
|
|
214
269
|
while s.next_element&.name == "option"
|
|
@@ -49,7 +49,8 @@ module Metanorma
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def example_attrs(node)
|
|
52
|
-
attr_code(id_unnum_attrs(node).merge(keep_attrs(node))
|
|
52
|
+
attr_code(id_unnum_attrs(node).merge(keep_attrs(node))
|
|
53
|
+
.merge(collapsible: node.option?("collapsible") ? "true" : nil))
|
|
53
54
|
end
|
|
54
55
|
|
|
55
56
|
def example_proper(node)
|
|
@@ -54,7 +54,9 @@ module Metanorma
|
|
|
54
54
|
part, subpart = node.attr("partnumber")&.split("-")
|
|
55
55
|
{ part:, subpart:, amendment: node.attr("amendment-number"),
|
|
56
56
|
corrigendum: node.attr("corrigendum-number"),
|
|
57
|
-
addendum: node.attr("addendum-number")
|
|
57
|
+
addendum: node.attr("addendum-number"),
|
|
58
|
+
supplement: node.attr("supplement-number"),
|
|
59
|
+
extract: node.attr("extract-number") }
|
|
58
60
|
end
|
|
59
61
|
|
|
60
62
|
def title_num_prefix(key, value, xml, lang)
|
|
@@ -198,6 +198,9 @@ module Metanorma
|
|
|
198
198
|
STANDOC_64: { category: "AsciiDoc Input",
|
|
199
199
|
error: "Empty index term: %s.",
|
|
200
200
|
severity: 0 },
|
|
201
|
+
STANDOC_65: { category: "AsciiDoc Input",
|
|
202
|
+
error: "Unbalanced sourcecode markup: unclosed %s",
|
|
203
|
+
severity: 0 },
|
|
201
204
|
RELATON_1: { category: "Relaton",
|
|
202
205
|
error: "(Error from Relaton) %s",
|
|
203
206
|
severity: 0 },
|
|
@@ -221,6 +221,8 @@ module Metanorma
|
|
|
221
221
|
global = !@no_isobib_cache && !node.attr("local-cache-only")
|
|
222
222
|
local = node.attr("local-cache") || node.attr("local-cache-only")
|
|
223
223
|
local = nil if @no_isobib_cache
|
|
224
|
+
flush_bib_caches_force(node) if node.attr("flush-caches") &&
|
|
225
|
+
@no_isobib_cache
|
|
224
226
|
@bibdb = Relaton::Db.init_bib_caches(
|
|
225
227
|
local_cache: local,
|
|
226
228
|
flush_caches: node.attr("flush-caches"),
|
|
@@ -228,6 +230,23 @@ module Metanorma
|
|
|
228
230
|
)
|
|
229
231
|
end
|
|
230
232
|
|
|
233
|
+
# `:flush-caches:` must clear stale cache state regardless of whether
|
|
234
|
+
# `:no-isobib-cache:` disables caching for *this* compile. When both
|
|
235
|
+
# are set, the `Relaton::Db.init_bib_caches` path no-ops on the flush
|
|
236
|
+
# (because it has no cache paths to flush), leaving any previously
|
|
237
|
+
# cached entries on disk for the next compile that DOES have caching
|
|
238
|
+
# enabled to pick up. Force-flush the conventional cache locations
|
|
239
|
+
# here so the flag does what its name says.
|
|
240
|
+
# Source issue: https://github.com/relaton/relaton-iso/issues/181
|
|
241
|
+
def flush_bib_caches_force(node)
|
|
242
|
+
FileUtils.rm_rf "#{Dir.home}/.relaton/cache"
|
|
243
|
+
lcache_name = node.attr("local-cache") || node.attr("local-cache-only")
|
|
244
|
+
if lcache_name
|
|
245
|
+
base = lcache_name.to_s.empty? ? "relaton" : lcache_name
|
|
246
|
+
FileUtils.rm_rf "#{base}/cache"
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
|
|
231
250
|
# Treat empty strings as falsy (they're set by Asciidoctor for some attributes)
|
|
232
251
|
def init_iev_caches(node)
|
|
233
252
|
no_cache = @no_isobib_cache && !@no_isobib_cache.empty?
|
|
@@ -41,6 +41,7 @@ module Metanorma
|
|
|
41
41
|
tocfigures: @tocfigures,
|
|
42
42
|
toctables: @toctables,
|
|
43
43
|
tocrecommendations: @tocrecommendations,
|
|
44
|
+
tocexamples: @tocexamples,
|
|
44
45
|
fonts: flex_attr_name(node, "fonts"),
|
|
45
46
|
fontlicenseagreement: flex_attr_name(node, "font-license-agreement"),
|
|
46
47
|
localizenumber: flex_attr_name(node, "localize-number"),
|
|
@@ -92,6 +93,7 @@ module Metanorma
|
|
|
92
93
|
tocfigures: @tocfigures,
|
|
93
94
|
toctables: @toctables,
|
|
94
95
|
tocrecommendations: @tocrecommendations,
|
|
96
|
+
tocexamples: @tocexamples,
|
|
95
97
|
fonts: flex_attr_name(node, "fonts"),
|
|
96
98
|
fontlicenseagreement: flex_attr_name(node, "font-license-agreement"),
|
|
97
99
|
}
|
|
@@ -213,6 +213,12 @@ Sources are currently only rendered in metanorma-plateau</a:documentation>
|
|
|
213
213
|
<define name="ExampleAttributes">
|
|
214
214
|
<ref name="NumberingAttributes"/>
|
|
215
215
|
<ref name="BlockAttributes"/>
|
|
216
|
+
<optional>
|
|
217
|
+
<attribute name="collapsible">
|
|
218
|
+
<a:documentation>Render the example as collapsible (HTML5 details/summary)</a:documentation>
|
|
219
|
+
<data type="boolean"/>
|
|
220
|
+
</attribute>
|
|
221
|
+
</optional>
|
|
216
222
|
</define>
|
|
217
223
|
<define name="ExampleBody">
|
|
218
224
|
<optional>
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: metanorma-standoc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.4.
|
|
4
|
+
version: 3.4.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: addressable
|
|
@@ -544,7 +543,6 @@ licenses:
|
|
|
544
543
|
- BSD-2-Clause
|
|
545
544
|
metadata:
|
|
546
545
|
rubygems_mfa_required: 'true'
|
|
547
|
-
post_install_message:
|
|
548
546
|
rdoc_options: []
|
|
549
547
|
require_paths:
|
|
550
548
|
- lib
|
|
@@ -559,8 +557,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
559
557
|
- !ruby/object:Gem::Version
|
|
560
558
|
version: '0'
|
|
561
559
|
requirements: []
|
|
562
|
-
rubygems_version:
|
|
563
|
-
signing_key:
|
|
560
|
+
rubygems_version: 4.0.10
|
|
564
561
|
specification_version: 4
|
|
565
562
|
summary: metanorma-standoc realises standards following the Metanorma standoc model
|
|
566
563
|
test_files: []
|