metanorma 2.5.12 → 2.5.13
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/Gemfile +4 -0
- data/lib/metanorma/collection/renderer/utils.rb +50 -2
- data/lib/metanorma/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8e2bbe018164520f24a47304e5a543b33162f139617e751a7bd4a71f5bc4b8c8
|
|
4
|
+
data.tar.gz: cd865930cf21c065807ef2d2e357ce3ee41b1c35708ecdb69ea59eb59963f504
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 774a88cefafe5985f8868890f62e1ed552c51a9ffb64cd5b3744394dfe424650a2d32742b48238cb438e03a1ab658ff2681783ad8ed343fcf8d95bc6997ef180
|
|
7
|
+
data.tar.gz: fb5f625706d30499551cad94edad5f9aa4f604e3a60c4ab43c0baf3ff83c298d396db5724dc47f58f04545a2d8d0a45afed1fd0d87ad0fa753db09ba9867bc19
|
data/Gemfile
CHANGED
|
@@ -30,6 +30,10 @@ gem "canon", "~> 0.3.122"
|
|
|
30
30
|
gem "lutaml-store", "~> 0.3.11"
|
|
31
31
|
#gem "metanorma-iho"
|
|
32
32
|
#gem "metanorma-iso", ">= 3.2.0"
|
|
33
|
+
# Floor fontist at the variable-font indexing fix (fontist#531/#532):
|
|
34
|
+
# anything below 3.0.31 misses freshly installed variable fonts on
|
|
35
|
+
# locations lookups ("Fira Code" MissingFontError, metanorma-iho#563).
|
|
36
|
+
gem "fontist", "~> 3.0.32"
|
|
33
37
|
gem "mnconvert"
|
|
34
38
|
gem "pry"
|
|
35
39
|
gem "rake", "~> 13.0"
|
|
@@ -153,15 +153,63 @@ module Metanorma
|
|
|
153
153
|
::Metanorma::Util.log(error, :warning)
|
|
154
154
|
end
|
|
155
155
|
|
|
156
|
+
# Image relocation for collection rendering, in three ordered passes:
|
|
157
|
+
# anchor every image target at the document that emitted it, then
|
|
158
|
+
# inline SVGs, then encode what remains as data URIs.
|
|
156
159
|
def datauri_encode(docxml, directory)
|
|
160
|
+
anchor_image_targets(docxml, directory)
|
|
161
|
+
inline_svg_images(docxml, directory)
|
|
162
|
+
datauri_images(docxml, directory)
|
|
163
|
+
docxml
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Image targets are emitted relative to the document that carries them
|
|
167
|
+
# (metanorma#646). Each target must be anchored at the emitting
|
|
168
|
+
# document's directory BEFORE it is resolved: Vectory's datauri
|
|
169
|
+
# fallback tries the process working directory first, so a relative
|
|
170
|
+
# target was resolved against wherever the build happened to run --
|
|
171
|
+
# picking a same-named file from the wrong tree, or missing both
|
|
172
|
+
# bases and failing the render. Data URIs, remote URLs and absolute
|
|
173
|
+
# paths carry their own base and pass through; a target that anchors
|
|
174
|
+
# to an existing file is pinned to that absolute path, so only the
|
|
175
|
+
# file's bytes reach the output and the output is build-directory
|
|
176
|
+
# independent. A target that anchors to nothing keeps its emitted
|
|
177
|
+
# form, so a missing image stays a build-independent dangling
|
|
178
|
+
# reference.
|
|
179
|
+
def anchor_image_targets(docxml, directory)
|
|
180
|
+
docxml.xpath(ns("//image")).each do |i|
|
|
181
|
+
anchor_image_target(i, directory)
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def inline_svg_images(docxml, directory)
|
|
157
186
|
docxml.xpath(ns("//image")).each do |i|
|
|
158
187
|
read_in_if_svg(i, directory.sub(%r{(?<!=/)$}, "/"))
|
|
159
188
|
end
|
|
160
|
-
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def datauri_images(docxml, directory)
|
|
192
|
+
docxml.xpath(ns("//image")).each do |i|
|
|
161
193
|
(i["src"] && !i["src"].empty?) or next
|
|
162
194
|
i["src"] = Vectory::Utils::datauri(i["src"], directory)
|
|
163
195
|
end
|
|
164
|
-
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def anchor_image_target(img, directory)
|
|
199
|
+
src = img["src"]
|
|
200
|
+
anchorable_base?(src) or return
|
|
201
|
+
path = File.expand_path(src, directory)
|
|
202
|
+
File.file?(path) or return
|
|
203
|
+
img["src"] = path
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# A target whose base is already determined cannot be re-anchored.
|
|
207
|
+
def anchorable_base?(src)
|
|
208
|
+
return false if src.nil? || src.empty?
|
|
209
|
+
|
|
210
|
+
!(Vectory::Utils.datauri?(src) ||
|
|
211
|
+
Vectory::Utils.url?(src) ||
|
|
212
|
+
Vectory::Utils.absolute_path?(src))
|
|
165
213
|
end
|
|
166
214
|
|
|
167
215
|
def read_in_if_svg(img, localdir)
|
data/lib/metanorma/version.rb
CHANGED