html2doc 1.10.2 → 1.10.4

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: 152467633084047452eb3055fb70033671821c5ba0b9918b9eff4a19373f8aea
4
+ data.tar.gz: 283ec00b5bb8660322c1cd0d55aa0f63bad3d4bbde9a1b23619d466ff681ae6f
5
5
  SHA512:
6
- metadata.gz: 54773965e4c77880a525bbe9b59e45472b3f9b745048a289848d170240b6ebdd1e72f201eba8f55739e2586d30400b3deea71b58dcc0da2ef6b705633497cc6a
7
- data.tar.gz: 45139d8ed49d211ca64f368cd7a3207a6554f72375c9861882a09d4f291cc77decebe9fc9078bbb4615096f394eac6a9f69b1f4f41c4f9221c8423110e619107
6
+ metadata.gz: 73004619c0d6f067037b411721fe580129a8a9ba781df3a180764b8283ab931ab8e82620605aeccffe9605ea9cee08b96caa9554fb176bbbd4adbd22339eaa78
7
+ data.tar.gz: a5fa1f0947456b12d2fa902a3beeddb05397b9d7f816ceb18214345b3c06364def154387eedf0878771ee7ef5dfde46b69a0f4faf4bbc1c10c1b7816503391f7
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.4".freeze
3
3
  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: 1.10.2
4
+ version: 1.10.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: 2026-02-16 00:00:00.000000000 Z
11
+ date: 2026-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64