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 +4 -4
- data/lib/html2doc/mime.rb +17 -8
- data/lib/html2doc/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 02c33f471d8fd4b7131ea9ff5ace1d7313b7faad39c896d532d8d4a911f35600
|
|
4
|
+
data.tar.gz: 587092246ccfb67e3e2e76edae52ed6dfbfbb5b0fc376fcf5c740b166dee5ee6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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}--"
|
data/lib/html2doc/version.rb
CHANGED