metanorma-standoc 3.5.14 → 3.5.15
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/standoc/version.rb +1 -1
- data/lib/metanorma/validate/image.rb +22 -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: 9b96f30e3e0dc5c448502269fa1384221782345409d54b53cf1a331072b950d4
|
|
4
|
+
data.tar.gz: c0fbaf1cc758d4405335f682229231a3aadddba407e1675ca9a4f77e69941f1c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e7e559b5e9a048921cc3721120a82cd5e87bbc146dd9e94b6f592ca3df727d289f087479788f4dfb218ee9cf5d725c0917aab3b36748ed23f42148b485bf6490
|
|
7
|
+
data.tar.gz: b06efa3d77680c503712787b55551239e0746823fb120ec224485378a0369ac4f36c3e9c137e5352328fe786272d61a4c85d2211c7054626d4bd1108700da2fd
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require "svg_conform"
|
|
2
2
|
require "png_conform"
|
|
3
|
+
require "yaml"
|
|
3
4
|
require "metanorma/standoc/conform_profiles"
|
|
4
5
|
|
|
5
6
|
module Metanorma
|
|
@@ -91,6 +92,8 @@ module Metanorma
|
|
|
91
92
|
|
|
92
93
|
def png_validate(doc)
|
|
93
94
|
return if png_conform_profile == :disabled
|
|
95
|
+
profile = png_conform_engine_profile(png_conform_profile)
|
|
96
|
+
profile.nil? and return
|
|
94
97
|
doc.xpath("//image[@mimetype = 'image/png'][@src]").each do |i|
|
|
95
98
|
Vectory::Utils::url?(i["src"]) and next
|
|
96
99
|
uri = Vectory::Utils::datauri?(i["src"])
|
|
@@ -98,13 +101,31 @@ module Metanorma
|
|
|
98
101
|
path or next
|
|
99
102
|
PngConform::Readers::StreamingReader.open(path) do |reader|
|
|
100
103
|
v = PngConform::Services::ValidationService.new(
|
|
101
|
-
reader, path, { profile:
|
|
104
|
+
reader, path, { profile: profile }
|
|
102
105
|
)
|
|
103
106
|
png_validate1(i, path, v)
|
|
104
107
|
end
|
|
105
108
|
end
|
|
106
109
|
end
|
|
107
110
|
|
|
111
|
+
# png_conform 0.1.6 takes a definition Hash, a built-in/YAML
|
|
112
|
+
# profile name, or nil/"none" (claricle/png_conform#34). Our
|
|
113
|
+
# descriptor is {profile_file:} (an owned YAML file, loaded as an
|
|
114
|
+
# inline definition — the gem reads no consumer directories) or
|
|
115
|
+
# {engine_profile:} (a gem-profile name, resolved loudly there).
|
|
116
|
+
def png_conform_engine_profile(descriptor)
|
|
117
|
+
case descriptor
|
|
118
|
+
when Hash
|
|
119
|
+
if (file = descriptor[:profile_file])
|
|
120
|
+
YAML.safe_load(File.read(file))
|
|
121
|
+
else
|
|
122
|
+
descriptor[:engine_profile]
|
|
123
|
+
end
|
|
124
|
+
else
|
|
125
|
+
descriptor
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
108
129
|
def png_validate1(img, _path, validator)
|
|
109
130
|
ret = validator.validate
|
|
110
131
|
ret.error_messages.each do |e|
|