Files
q-tools/reporting/md-color
ville rantanen 3516fed53c coloring update
2015-06-15 10:48:23 +03:00

52 lines
991 B
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
# Color codes
export HB_RULES='"^\s*\*.*" "$y" \
"^[[:space:]]*[0-9]\+\..*" "$y" \
"^#.*" "$U$W" \
"^\s\s\s\s[^\*0-9].*" "$c" \
"\`[^[[:space:]]]*[^\`]\+\`" "$c" \
"\[[^]]\+\]([^)]\+)" "$B$U" \
"\*\{1,2\}[^[[:space:]]]*[^\*]\+\*\{1,2\}" "$W" \
"_[^[[:space:]]]*[^_]\+_" "$W" \
"<[^>]\+>" "$K" \
"\${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" \
'
cat "$@" | highbeam | sed 's,\${[RGBCMYrgbcmykKwWU]},,g'