Skip to content

Commit

Permalink
Add support for bat for markdown rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
pvonmoradi authored and b3nj5m1n committed May 15, 2022
1 parent 49d3edc commit 77a170c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 11 additions & 5 deletions xdg-ninja.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 77a170c

Please sign in to comment.