metanorma-standoc 3.5.19 → 3.5.20
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7d793bd2fe69d69038a794758d043907343cc86c941f23e6bc27e7b521e3ff8e
|
|
4
|
+
data.tar.gz: 5ab4fdf66f6258898a72a40e2475ef6dc655a0e02498ca2b8d7ed1e280776d99
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 39ca7913b41d2e1c910abb799f458d2136e6999e13861a1aa22f70a21b144059decd46f4b62fd0768b2f657de2d1cbd65367b9376c89ad13c3a873ac834c3f73
|
|
7
|
+
data.tar.gz: 6d08352ddda756491ef7270a32711c76d60a451bc8a066e3cf8a590b3f54bd124000ae6860230fc3849b32e4b97ee499f1447e594ae00f031736e834a1e5db99
|
|
@@ -2,8 +2,17 @@ module Metanorma
|
|
|
2
2
|
module Standoc
|
|
3
3
|
module Text
|
|
4
4
|
def ancestor_include?(elem, ancestors)
|
|
5
|
-
|
|
6
|
-
path
|
|
5
|
+
# Walk the parent chain instead of building elem.path: the libxml
|
|
6
|
+
# path string plus regex/split ran per text node during
|
|
7
|
+
# linebreak cleanup and smart-quote processing, and dominated
|
|
8
|
+
# cleanup CPU on large documents.
|
|
9
|
+
parent = elem.parent
|
|
10
|
+
while parent && parent.element?
|
|
11
|
+
return true if ancestors.include?(parent.name)
|
|
12
|
+
|
|
13
|
+
parent = parent.parent
|
|
14
|
+
end
|
|
15
|
+
false
|
|
7
16
|
end
|
|
8
17
|
|
|
9
18
|
# process example/p, example/sourcecode, not example on its own:
|
|
@@ -213,6 +213,11 @@ module Metanorma
|
|
|
213
213
|
STANDOC_68: { category: "Suppression",
|
|
214
214
|
error: "Validation suppression active: %s",
|
|
215
215
|
severity: 3 },
|
|
216
|
+
STANDOC_69: { category: "Include",
|
|
217
|
+
error: "Unresolved directive %s: the file %s exists " \
|
|
218
|
+
"but lies outside the include jail %s; compile " \
|
|
219
|
+
"with --base-dir <directory> to widen the jail",
|
|
220
|
+
severity: 0 },
|
|
216
221
|
RELATON_1: { category: "Relaton",
|
|
217
222
|
error: "(Error from Relaton) %s",
|
|
218
223
|
severity: 0 },
|
|
@@ -13,14 +13,35 @@ module Asciidoctor
|
|
|
13
13
|
if inc_path && !%i(file uri).include?(target_type)
|
|
14
14
|
# include has been skipped because of error
|
|
15
15
|
n = peek_line(true)
|
|
16
|
-
/^Unresolved directive in/.match?(n) and
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
)])
|
|
16
|
+
/^Unresolved directive in/.match?(n) and begin
|
|
17
|
+
code, params = include_failure_code(n, expanded_target)
|
|
18
|
+
@document.converter.log&.add(code, nil, **params)
|
|
19
|
+
end
|
|
21
20
|
end
|
|
22
21
|
[inc_path, target_type, relpath]
|
|
23
22
|
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
# A skipped include whose target exists on disk but outside the
|
|
27
|
+
# document's include jail is a jail reach, not a missing file: the
|
|
28
|
+
# generic STANDOC_41 "unresolved" row sends the reader hunting for a
|
|
29
|
+
# file that is right there (metanorma-cli#490). Name the jail and the
|
|
30
|
+
# --base-dir flag instead.
|
|
31
|
+
def include_failure_code(line, expanded_target)
|
|
32
|
+
encoded = HTMLEntities.new.encode(
|
|
33
|
+
line.sub(/^Unresolved directive /, ""), :basic
|
|
34
|
+
)
|
|
35
|
+
candidate = File.expand_path(expanded_target.to_s, dir)
|
|
36
|
+
jail = File.expand_path(@document.base_dir.to_s)
|
|
37
|
+
outside = File.exist?(candidate) &&
|
|
38
|
+
candidate != jail && !candidate.start_with?(jail + File::SEPARATOR)
|
|
39
|
+
if outside
|
|
40
|
+
["STANDOC_69", { params: [encoded, candidate, jail] }]
|
|
41
|
+
else
|
|
42
|
+
["STANDOC_41", { params: [encoded] }]
|
|
43
|
+
end
|
|
44
|
+
end
|
|
24
45
|
end
|
|
25
46
|
end
|
|
26
47
|
|
|
@@ -145,6 +145,15 @@ module Metanorma
|
|
|
145
145
|
end
|
|
146
146
|
|
|
147
147
|
# Use SAX for fast validation
|
|
148
|
+
#
|
|
149
|
+
# Machine-emitted diagram images are skipped: the svgmap blocks
|
|
150
|
+
# emitted for EXPRESS-G and other generated diagrams (e.g. by
|
|
151
|
+
# stepmod2mn) wrap pre-baked placeholder SVG/GIF assets which are
|
|
152
|
+
# not author-authored content, and their eref integrity is
|
|
153
|
+
# enforced separately when svgmap targets are resolved at render
|
|
154
|
+
# time. Validating them through SvgConform costs heavily on
|
|
155
|
+
# diagram-heavy corpora and yields nothing the render does not
|
|
156
|
+
# already catch.
|
|
148
157
|
def svg_validate(doc)
|
|
149
158
|
profile = svg_conform_profile
|
|
150
159
|
profile.nil? and return
|
|
@@ -152,6 +161,7 @@ module Metanorma
|
|
|
152
161
|
engine = SvgConform::RemediationEngine.new(profile)
|
|
153
162
|
@svg_remediation_cache = {}
|
|
154
163
|
doc.xpath("//m:svg", "m" => SVG_NS).each do |svg_element|
|
|
164
|
+
svgmap_emission?(svg_element) and next
|
|
155
165
|
result = svg_validate1(validator, profile, svg_element)
|
|
156
166
|
if profile.remediation_count.positive? && !result.valid?
|
|
157
167
|
svg_remediate(validator, profile, engine, svg_element,
|
|
@@ -160,6 +170,16 @@ module Metanorma
|
|
|
160
170
|
end
|
|
161
171
|
end
|
|
162
172
|
|
|
173
|
+
# Is this inline SVG a machine-generated diagram emission, rather
|
|
174
|
+
# than an author-provided SVG asset? svgmaps that carry eref
|
|
175
|
+
# targets survive cleanup as wrappers of their diagram, so a
|
|
176
|
+
# svgmap ancestor marks the diagram as svgmap-emitted. Author
|
|
177
|
+
# SVGs (plain image elements) have no svgmap ancestor and keep
|
|
178
|
+
# being validated.
|
|
179
|
+
def svgmap_emission?(svg)
|
|
180
|
+
!svg.at_xpath("ancestor::svgmap").nil?
|
|
181
|
+
end
|
|
182
|
+
|
|
163
183
|
def svg_validate1(validator, profile, svg)
|
|
164
184
|
result = validator.validate(svg, profile: profile)
|
|
165
185
|
svg_error("STANDOC_55", svg, result.errors, display: false)
|