html2doc 0.8.3 → 0.8.4

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: c7d587c237cbfcaa7fbc1565fedfb3ef586ea7ce1105e79207130a3c6bffdbdf
4
- data.tar.gz: 0f4c63e1ee7c47e4327d813fb524351914db8fb5e27dedf76a8082b0f7cd1246
3
+ metadata.gz: ebe0e5db8814308a2e3d8ade848d2a7a0323d2caf2e87f471d333edcf271ab8b
4
+ data.tar.gz: 6a0b6944d46e3a05aece3a52f445d00425ac78fa6d4e66a08adc9697618a7df4
5
5
  SHA512:
6
- metadata.gz: bb584350898d40679e2e0eb5eb42d993b6407a2a52588e2e54bf59291b6987c4517689b5ec83b5c1620f6e09c5a7698ea51bf924b75de4e769b9f2789e253451
7
- data.tar.gz: 25caa1a0e9aa35d5c776f21328cadb3d0efa9f9950efd7a14caed976e3f1bfe6b31cfbaf3ae541dac143c25fb2fd70ac5ec59d4d8c94eb86cd42b17301e8d657
6
+ metadata.gz: 78b8a0b62a7420145b032a40004dd97cb05851d700c182ca9fc6bc94884c1ae4f5eb917fae3e0084ef189db3d41d1338afe6a6dc6415e8445848e72db7642b85
7
+ data.tar.gz: 5245dc6ae3dbb947f47b1fb21f775b6021385bba13449014fd5dde1d55cd572e52abc2019b7430ad42ead2f55c5ccb165c495d359ed6d9bb8010875b14988322
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- html2doc (0.8.2)
4
+ html2doc (0.8.4)
5
5
  asciimath
6
6
  htmlentities (~> 4.3.4)
7
7
  image_size
@@ -14,7 +14,7 @@ PATH
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
- asciimath (1.0.4)
17
+ asciimath (1.0.6)
18
18
  ast (2.4.0)
19
19
  byebug (9.1.0)
20
20
  coderay (1.1.2)
@@ -48,18 +48,18 @@ GEM
48
48
  ruby_dep (~> 1.2)
49
49
  lumberjack (1.0.13)
50
50
  method_source (0.9.0)
51
- mime-types (3.1)
51
+ mime-types (3.2.2)
52
52
  mime-types-data (~> 3.2015)
53
- mime-types-data (3.2016.0521)
53
+ mime-types-data (3.2018.0812)
54
54
  mini_portile2 (2.3.0)
55
55
  nenv (0.3.0)
56
- nokogiri (1.8.4)
56
+ nokogiri (1.8.5)
57
57
  mini_portile2 (~> 2.3.0)
58
58
  notiffany (0.1.1)
59
59
  nenv (~> 0.1)
60
60
  shellany (~> 0.0)
61
61
  parallel (1.12.1)
62
- parser (2.5.1.0)
62
+ parser (2.5.1.2)
63
63
  ast (~> 2.4.0)
64
64
  powerpack (0.1.2)
65
65
  pry (0.11.3)
@@ -70,30 +70,30 @@ GEM
70
70
  rb-fsevent (0.10.3)
71
71
  rb-inotify (0.9.10)
72
72
  ffi (>= 0.5.0, < 2)
73
- rspec (3.7.0)
74
- rspec-core (~> 3.7.0)
75
- rspec-expectations (~> 3.7.0)
76
- rspec-mocks (~> 3.7.0)
77
- rspec-core (3.7.1)
78
- rspec-support (~> 3.7.0)
79
- rspec-expectations (3.7.0)
73
+ rspec (3.8.0)
74
+ rspec-core (~> 3.8.0)
75
+ rspec-expectations (~> 3.8.0)
76
+ rspec-mocks (~> 3.8.0)
77
+ rspec-core (3.8.0)
78
+ rspec-support (~> 3.8.0)
79
+ rspec-expectations (3.8.1)
80
80
  diff-lcs (>= 1.2.0, < 2.0)
81
- rspec-support (~> 3.7.0)
81
+ rspec-support (~> 3.8.0)
82
82
  rspec-match_fuzzy (0.1.3)
83
83
  rspec (>= 3.2)
84
- rspec-mocks (3.7.0)
84
+ rspec-mocks (3.8.0)
85
85
  diff-lcs (>= 1.2.0, < 2.0)
