isodoc 2.7.4 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +1 -4
- data/isodoc.gemspec +1 -1
- data/lib/isodoc/html_function/postprocess.rb +1 -1
- data/lib/isodoc/presentation_function/image.rb +38 -76
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc.rb +1 -0
- metadata +17 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7399ef0fe36a0b345f15af67b09daec6f68ed36ce2226af1469ace300d4e3fa9
|
4
|
+
data.tar.gz: 5d03fbb31c3a38b11ca47d34a1673326f68e7db9f577de5995944b4c1e77d1f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b5fb43c2a320525f7a1ce8e30d376ee687fd3295e16aa9336e846db7f93958d130e50b896216cbc651e4b33037840c97d9df2b6a9f578cc8dfef34a89bed098
|
7
|
+
data.tar.gz: 5b9bb3130bde935c9d420c02092d5c341ed2bdb18e7a5aaa2e718a58798c165c8130b7a036ff4619b19ef2655d41223a7f13b5c110bd0e5b2881a877920d0119
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
spec/assets/img.svg
|
data/Gemfile
CHANGED
data/isodoc.gemspec
CHANGED
@@ -31,7 +31,6 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_dependency "html2doc", "~> 1.7.1"
|
32
32
|
spec.add_dependency "htmlentities", "~> 4.3.4"
|
33
33
|
# spec.add_dependency "isodoc-i18n", "~> 1.1.0" # already in relaton-render and mn-requirements
|
34
|
-
spec.add_dependency "emf2svg"
|
35
34
|
spec.add_dependency "liquid", "~> 5"
|
36
35
|
#spec.add_dependency "relaton-cli"
|
37
36
|
# spec.add_dependency "metanorma-utils", "~> 1.5.0" # already in isodoc-i18n
|
@@ -44,6 +43,7 @@ Gem::Specification.new do |spec|
|
|
44
43
|
spec.add_dependency "thread_safe"
|
45
44
|
spec.add_dependency "twitter_cldr", ">= 6.6.0"
|
46
45
|
spec.add_dependency "uuidtools"
|
46
|
+
spec.add_dependency "vectory", "~> 0.6"
|
47
47
|
|
48
48
|
spec.add_development_dependency "debug"
|
49
49
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require "base64"
|
2
|
-
require "emf2svg"
|
3
2
|
|
4
3
|
module IsoDoc
|
5
4
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
@@ -92,33 +91,56 @@ module IsoDoc
|
|
92
91
|
|
93
92
|
def svg_prep(img)
|
94
93
|
img["mimetype"] = "image/svg+xml"
|
95
|
-
%r{^data:
|
96
|
-
img["src"] =
|
94
|
+
%r{^data:}.match?(img["src"]) or
|
95
|
+
img["src"] = Vectory::Emf.from_path(img["src"]).to_uri.content
|
97
96
|
end
|
98
97
|
|
99
98
|
def emf_to_svg(img)
|
100
|
-
|
101
|
-
|
99
|
+
datauri_src = img.at(ns("./emf/@src")).text
|
100
|
+
Vectory::Emf.from_datauri(datauri_src)
|
101
|
+
.to_svg
|
102
|
+
.content
|
103
|
+
.sub(/<\?[^>]+>/, "")
|
102
104
|
end
|
103
105
|
|
104
106
|
def eps_to_svg(node)
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
107
|
+
if !node.text.strip.empty? || %r{^data:}.match?(node["src"])
|
108
|
+
return eps_to_svg_from_node(node)
|
109
|
+
end
|
110
|
+
|
111
|
+
target_path = imgfile_suffix(node["src"], "svg")
|
112
|
+
return target_path if File.exist?(target_path)
|
113
|
+
|
114
|
+
eps_to_svg_from_node(node, target_path)
|
115
|
+
end
|
116
|
+
|
117
|
+
def eps_to_svg_from_node(node, target_path = nil)
|
118
|
+
svg = Vectory::Eps.from_node(node).to_svg
|
119
|
+
return svg.write(target_path).path if target_path
|
120
|
+
|
121
|
+
svg.write.path
|
109
122
|
end
|
110
123
|
|
111
124
|
def svg_to_emf(node)
|
112
125
|
@output_formats[:doc] or return
|
113
|
-
|
126
|
+
|
114
127
|
svg_impose_height_attr(node)
|
115
|
-
|
116
|
-
if
|
117
|
-
|
118
|
-
return ret
|
128
|
+
|
129
|
+
if node.elements&.first&.name == "svg" || %r{^data:}.match?(node["src"])
|
130
|
+
return svg_to_emf_from_node(node)
|
119
131
|
end
|
120
|
-
|
121
|
-
|
132
|
+
|
133
|
+
target_path = imgfile_suffix(node["src"], "emf")
|
134
|
+
return target_path if File.exist?(target_path)
|
135
|
+
|
136
|
+
svg_to_emf_from_node(node, target_path)
|
137
|
+
end
|
138
|
+
|
139
|
+
def svg_to_emf_from_node(node, target_path = nil)
|
140
|
+
emf = Vectory::Svg.from_node(node).to_emf
|
141
|
+
return emf.write(target_path).to_uri.content if target_path
|
142
|
+
|
143
|
+
emf.to_uri.content
|
122
144
|
end
|
123
145
|
|
124
146
|
def svg_impose_height_attr(node)
|
@@ -129,68 +151,8 @@ module IsoDoc
|
|
129
151
|
node["width"] = e["width"]
|
130
152
|
end
|
131
153
|
|
132
|
-
def inkscape_convert(uri, file, option)
|
133
|
-
exe = inkscape_installed? or raise "Inkscape missing in PATH, unable" \
|
134
|
-
"to convert image #{uri}. Aborting."
|
135
|
-
uri = Metanorma::Utils::external_path uri
|
136
|
-
exe = Metanorma::Utils::external_path exe
|
137
|
-
warn %(#{exe} #{option} #{uri})
|
138
|
-
err = system %(#{exe} #{option} #{uri})
|
139
|
-
File.exist?(file) and return Metanorma::Utils::datauri(file)
|
140
|
-
file2 = uri + File.extname(file)
|
141
|
-
warn "Checking #{file2}"
|
142
|
-
File.exist?(file2) and return Metanorma::Utils::datauri(file2)
|
143
|
-
raise %(Fail on #{exe} #{option} #{uri} outputting #{file}: status #{err})
|
144
|
-
end
|
145
|
-
|
146
|
-
def svg_to_emf_uri(node)
|
147
|
-
uri = svg_to_emf_uri_convert(node)
|
148
|
-
cache_dataimage(uri)
|
149
|
-
end
|
150
|
-
|
151
|
-
def eps_to_svg_uri(node)
|
152
|
-
uri = eps_to_svg_uri_convert(node)
|
153
|
-
cache_dataimage(uri)
|
154
|
-
end
|
155
|
-
|
156
|
-
def cache_dataimage(uri)
|
157
|
-
if %r{^data:}.match?(uri)
|
158
|
-
uri = save_dataimage(uri)
|
159
|
-
end
|
160
|
-
uri
|
161
|
-
end
|
162
|
-
|
163
|
-
def svg_to_emf_uri_convert(node)
|
164
|
-
if node.elements&.first&.name == "svg"
|
165
|
-
a = Base64.strict_encode64(node.children.to_xml)
|
166
|
-
"data:image/svg+xml;base64,#{a}"
|
167
|
-
else node["src"]
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
def eps_to_svg_uri_convert(node)
|
172
|
-
if node.text.strip.empty?
|
173
|
-
node["src"]
|
174
|
-
else
|
175
|
-
a = Base64.strict_encode64(node.children.to_xml)
|
176
|
-
"data:application/postscript;base64,#{a}"
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
154
|
def imgfile_suffix(uri, suffix)
|
181
155
|
"#{File.join(File.dirname(uri), File.basename(uri, '.*'))}.#{suffix}"
|
182
156
|
end
|
183
|
-
|
184
|
-
def inkscape_installed?
|
185
|
-
cmd = "inkscape"
|
186
|
-
exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]
|
187
|
-
ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
|
188
|
-
exts.each do |ext|
|
189
|
-
exe = File.join(path, "#{cmd}#{ext}")
|
190
|
-
return exe if File.executable?(exe) && !File.directory?(exe)
|
191
|
-
end
|
192
|
-
end
|
193
|
-
nil
|
194
|
-
end
|
195
157
|
end
|
196
158
|
end
|
data/lib/isodoc/version.rb
CHANGED
data/lib/isodoc.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isodoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: html2doc
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 4.3.4
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: emf2svg
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: liquid
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,6 +164,20 @@ dependencies:
|
|
178
164
|
- - ">="
|
179
165
|
- !ruby/object:Gem::Version
|
180
166
|
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: vectory
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0.6'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0.6'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: debug
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -329,6 +329,7 @@ executables: []
|
|
329
329
|
extensions: []
|
330
330
|
extra_rdoc_files: []
|
331
331
|
files:
|
332
|
+
- ".gitignore"
|
332
333
|
- ".hound.yml"
|
333
334
|
- ".oss-guides.rubocop.yml"
|
334
335
|
- ".rubocop.yml"
|