html2doc 1.10.2 → 1.10.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8c443b99cbd047a0b18d7533d67d0c0b2aef65b46454dc4bf144aeb45bd8c05
4
- data.tar.gz: bdd4cef5357c4003f4091bd4a78219439d4c2b56c4814b8cd2f46ad4ac9d08c7
3
+ metadata.gz: 02c33f471d8fd4b7131ea9ff5ace1d7313b7faad39c896d532d8d4a911f35600
4
+ data.tar.gz: 587092246ccfb67e3e2e76edae52ed6dfbfbb5b0fc376fcf5c740b166dee5ee6
5
5
  SHA512:
6
- metadata.gz: 54773965e4c77880a525bbe9b59e45472b3f9b745048a289848d170240b6ebdd1e72f201eba8f55739e2586d30400b3deea71b58dcc0da2ef6b705633497cc6a
7
- data.tar.gz: 45139d8ed49d211ca64f368cd7a3207a6554f72375c9861882a09d4f291cc77decebe9fc9078bbb4615096f394eac6a9f69b1f4f41c4f9221c8423110e619107
6
+ metadata.gz: 42674daf1d61fd2e33322cb7a7639518c2bdec3f0ec32968ba30bcfbe9664e91d723677057e12d1e7a3fb0ebaaaa8dab5bd82d0f131083af4095ee984899c9b2
7
+ data.tar.gz: 0f0c3880c7ce1df88157a2acefdee22d5d21b51d5ea1a178396844ba6ee0a1957727e62c27d2acff9b4c60f64023b51497a3a6b291c712503188769579ea70b7
data/lib/html2doc/mime.rb CHANGED
@@ -42,16 +42,24 @@ class Html2Doc
42
42
 
43
43
  def mime_type(item)
44
44
  abs_path = File.absolute_path(item)
45
+ type = mime_type1(abs_path)
46
+ type ||= 'text/plain; charset="utf-8"'
47
+ type = %(#{type}; charset="utf-8") if /^text/.match?(type)
48
+ type
49
+ end
50
+
51
+ # Marcel sometimes fails to detect XML files and returns application/octet-stream
52
+ # Override for .xml and .html files when detection fails
53
+ def mime_type1(abs_path)
45
54
  type = Marcel::MimeType.for(Pathname.new(abs_path))
46
-
47
- # Marcel sometimes fails to detect XML files and returns application/octet-stream
48
- # Override for .xml files when detection fails
49
- if type == "application/octet-stream" && File.extname(abs_path).downcase == ".xml"
50
- type = "application/xml"
55
+ if type == "application/octet-stream"
56
+ case File.extname(abs_path).downcase
57
+ when ".xml"
58
+ type = "application/xml"
59
+ when ".html", ".htm"
60
+ type = "text/html"
61
+ end
51
62
  end
52
-
53
- type ||= 'text/plain; charset="utf-8"'
54
- type = %(#{type} charset="utf-8") if /^text/.match?(type)
55
63
  type
56
64
  end
57
65
 
@@ -67,6 +75,7 @@ class Html2Doc
67
75
  Dir.foreach(dir) do |item|
68
76
  next if item == "." || item == ".." || /^\./.match(item) ||
69
77
  item == "filelist.xml"
78
+
70
79
  mhtml += mime_attachment(boundary, "#{filename}.htm", item, dir)
71
80
  end
72
81
  mhtml += "--#{boundary}--"
@@ -1,3 +1,3 @@
1
1
  class Html2Doc
2
- VERSION = "1.10.2".freeze
2
+ VERSION = "1.10.3".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html2doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.2
4
+ version: 1.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.