#!/bin/sh
#
# It is important that this program returns the correct exit code: return 0 if your filter handles the input, return 1
# if the standard lesspipe/lessfile filter should handle the input.

case "$1" in
    *.md)
        if which pandoc &> /dev/null; then
            pandoc -s -f markdown_github -t man "$1" | man -l -
        else
            exit 1
        fi
        ;;
    *.doc)
        if which antiword &> /dev/null; then
            antiword -a a4 -m utf-8 "$1"
        else
            exit 1
        fi
        ;;
    *.xml)
        # No further filtering
        exit 0
	;;
    *)
        # We don't handle this format.
        exit 1
esac

# No further processing by lesspipe necessary
exit 0
