doronbehar / pistol

General purpose file previewer designed for Ranger, Lf to make scope.sh redundant

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pistol not print JSON data

RonanMacF opened this issue · comments

What is the thinking behind not print JSON data and instead displaying a message stating that it is JSON data?

That's a good question :) The issue is the mime type of a JSON file is application/json and not text/json or anything that would match text/*. See this table:

var internalWritersRegexMap = map[string] func(string, string) (func(w io.Writer) error, error) {
"text/*": NewChromaWriter,
"application/zip": NewArchiveLister,
"application/x-rar-compressed": NewArchiveLister,
"application/x-tar": NewArchiveLister,
"application/x-xz": NewArchiveLister,
"application/x-bzip2": NewArchiveLister,
"application/gzip": NewArchiveLister,
"application/x-lz4": NewArchiveLister,
"application/x-snappy-framed": NewArchiveLister,
"application/x-zstd": NewArchiveLister,
// TODO: Match brotli when libmagic supports it
}

Feel free @RonanMacF to try and a line there for application/json and use the NewChromaWriter as the key in that map.