86
- rspec-support (~> 3.7.0)
87
- rspec-support (3.7.1)
88
- rubocop (0.58.0)
86
+ rspec-support (~> 3.8.0)
87
+ rspec-support (3.8.0)
88
+ rubocop (0.59.2)
89
89
  jaro_winkler (~> 1.5.1)
90
90
  parallel (~> 1.10)
91
- parser (>= 2.5)
91
+ parser (>= 2.5, != 2.5.1.1)
92
92
  powerpack (~> 0.1)
93
93
  rainbow (>= 2.2.2, < 4.0)
94
94
  ruby-progressbar (~> 1.7)
95
95
  unicode-display_width (~> 1.0, >= 1.0.1)
96
- ruby-progressbar (1.9.0)
96
+ ruby-progressbar (1.10.0)
97
97
  ruby-xslt (0.9.10)
98
98
  ruby_dep (1.5.0)
99
99
  shellany (0.0.1)
data/README.adoc CHANGED
@@ -21,13 +21,13 @@ The gem currently does the following:
21
21
  * Convert any AsciiMath and MathML to Word's native mathematical formatting language, OOXML. Word supports copy-pasting MathML into Word and converting it into OOXML; however the conversion is not infallible (we have found problems with `\sum`: Word claims parameters were missing, and inserting dotted squares to indicate as much), and you may need to post-edit the OOXML.
22
22
  ** The gem does attempt to repair the MathML input, to bring it in line with Word's OOXML's expectations. If you find any issues with AsciiMath or MathML input, please raise an issue.
23
23
  * Identify any footnotes in the document (defined as hyperlinks with attributes `class = "Footnote"` or `epub:type = "footnote"`), and render them as Microsoft Word footnotes.
24
- * Resize any images in the HTML file to fit within the maximum page size. (Word will otherwise crash on reading the document.)
24
+ * Resize any local images in the HTML file to fit within the maximum page size. (Word will otherwise crash on reading the document.)
25
25
  * Optionally apply list styles with predefined bullet and numbering from a Word CSS to the unordered and ordered lists in the document, restarting numbering for each ordered list.
26
26
  * Convert any internal `@id` anchors to `a@name` anchors; Word only hyperlinks to the latter.
27
27
  * Generate a filelist.xml listing of all files to be bundled into the Word document.
28
28
  * Assign the class `MsoNormal` to any paragraphs that do not have a class, so that they can be treated as Normal Style when editing the Word document.
29
29
  * Inject Microsoft Word-specific CSS into the HTML document. If a CSS file is not supplied, the CSS file used is at `lib/html2doc/wordstyle.css` is used by default. Microsoft Word HTML has particular requirements from its CSS, and you should review the sample CSS before replacing it with your own. (This generic CSS can be overridden by CSS already in the HTML document, since the generic CSS is injected at the top of the document.)
30
- * Bundle up the images, the HTML file of the document proper, and the `header.html` file representing header/footer information, into a MIME file, and save that file to disk (so that Microsoft Word can deal with it as a Word file.)
30
+ * Bundle up the local images, the HTML file of the document proper, and the `header.html` file representing header/footer information, into a MIME file, and save that file to disk (so that Microsoft Word can deal with it as a Word file.)
31
31
 
32
32
  For a representative generator of HTML that uses this gem in postprocessing, see https://github.com/riboseinc/asciidoctor-iso
33
33
 
@@ -55,7 +55,7 @@ result:: is the Html document to be converted into Word, as a string.
55
55
  filename:: is the name the document is to be saved as, without a file suffix
56
56
  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.
57
57
  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/riboseinc/asciidoctor-iso/blob/master/lib/asciidoctor/iso/word/header.html
58
- 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.)
58
+ 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.)
59
59
  asciimathdelims:: are the AsciiMath delimiters used in the text (an array of an opening and a closing delimiter). If none are provided, no AsciiMath conversion is attempted.
60
60
  liststyles:: a hash of list style labels in Word CSS, which are used to define the behaviour of list item labels (e.g. _i)_ vs _i._). The gem recognises the hash keys `ul`, `ol`. So if the appearance of an ordered list's item labels in the supplied stylesheet is governed by style `@list l1` (e.g. `@list l1:level1 {mso-level-text:"%1\)";}` appears in the stylesheet), call the method with `liststyles:{ol: "l1"}`.
61
61
 
data/lib/html2doc/base.rb CHANGED
@@ -4,6 +4,7 @@ require "htmlentities"
4
4
  require "nokogiri"
