ydocx 1.1.0 → 1.1.1
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.
- data/History.txt +4 -0
- data/lib/ydocx/parser.rb +31 -21
- data/lib/ydocx.rb +1 -1
- metadata +5 -5
data/History.txt
CHANGED
data/lib/ydocx/parser.rb
CHANGED
@@ -145,27 +145,37 @@ module YDocx
|
|
145
145
|
nil # default no block element
|
146
146
|
end
|
147
147
|
def parse_image(r)
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
148
|
+
id = nil
|
149
|
+
additional_namespaces = {
|
150
|
+
'xmlns:a' => 'http://schemas.openxmlformats.org/drawingml/2006/main',
|
151
|
+
'xmlns:pic' => 'http://schemas.openxmlformats.org/drawingml/2006/picture'
|
152
|
+
}
|
153
|
+
ns = r.namespaces.merge additional_namespaces
|
154
|
+
paths = {
|
155
|
+
:id => '//w:pict//v:shape//v:imagedata',
|
156
|
+
:embed => '//w:drawing//wp:anchor//a:graphic//a:graphicData//pic:pic//pic:blipFill//a:blip'
|
157
|
+
}.each do |attr, path|
|
158
|
+
if image = r.xpath(path, ns) and !image.empty?
|
159
|
+
id = image.first[attr.to_s]
|
160
|
+
end
|
161
|
+
end
|
162
|
+
if id
|
163
|
+
@rel.xpath('/').children.each do |element|
|
164
|
+
element.children.each do |rel|
|
165
|
+
if rel['Id'] == id and rel['Target']
|
166
|
+
target = rel['Target']
|
167
|
+
source = id.downcase + '/'
|
168
|
+
if defined? Magick::Image and
|
169
|
+
ext = File.extname(target).match(/\.wmf$/).to_a[0]
|
170
|
+
source << File.basename(target, ext) + '.png'
|
171
|
+
else
|
172
|
+
source << File.basename(target)
|
168
173
|
end
|
174
|
+
@pictures << {
|
175
|
+
:origin => target,
|
176
|
+
:source => source
|
177
|
+
}
|
178
|
+
return markup :img, [], {:src => source}
|
169
179
|
end
|
170
180
|
end
|
171
181
|
end
|
@@ -194,7 +204,7 @@ module YDocx
|
|
194
204
|
content << optional_replace(code)
|
195
205
|
pos += 1
|
196
206
|
end
|
197
|
-
|
207
|
+
if !r.xpath('w:pict').empty? or !r.xpath('w:drawing').empty?
|
198
208
|
content << parse_image(r)
|
199
209
|
end
|
200
210
|
end
|
data/lib/ydocx.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ydocx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-05-07 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdoc
|
16
|
-
requirement: &
|
16
|
+
requirement: &13563740 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.10'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *13563740
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: hoe
|
27
|
-
requirement: &
|
27
|
+
requirement: &13563320 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '2.13'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *13563320
|
36
36
|
description: ''
|
37
37
|
email:
|
38
38
|
- yasaka@ywesee.com, zdavatz@ywesee.com
|