Skip to content

astextplain: use mimetype to decide helper #624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions git-extra/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pkgbase="mingw-w64-${_realname}"
pkgname=($_realname
"${MINGW_PACKAGE_PREFIX}-${_realname}")
_ver_base=1.1
pkgver=1.1.657.d7f05a9c2
pkgver=1.1.659.e3eddae38
pkgrel=1
pkgdesc="Git for Windows extra files"
arch=('any')
Expand Down Expand Up @@ -79,7 +79,7 @@ sha256sums=('8ed76d1cb069ac8568f21c431f5e23caebea502d932ab4cdff71396f4f0d5b72'
'dcbd1b981d5b899afe30151a5f5a27ea52025ff1335f131af1b5891f62ddd55b'
'683ab066be19cb4defec470ebd53f165ca5dbf761fd40c13aee8abe31ba42803'
'1cf2c13fb97c51375a76ed479362c3cbcdb51ab4d3a745e8d2c3a780badd8d46'
'201fc40c1aadadceccc617511a4add05536b3638bff34456cc334e3b21c130e7'
'2ad7292f8ea4aa7d027221bff2a987ad8e7c72a6866a5f14ea67f6187e850244'
'180e05c1b8afa34d59cb2f6635bc75fece10474f37e164ea5916a6b3b56e20dd'
'22f41610dea842890955032af30efdb60e80f310e95a04e57ab36b10e0376923'
'38c0cf57e03d275cdd42984f102bee8352fac672f875ab23c46b9625eefc49f3'
Expand Down
21 changes: 7 additions & 14 deletions git-extra/astextplain
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,21 @@ if test "$#" != 1 ; then
fi

# XXX output encoding (UTF-8) hardcoded
case "$1" in
*.ods | *.ODS | *.odf |*.ODF | *.odt | *.ODT)
case "$(file --brief --mime-type "$1")" in
application/vnd.oasis.opendocument.spreadsheet | application/vnd.oasis.opendocument.formula | application/vnd.oasis.opendocument.text)
odt2txt "$1" || cat "$1"
;;
*.doc | *.DOC | *.dot | *.DOT)
case "$(file --brief --mime-type "$1")" in
application/msword)
out=$(antiword -m UTF-8 "$1") && sed "s/\^M$//" <<<$out || cat "$1"
;;
*)
cat "$1"
;;
esac
application/msword)
out=$(antiword -m UTF-8 "$1") && sed "s/\^M$//" <<<$out || cat "$1"
;;
*.docx | *.DOCX | *.dotx | *.DOTX | *.docm | *.DOCM | *.dotm | *.DOTM)
application/vnd.openxmlformats-officedocument.wordprocessingml.* | application/vnd.ms-word.*.macroenabled.12)
docx2txt.pl "$1" - || cat "$1"
;;
*.pdf | *.PDF)
application/pdf)
out=$(pdftotext -q -layout -enc UTF-8 "$1" -) && sed "s/(\^M$)|(^\^L)//" <<<$out || cat "$1"
;;
# TODO add rtf support
*.rtf | *.RTF)
application/rtf | text/rtf)
cat "$1"
;;
*)
Expand Down