summaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
authorReuben Thomas <rrt@sc3d.org>2022-09-13 22:36:35 +0100
committerGitHub <noreply@github.com>2022-09-13 23:36:35 +0200
commit1bba6552a54e2e42845743fcaa668f62cee19361 (patch)
treec74596bd2bbbc7cc2f74152b5e8121e97202a86d /external
parentca56bf26961a04e53c7691f4f15a1ffe1d222fec (diff)
downloadpygments-git-1bba6552a54e2e42845743fcaa668f62cee19361.tar.gz
autopygmentize: support more file types (#2219)
Includes new languages and new compression types. Also, check that the decompression program exists before trying to use it.
Diffstat (limited to 'external')
-rwxr-xr-xexternal/autopygmentize54
1 files changed, 46 insertions, 8 deletions
diff --git a/external/autopygmentize b/external/autopygmentize
index 3a4aed7f..85d23668 100755
--- a/external/autopygmentize
+++ b/external/autopygmentize
@@ -23,37 +23,60 @@ case $(file --mime-type --uncompress $file_common_opts "$file") in
text/x-awk) lexer=awk;;
text/x-c) lexer=c;;
text/x-c++) lexer=cpp;;
+ text/x-clojure) lexer=clojure;;
text/x-crystal) lexer=crystal;;
text/x-diff) lexer=diff;;
+ text/x-execline) lexer=execline;;
+ text/x-forth) lexer=forth;;
text/x-fortran) lexer=fortran;;
text/x-gawk) lexer=gawk;;
text/x-java) lexer=java;;
text/x-lisp) lexer=common-lisp;;
- text/x-lua) lexer=lua;;
+ text/x-lua|text/x-luatex) lexer=lua;;
text/x-makefile) lexer=make;;
text/x-msdos-batch) lexer=bat;;
text/x-nawk) lexer=nawk;;
+ text/x-objective-c) lexer=objective-c;;
text/x-pascal) lexer=pascal;;
text/x-perl) lexer=perl;;
text/x-php) lexer=php;;
text/x-po) lexer=po;;
text/x-python) lexer=python;;
text/x-ruby) lexer=ruby;;
+ text/x-script.python) lexer=python;;
text/x-shellscript) lexer=sh;;
text/x-tcl) lexer=tcl;;
text/x-tex|text/x-texinfo) lexer=latex;; # FIXME: texinfo really needs its own lexer
+ text/xml) lexer=xml;;
+ text/vnd.graphviz) lexer=graphviz;;
- # Types that file outputs which pygmentize didn't support as of file 5.20, pygments 2.0
+ # Types that file outputs which pygmentize didn't support as of file 5.41, pygments 2.11.2
+ # text/binary
# text/calendar
- # text/inf
# text/PGP
+ # text/prs.lines.tag
# text/rtf
+ # text/spreadsheet
# text/texmacs
- # text/vnd.graphviz
+ # text/vcard
+ # text/vnd.sosi
+ # text/x-Algol68
# text/x-bcpl
+ # text/x-dmtf-mif
+ # text/x-gimp-curve
+ # text/x-gimp-ggr
+ # text/x-gimp-gpl
# text/x-info
+ # text/x-installshield-lid
# text/x-m4
+ # text/x-modulefile
+ # text/x-ms-adm
+ # text/x-ms-cpx
+ # text/x-ms-regedirt
+ # text/x-ms-tag
+ # text/x-systemtap
# text/x-vcard
+ # text/x-wine-extension-reg
# text/x-xmcd
text/plain) # special filenames. TODO: insert more
@@ -67,12 +90,27 @@ case $(file --mime-type --uncompress $file_common_opts "$file") in
esac
# Find a concatenator for compressed files
-concat=cat
+concat=
+concat_opts=
case $(file $file_common_opts --mime-type "$file") in
- application/gzip) concat=zcat;;
- application/x-bzip2) concat=bzcat;;
- application/x-xz) concat=xzcat;;
+ # TODO: add support
+ # application/x-rzip (does not decompress to stdout)
+ # application/x-dzip (Windows only)
+ application/gzip|application/x-gzip) concat=zcat;;
+ application/x-bzip) concat=bzip; concat_opts=-dc;;
+ application/x-bzip2) concat=bzcat;;
+ application/x-lz4) concat=lz4; concat_opts=-dc;;
+ application/x-lzh-compressed) concat=p7zip; concat_opts=-dc;;
+ application/x-lzma) concat=lzcat;;
+ application/x-lzip) concat=lzip; concat_opts=-dc;;
+ application/x-xz) concat=xzcat;;
+ application/x-zoo) concat=zoo; concat_opts=fu;;
esac
+# If concat is unset or doesn't exist, use cat instead
+if [[ "$concat" == "" ]] || ! command -v "$concat"; then
+ concat=cat
+ concat_opts=
+fi
# Find a suitable reader, preceded by a hex dump for binary files,
# or fmt for text with very long lines