From: Pooya Moradi Date: Sun, 15 May 2022 08:03:00 +0000 (+0430) Subject: Add support for bat for markdown rendering X-Git-Tag: v0.2.0.0~66 X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/xdg-ninja.git/commitdiff_plain/77a170c54a920a715ab92957be308814a662d8ae?ds=inline Add support for bat for markdown rendering --- diff --git a/README.md b/README.md index d4e3349..d5cdc9a 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ This will run every test in the default configuration. ### Optional -- [glow](https://repology.org/project/glow/packages) for rendering markdown in the terminal +- [glow](https://repology.org/project/glow/packages) or [bat](https://repology.org/project/bat-cat/packages) for rendering markdown in the terminal - [cabal](https://repology.org/project/cabal/packages) for compiling the helper program for creating configurations ## Configuration diff --git a/xdg-ninja.sh b/xdg-ninja.sh index e16bd71..c7b4ab2 100755 --- a/xdg-ninja.sh +++ b/xdg-ninja.sh @@ -1,12 +1,16 @@ #!/usr/bin/env sh # shellcheck disable=SC2016 -USE_GLOW=true -if ! command -v glow >/dev/null 2>/dev/null; then - printf "Glow not found, markdown rendering not available.\n" +USE_GLOW=false +USE_BAT=false +if command -v glow >/dev/null 2>/dev/null; then + USE_GLOW=true +elif command -v bat >/dev/null 2>/dev/null; then + USE_BAT=true +else + printf "Glow or bat not found, markdown rendering not available.\n" printf "Output will be raw markdown and might look weird.\n" - printf "Install glow for easier reading & copy-paste.\n" - USE_GLOW=false + printf "Install glow or bat for easier reading & copy-paste.\n" fi unalias -a @@ -123,6 +127,8 @@ log() { HELP) if $USE_GLOW; then printf "%s" "$HELP" | glow - + elif $USE_BAT; then + printf "%s" "$HELP" | bat -pp -f --language markdown else printf "%s" "$HELP" fi