#!/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 block # code inline # [links](URL) # *bold* & **bold** # _bold_ # <> tags # [ ] check list (unofficial) # [x] check list (unofficial) # $> $! unofficial colors for executable code blocks # Color codes export HB_RULES='"\[[^]]\+\]([^)]\+)" "$U$B" \ "^\s*\*" "$y" \ "^[[:space:]]*[0-9]\+\..*" "$y" \ "^#.*" "$U$W" \ "\`\`\`.*" "$c" \ "^\s\s\s\s[^\*0-9].*" "$c" \ "\`[^[[:space:]]]*[^\`]\+\`" "$c" \ "\*\{1,2\}[^[[:space:]]]*[^\*]\+\*\{1,2\}" "$W" \ "[[:space:]]_[^[[:space:]]]*[^_]\+_" "$W" \ "<[^>]\+>" "$K" \ "^\s*\[\s]\s.*" "$y" \ "^\s*\[x]\s.*" "$Y" \ "\$[>!].*\$[>!]" "$c" \ "\${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,\${[RGBCMYrgbcmykKwWUZ]},,g'