metanorma-plugin-lutaml 0.7.61 → 0.7.62
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: 102085caacd4951ba78acd47b10eecec2fd50c6646270bd15c70444d4a54bb3e
|
|
4
|
+
data.tar.gz: 42939df5ca71fe3e838277864054f215d5b3432310792d75384983eb4a35b7cb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 550a516ed78801a0a5359a114edac8258bc1c94e0f72384a2d0f338ab38c8476f729de6fb2d4876c21729569badbdfdce17b13e7a6bd0d4164a1a860b319c388
|
|
7
|
+
data.tar.gz: a641b9efc125a5fce7432c43dd1e49fd673abef9f8991e73a3e182f5a44e7a987e40a741164e8be75f9198497d9063e29d44972a1a500f9cc1c90573d7fe9472
|
|
@@ -17,43 +17,25 @@ module Metanorma
|
|
|
17
17
|
)
|
|
18
18
|
resolved = document.path_resolver
|
|
19
19
|
.system_path(file_path, docfile_directory)
|
|
20
|
+
# The decorator expands emitted paths against this base: relative
|
|
21
|
+
# prefixes alone get re-anchored by asciidoctor's imagesdir
|
|
22
|
+
# handling (images/../../schemas collapses a level), so the
|
|
23
|
+
# decoration must produce paths that resolve from the docfile.
|
|
24
|
+
options["relative_path_base"] =
|
|
25
|
+
File.expand_path(docfile_directory)
|
|
20
26
|
# The prefix lands inside emitted image macros, so it must not
|
|
21
27
|
# carry the absolute build path: two builds of the same tree in
|
|
22
28
|
# two directories produced different image/@src values
|
|
23
29
|
# (metanorma/metanorma-plugin-lutaml#325). A path relative to the
|
|
24
30
|
# docfile resolves to the same schema file at render time and is
|
|
25
|
-
# byte-identical across build directories
|
|
26
|
-
# as written rather than expanding it.
|
|
27
|
-
#
|
|
28
|
-
# The render resolves image targets against the imagesdir joined
|
|
29
|
-
# onto the docfile directory, not the bare docfile: a target
|
|
30
|
-
# relative to the bare docfile is re-anchored through the
|
|
31
|
-
# imagesdir prefix and every decorated diagram misses by its
|
|
32
|
-
# depth (metanorma/iso-10303 smol-all FATAL: emitted
|
|
33
|
-
# `../schemas/…`, resolved as `images/../schemas/…`). Compute the
|
|
34
|
-
# prefix against the directory the render resolves from.
|
|
31
|
+
# byte-identical across build directories.
|
|
35
32
|
# The docfile directory may be relative ("."): relative_path_from
|
|
36
33
|
# refuses mixed prefixes, so both sides expand first
|
|
37
34
|
Pathname.new(File.expand_path(resolved))
|
|
38
|
-
.relative_path_from(
|
|
39
|
-
Pathname.new(image_resolve_base(document, docfile_directory)),
|
|
40
|
-
)
|
|
35
|
+
.relative_path_from(Pathname.new(File.expand_path(docfile_directory)))
|
|
41
36
|
.to_s
|
|
42
37
|
end
|
|
43
38
|
|
|
44
|
-
# The directory image targets resolve against: the docfile
|
|
45
|
-
# directory with the imagesdir joined on. A web or absolute
|
|
46
|
-
# imagesdir bypasses the join; the bare docfile directory is the
|
|
47
|
-
# closest approximation.
|
|
48
|
-
def self.image_resolve_base(document, docfile_directory)
|
|
49
|
-
base = File.expand_path(docfile_directory)
|
|
50
|
-
imagesdir = document.attributes["imagesdir"]
|
|
51
|
-
return base if imagesdir.nil? || imagesdir.empty?
|
|
52
|
-
return base if imagesdir.match?(%r{\A(?:[a-z]+:|/)})
|
|
53
|
-
|
|
54
|
-
File.expand_path(imagesdir, base)
|
|
55
|
-
end
|
|
56
|
-
|
|
57
39
|
def self.for(model)
|
|
58
40
|
case model
|
|
59
41
|
when Expressir::Model::Cache
|
|
@@ -68,15 +68,19 @@ module Metanorma
|
|
|
68
68
|
return line if path_prefix && line.include?(path_prefix)
|
|
69
69
|
|
|
70
70
|
line.gsub(RELATIVE_PREFIX_MACRO_REGEXP) do |_match|
|
|
71
|
-
#
|
|
72
|
-
#
|
|
73
|
-
#
|
|
74
|
-
#
|
|
75
|
-
#
|
|
76
|
-
#
|
|
77
|
-
#
|
|
78
|
-
#
|
|
79
|
-
|
|
71
|
+
# Expand against the docfile directory (passed by the adapter
|
|
72
|
+
# as relative_path_base), NOT the process CWD: a CWD expansion
|
|
73
|
+
# produced absolute image paths under whatever directory the
|
|
74
|
+
# build was launched from (e.g. <repo>/../../schemas/...).
|
|
75
|
+
# The absolute result is deliberate: relative targets are
|
|
76
|
+
# re-anchored by asciidoctor's imagesdir handling
|
|
77
|
+
# (images/../../schemas collapses a level), which made every
|
|
78
|
+
# decorated diagram unresolvable at render time.
|
|
79
|
+
full_path = File.expand_path(
|
|
80
|
+
File.join(path_prefix, $3.strip),
|
|
81
|
+
options["relative_path_base"] || Dir.pwd,
|
|
82
|
+
)
|
|
83
|
+
"#{$1}#{$2}#{full_path}#{$4}"
|
|
80
84
|
end
|
|
81
85
|
end
|
|
82
86
|
end
|