diff options
| author | Anton Bobov <abobov@gmail.com> | 2020-11-07 23:05:23 +0500 |
|---|---|---|
| committer | Anton Bobov <abobov@gmail.com> | 2020-11-07 23:05:23 +0500 |
| commit | a8b19f5d7ec7e442f0a55a12f4afe6afbf32f006 (patch) | |
| tree | 9a646d8c7164cd08d8318df2cde2bca3e14d0bce /files/.lessfilter.sh | |
| parent | 574c00d98c952d1b3d0db1b50ed1bddc9a1fcecf (diff) | |
Add lessfilter ability to format XML with python, use python3 if available.
Diffstat (limited to 'files/.lessfilter.sh')
| -rwxr-xr-x | files/.lessfilter.sh | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/files/.lessfilter.sh b/files/.lessfilter.sh index 8c18600..e3c01d1 100755 --- a/files/.lessfilter.sh +++ b/files/.lessfilter.sh @@ -4,16 +4,22 @@ case $1 in *.xml) if [ -x "$(command -v xmlstarlet)" ]; then exec xmlstarlet fo "$1" + elif [ -x "$(command -v python3)" ] ; then + exec python3 -c 'import sys; import xml.dom.minidom as xml; sys.stdout.write(xml.parse(sys.argv[1]).toprettyxml())' "$1" + elif [ -x "$(command -v python)" ] ; then + exec python -c 'import sys; import xml.dom.minidom as xml; sys.stdout.write(xml.parse(sys.argv[1]).toprettyxml())' "$1" fi ;; *.json) if [ -x "$(command -v jq)" ]; then exec jq -C . "$1" + elif [ -x "$(command -v python3)" ] ; then + exec python3 -m json.tool "$1" elif [ -x "$(command -v python)" ] ; then exec python -m json.tool "$1" fi ;; - *.md) + *.md|*.html) if [ -x "$(command -v pandoc)" ]; then exec pandoc -t plain "$1" fi |
