isodoc 2.7.4 → 2.8.1
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/metadata_contributor.rb +2 -2
- data/lib/isodoc/presentation_function/image.rb +38 -76
- data/lib/isodoc/presentation_function/refs.rb +2 -2
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/postprocess.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: 3a4ea94214377595240bcb873426fb3170509fd7e535b2c277fff4dbb6077f95
|
4
|
+
data.tar.gz: 46c9e47211dbbd225871f4ea91a86697c119b0d60a5359b974795c303becca18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9862cb11f6f06fb48052a21c5a1289e53677a2d357da003434d66251a28fd4c62cda42696e2d906448f791edd485545bc7a7257764eabeb6125f35ef287dfd15
|
7
|
+
data.tar.gz: db953889f3de823b3bb107d9c694088c81fc68ebf16d8f75cd38d78aef13b5794b0349cff181e8c1f9c3566b16c9b8ffa7da57a8baa02cfb937317658d807c79
|
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"
|
@@ -58,8 +58,8 @@ module IsoDoc
|
|
58
58
|
def iso?(org)
|
59
59
|
name = org&.at(ns("./name"))&.text
|
60
60
|
abbrev = org&.at(ns("./abbreviation"))&.text
|
61
|
-
|
62
|
-
|
61
|
+
abbrev == "ISO" ||
|
62
|
+
name == "International Organization for Standardization"
|
63
63
|
end
|
64
64
|
|
65
65
|
def agency1(xml)
|
@@ -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
|
@@ -16,7 +16,7 @@ module IsoDoc
|
|
16
16
|
s = docxml.at(ns("//sections")) ||
|
17
17
|
docxml.at(ns("//preface"))&.after("<sections/>")&.next_element ||
|
18
18
|
docxml.at(ns("//annex | //bibliography"))&.before("<sections/>")
|
19
|
-
|
19
|
+
&.previous_element or return
|
20
20
|
docxml.xpath(ns(@xrefs.klass.norm_ref_xpath)).each do |r|
|
21
21
|
s << r.remove
|
22
22
|
end
|
@@ -163,7 +163,7 @@ module IsoDoc
|
|
163
163
|
# else, use both ordinal, as prefix, and ids
|
164
164
|
def biblio_ref_entry_code(ordinal, ids, _id, _standard, datefn, _bib)
|
165
165
|
# standard and id = nil
|
166
|
-
ret =
|
166
|
+
ret = ids[:ordinal] || ids[:metanorma] || "[#{ordinal}]"
|
167
167
|
if ids[:sdo]
|
168
168
|
ret = prefix_bracketed_ref(ret)
|
169
169
|
ret += "#{ids[:sdo]}#{datefn}, "
|
data/lib/isodoc/version.rb
CHANGED
@@ -99,7 +99,7 @@ module IsoDoc
|
|
99
99
|
def word_tab_clean(docxml)
|
100
100
|
docxml.xpath("//p[@class='Biblio']//span[@style='mso-tab-count:1']")
|
101
101
|
.each do |s|
|
102
|
-
s.next
|
102
|
+
s.next&.text? or next
|
103
103
|
s.next.replace(@c.encode(s.next.text.sub(/^\s+/, ""), :hexadecimal))
|
104
104
|
end
|
105
105
|
end
|
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.1
|
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-02-08 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"
|