5
5
  require "xml/xslt"
6
6
  require "pp"
7
+ require "fileutils"
7
8
 
8
9
  module Html2Doc
9
10
  def self.process(result, hash)
@@ -37,9 +38,9 @@ module Html2Doc
37
38
  end
38
39
 
39
40
  def self.rm_temp_files(filename, dir, dir1)
40
- system "rm #{filename}.htm"
41
- system "rm -r #{dir1}/header.html"
42
- system "rm -r #{dir1}" unless dir
41
+ FileUtils.rm "#{filename}.htm"
42
+ FileUtils.rm_f "#{dir1}/header.html"
43
+ FileUtils.rm_r dir1 unless dir
43
44
  end
44
45
 
45
46
  def self.cleanup(docxml, hash)
data/lib/html2doc/mime.rb CHANGED
@@ -59,7 +59,7 @@ module Html2Doc
59
59
  File.open("#{filename}.doc", "w:UTF-8") { |f| f.write mhtml }
60
60
  end
61
61
 
62
- # max height for Word document is 400, max width is 680
62
+ # max width for Word document is 400, max height is 680
63
63
  def self.image_resize(i, maxheight, maxwidth)
64
64
  realSize = ImageSize.path(i["src"]).size
65
65
  s = [i["width"].to_i, i["height"].to_i]
@@ -81,7 +81,7 @@ module Html2Doc
81
81
  uuid = UUIDTools::UUID.random_create.to_s
82
82
  new_full_filename = File.join(dir, "#{uuid}.#{matched[:suffix]}")
83
83
  FileUtils.cp i["src"], new_full_filename
84
- i["width"], i["height"] = image_resize(i, 400, 680)
84
+ i["width"], i["height"] = image_resize(i, 680, 400)
85
85
  i["src"] = new_full_filename
86
86
  end
87
87
  docxml
@@ -1,3 +1,3 @@
1
1
  module Html2Doc
2
- VERSION = "0.8.3".freeze
2
+ VERSION = "0.8.4".freeze
3
3
  end
@@ -517,7 +517,7 @@ RSpec.describe Html2Doc do
517
517
  expect(testdoc).to match(%r{Content-Type: image/png})
518
518
  expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT)
519
519
  #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
520
- #{image_clean(word_body('<img src="test_files/cb7b0d19-891e-4634-815a-570d019d454c.png" width="412" height="400"></img>', '<div style="mso-element:footnote-list"/>'))}
520
+ #{image_clean(word_body('<img src="test_files/cb7b0d19-891e-4634-815a-570d019d454c.png" width="400" height="388"></img>', '<div style="mso-element:footnote-list"/>'))}
521
521
  #{image_clean(WORD_FTR3)}
522
522
  OUTPUT
523
523
  end
@@ -529,7 +529,7 @@ RSpec.describe Html2Doc do
529
529
  expect(testdoc).to match(%r{Content-Type: image/gif})
530
530
  expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT)
531
531
  #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
532
- #{image_clean(word_body('<img src="test_files/cb7b0d19-891e-4634-815a-570d019d454c.gif" width="680" height="202"></img>', '<div style="mso-element:footnote-list"/>'))}
532
+ #{image_clean(word_body('<img src="test_files/cb7b0d19-891e-4634-815a-570d019d454c.gif" width="400" height="118"></img>', '<div style="mso-element:footnote-list"/>'))}
533
533
  #{image_clean(WORD_FTR3).gsub(/image\.png/, "image.gif")}
534
534
  OUTPUT
535
535
  end
@@ -541,7 +541,7 @@ RSpec.describe Html2Doc do
541
541
  expect(testdoc).to match(%r{Content-Type: image/jpeg})
542
542
  expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT)
543
543
  #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
544
- #{image_clean(word_body('<img src="test_files/cb7b0d19-891e-4634-815a-570d019d454c.jpg" width="122" height="400"></img>', '<div style="mso-element:footnote-list"/>'))}
544
+ #{image_clean(word_body('<img src="test_files/cb7b0d19-891e-4634-815a-570d019d454c.jpg" width="208" height="680"></img>', '<div style="mso-element:footnote-list"/>'))}
545
545
  #{image_clean(WORD_FTR3).gsub(/image\.png/, "image.jpg")}
546
546
  OUTPUT
547
547
  end
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: 0.8.3
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-26 00:00:00.000000000 Z
11
+ date: 2018-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities