html2doc 1.1.4 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9ed3f5d01d7910a104f86dfe54090ffc3ddf56730f5885293801b3848b24735
4
- data.tar.gz: 98428b2016bba38f17cb66226e2fb8d96a28c6ad28bd47a3bc0b998ea1c81228
3
+ metadata.gz: 64cb262d3176610f0887cc69bab66fa2a3a7ca8445f8ad493d9d65c455a091d6
4
+ data.tar.gz: 468dc7a8fb687cdbf6db1497cf9d9b5e164687b7d460a5eac1fb983b4673672b
5
5
  SHA512:
6
- metadata.gz: ede857348aa47a2f09df5c0c1929056251729b358815130ed6c7823f14e9a49cbb1439d43eb45104cb6be2104f47b4dda15b156680dfefd687c4d6439e162c89
7
- data.tar.gz: 4027da3d313f7efb834efc96666d6aedfa509d3b2fc7335b367259833a0050e29b13da92e40514b2afee76b9f84420b81951d1fb9d577643a077643823dcf23c
6
+ metadata.gz: 2a47bbe5df7ae0767ad2f4ccf52c1f96b8e27fc32d08b3b7b25e5051a3d229b29b9852a51c052a701990f9be6dbf0efc97795ea0c0ff4b3745b63f5a0c7adb4f
7
+ data.tar.gz: c4c10a84141889d820fd8d2afc273122b28372794edd9fdb3e60aee28773350d3e545f2a3efb75c4d28eff350d367b020d01d6e5cc2874a957ca612124e78fd4
data/README.adoc CHANGED
@@ -58,11 +58,12 @@ There there are two other Microsoft Word vendors in the Ruby ecosystem.
58
58
  --
59
59
  require "html2doc"
60
60
 
61
- Html2Doc.process(result, filename: filename, stylesheet: stylesheet, header_filename: header_filename, dir: dir, asciimathdelims: asciimathdelims, liststyles: liststyles)
61
+ Html2Doc.process(result, filename: filename, imagedir: imagedir, stylesheet: stylesheet, header_filename: header_filename, dir: dir, asciimathdelims: asciimathdelims, liststyles: liststyles)
62
62
  --
63
63
 
64
64
  result:: is the Html document to be converted into Word, as a string.
65
65
  filename:: is the name the document is to be saved as, without a file suffix
66
+ imagedir:: base directory for local image file names in source XML
66
67
  stylesheet:: is the full path filename of the CSS stylesheet for Microsoft Word-specific styles. If this is not provided, the program will used the default stylesheet included in the gem, `lib/html2doc/wordstyle.css`. The stylsheet provided must match this stylesheet; you can obtain one by saving a Word document with your desired styles to HTML, and extracting the style definitions from the HTML document header.
67
68
  header_filename:: is the filename of the HTML document containing header and footer for the document, as well as footnote/endnote separators; if there is none, use nil. To generate your own such document, save a Word document with headers/footers and/or footnote/endnote separators as an HTML document; the `header.html` will be in the `{filename}.fld` folder generated along with the HTML. A sample file is available at https://github.com/metanorma/metanorma-iso/blob/master/lib/asciidoctor/iso/word/header.html
68
69
  dir:: is the folder that any ancillary files (images, headers, filelist) are to be saved to. If not provided, it will be created as `{filename}_files`. Anything in the directory will be attached to the Word document; so this folder should only contain the images that accompany the document. (If the images are elsewhere on the local drive, the gem will move them into the folder. External URL images are left alone, and are not downloaded.)
data/lib/html2doc/base.rb CHANGED
@@ -53,7 +53,7 @@ module Html2Doc
53
53
 
54
54
  def self.cleanup(docxml, hash)
55
55
  namespace(docxml.root)
56
- image_cleanup(docxml, hash[:dir1], File.dirname(hash[:filename]))
56
+ image_cleanup(docxml, hash[:dir1], hash[:imagedir])
57
57
  mathml_to_ooml(docxml)
