Files
q-tools/reporting/md-color
2016-02-14 18:58:14 +02:00

57 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
function helpexit() {
echo "Colorify a markdown document"
echo "Give filename(s) as the argument"
echo " Depends on highbeam "
exit
}
[[ -z "$1" ]] && helpexit
[[ "$1" = "-h" ]] && helpexit
# * bullets
# 1. ordered list
# ## Headers
# code block
# code inline
# [links](URL)
# *bold* & **bold**
# _bold_
# <> tags
# [ ] check list (unofficial)
# [x] check list (unofficial)
# Color codes
export HB_RULES='"\[[^]]\+\]([^)]\+)" "$U$B" \
"^\s*\*.*" "$y" \
"^[[:space:]]*[0-9]\+\..*" "$y" \
"^#.*" "$U$W" \
"^\s\s\s\s[^\*0-9].*" "$c" \
"\`[^[[:space:]]]*[^\`]\+\`" "$c" \
"\*\{1,2\}[^[[:space:]]]*[^\*]\+\*\{1,2\}" "$W" \
"_[^[[:space:]]]*[^_]\+_" "$W" \
"<[^>]\+>" "$K" \
"^\s*\[\s]\s.*" "$y" \
"^\s*\[x]\s.*" "$Y" \
"\${R}.*" "$R" \
"\${G}.*" "$G" \
"\${B}.*" "$B" \
"\${C}.*" "$C" \
"\${M}.*" "$M" \
"\${Y}.*" "$Y" \
"\${r}.*" "$r" \
"\${g}.*" "$g" \
"\${b}.*" "$b" \
"\${c}.*" "$c" \
"\${m}.*" "$m" \
"\${y}.*" "$y" \
"\${k}.*" "$k" \
"\${K}.*" "$K" \
"\${w}.*" "$w" \
"\${W}.*" "$W" \
"\${U}.*" "$U" \
"\${Z}.*" "$Z" \
'
cat "$@" | highbeam -c | sed 's,\${[RGBCMYrgbcmykKwWU]},,g'