avv2word 1.1.30 → 1.1.31
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/avv2word/document.rb +24 -8
- data/lib/avv2word/templates/default.docx +0 -0
- data/lib/avv2word/version.rb +1 -1
- data/lib/avv2word/xslt/links.xslt +1 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d8568faddf890ada2e05ab971a1d9829938e0300213f0c510921322ad2f71a0
|
4
|
+
data.tar.gz: 3a175e32880587cdad276769604517f774c1995c1134802c5d8214aee82e7365
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2e040b9b91976b7ce8a58723af3de9863e433d93f35728aaa46a74527932f7514d4ffd9c974bcb017c38d282c2c0b016e8e97b428c1c0fd4ba59f8bad2c5747
|
7
|
+
data.tar.gz: f971b5da98c1f4af48fbb7ce3c24870a1eb218e4174589d88a9a1503fb89726fdec17df71d3953879a3f6e1504ce20577c27cdcdde715927c24d88a5b9b4be07
|
data/lib/avv2word/document.rb
CHANGED
@@ -272,19 +272,34 @@ module Avv2word
|
|
272
272
|
end
|
273
273
|
end
|
274
274
|
|
275
|
-
def
|
275
|
+
def inject_relations(relations, noko_html_source)
|
276
276
|
rel_doc = Nokogiri::XML(relations)
|
277
277
|
relations_root = rel_doc.css("Relationships").first
|
278
|
-
|
279
278
|
relations_size = relations_root.css("Relationship").size
|
279
|
+
img_counter = 0
|
280
280
|
|
281
|
-
noko_html_source.
|
281
|
+
html = noko_html_source.to_xml
|
282
|
+
html.scan(/<img.*?>|<a.*?\/a>/).each_with_index do |link,i|
|
282
283
|
new_relation = relations_root.css("Relationship").last.clone
|
283
|
-
|
284
|
-
|
285
|
-
|
284
|
+
|
285
|
+
case link
|
286
|
+
when /^<a/
|
287
|
+
a_href = link.match(/href="(.*?)"/)[1]
|
288
|
+
new_relation["Id"] = "rId#{i + 1 + relations_size}"
|
289
|
+
new_relation["Type"] = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"
|
290
|
+
new_relation["TargetMode"] = "External"
|
291
|
+
new_relation["Target"] = a_href
|
292
|
+
when /^<img/
|
293
|
+
img_counter += 1
|
294
|
+
img_src = link.match(/src="(.*?)"/)[1]
|
295
|
+
new_relation["Id"] = "rId#{i + 1 + relations_size}"
|
296
|
+
new_relation["Type"] = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
|
297
|
+
new_relation["Target"] = "media/image#{img_counter}#{File.extname(img_src)}"
|
298
|
+
new_relation.remove_attribute("TargetMode") if new_relation["TargetMode"]
|
299
|
+
end
|
286
300
|
relations_root.add_child new_relation
|
287
301
|
end
|
302
|
+
|
288
303
|
rel_doc.to_xml
|
289
304
|
end
|
290
305
|
|
@@ -292,8 +307,9 @@ module Avv2word
|
|
292
307
|
stylesheet = xslt(stylesheet_path: stylesheet_path)
|
293
308
|
content = stylesheet.apply_to(source)
|
294
309
|
content.gsub!(/\s*xmlns:(\w+)="(.*?)\s*"/, '') if remove_ns
|
295
|
-
|
296
|
-
|
310
|
+
|
311
|
+
if ( file =~ /document\.xml\.rels/ ) && (( source.css("a").size > 0 ) || ( source.css("img").size > 0 ))
|
312
|
+
content = inject_relations(content, source)
|
297
313
|
elsif file =~ /header/i
|
298
314
|
@replaceable_files["word/_rels/header.xml.rels"] = %(<?xml version="1.0" encoding="UTF-8"?>\n<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">\n</Relationships>)
|
299
315
|
source.css("img").each_with_index do |noko_img,i|
|
Binary file
|
data/lib/avv2word/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avv2word
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marián Bilas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|