58
58
  lists(docxml, hash[:liststyles])
59
59
  footnotes(docxml)
@@ -1,3 +1,3 @@
1
1
  module Html2Doc
2
- VERSION = "1.1.4".freeze
2
+ VERSION = "1.2.0".freeze
3
3
  end
@@ -565,7 +565,7 @@ RSpec.describe Html2Doc do
565
565
 
566
566
  it "resizes images for height, in a file in a subdirectory" do
567
567
  simple_body = '<img src="19160-6.png">'
568
- Html2Doc.process(html_input(simple_body), filename: "spec/test")
568
+ Html2Doc.process(html_input(simple_body), filename: "spec/test", imagedir: "spec")
569
569
  testdoc = File.read("spec/test.doc", encoding: "utf-8")
570
570
  expect(testdoc).to match(%r{Content-Type: image/png})
571
571
  expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT)
@@ -577,7 +577,7 @@ RSpec.describe Html2Doc do
577
577
 
578
578
  it "resizes images for width" do
579
579
  simple_body = '<img src="spec/19160-7.gif">'
580
- Html2Doc.process(html_input(simple_body), filename: "test")
580
+ Html2Doc.process(html_input(simple_body), filename: "test", imagedir: ".")
581
581
  testdoc = File.read("test.doc", encoding: "utf-8")
582
582
  expect(testdoc).to match(%r{Content-Type: image/gif})
583
583
  expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT)
@@ -589,7 +589,7 @@ RSpec.describe Html2Doc do
589
589
 
590
590
  it "resizes images for height" do
591
591
  simple_body = '<img src="spec/19160-8.jpg">'
592
- Html2Doc.process(html_input(simple_body), filename: "test")
592
+ Html2Doc.process(html_input(simple_body), filename: "test", imagedir: ".")
593
593
  testdoc = File.read("test.doc", encoding: "utf-8")
594
594
  expect(testdoc).to match(%r{Content-Type: image/jpeg})
595
595
  expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT)
@@ -642,7 +642,7 @@ RSpec.describe Html2Doc do
642
642
 
643
643
  it "does not move images if they are external URLs" do
644
644
  simple_body = '<img src="https://example.com/19160-6.png">'
645
- Html2Doc.process(html_input(simple_body), filename: "test")
645
+ Html2Doc.process(html_input(simple_body), filename: "test", imagedir: ".")
646
646
  testdoc = File.read("test.doc", encoding: "utf-8")
647
647
  expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT)
648
648
  #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
@@ -653,7 +653,7 @@ RSpec.describe Html2Doc do
653
653
 
654
654
  it "deals with absolute image locations" do
655
655
  simple_body = %{<img src="#{__dir__}/19160-6.png">}
656
- Html2Doc.process(html_input(simple_body), filename: "spec/test")
656
+ Html2Doc.process(html_input(simple_body), filename: "spec/test", imagedir: ".")
657
657
  testdoc = File.read("spec/test.doc", encoding: "utf-8")
658
658
  expect(testdoc).to match(%r{Content-Type: image/png})
659
659
  expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT)
@@ -836,7 +836,7 @@ RSpec.describe Html2Doc do
836
836
  it "test image base64 image encoding" do
837
837
  simple_body = '<img src="19160-6.png">'
838
838
  Html2Doc.process(html_input(simple_body),
839
- filename: "spec/test", debug: true)
839
+ filename: "spec/test", debug: true, imagedir: "spec")
840
840
  testdoc = File.read("spec/test.doc", encoding: "utf-8")
841
841
  base64_image = testdoc[/image\/png\n\n(.*?)\n\n----/m, 1].gsub!("\n", "")
842
842
  base64_image_basename = testdoc[%r{Content-ID: <([0-9a-z\-]+)\.png}m, 1]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html2doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.2.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: 2021-09-27 00:00:00.000000000 Z
11
+ date: 2021-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath