@@ -185,21 +185,21 @@ func (args *Args) renderFile(name string) (image.Image, string, error) {
185
185
args .logger ("mime: %s" , typ )
186
186
var g func (io.Reader , string ) (image.Image , error )
187
187
var notStream bool
188
- switch {
188
+ switch ext := strings . ToLower ( strings . TrimPrefix ( filepath . Ext ( name ), "." )); {
189
189
case typ == "image/svg" :
190
190
g = args .renderResvg
191
- case typ == "text/plain" :
192
- g = args .renderMarkdown
193
191
case isImageBuiltin (typ ):
194
192
g = args .renderImage
193
+ case isLibreOffice (typ , ext ):
194
+ g , notStream = args .renderLibreOffice , true
195
195
case isVipsImage (typ ): // use vips
196
196
g = args .renderVips
197
+ case typ == "text/plain" :
198
+ g = args .renderMarkdown
197
199
case strings .HasPrefix (typ , "font/" ):
198
200
g = args .renderFont
199
201
case strings .HasPrefix (typ , "video/" ):
200
202
g , notStream = args .renderAstiav , true
201
- case isLibreOffice (typ ):
202
- g , notStream = args .renderLibreOffice , true
203
203
default :
204
204
return nil , "" , fmt .Errorf ("mime type %q not supported" , typ )
205
205
}
@@ -646,15 +646,16 @@ func isVipsImage(typ string) bool {
646
646
647
647
// isLibreOffice returns true if the mime type is supported by the `soffice`
648
648
// command.
649
- func isLibreOffice (typ string ) bool {
649
+ func isLibreOffice (typ , ext string ) bool {
650
650
switch {
651
651
case
652
652
strings .HasPrefix (typ , "application/vnd.openxmlformats-officedocument." ), // pptx, xlsx, ...
653
653
strings .HasPrefix (typ , "application/vnd.ms-" ), // ppt, xls, ...
654
654
strings .HasPrefix (typ , "application/vnd.oasis.opendocument." ), // otp, otp, odg, ...
655
655
typ == "text/rtf" ,
656
656
typ == "text/csv" ,
657
- typ == "text/tab-separated-values" :
657
+ typ == "text/tab-separated-values" ,
658
+ typ == "text/plain" && (ext == "csv" || ext == "tsv" ):
658
659
return true
659
660
}
660
661
return false
0 commit comments