markdown.filter - tgtimes - The Gopher Times HTML git clone git://bitreich.org/tgtimes git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/tgtimes DIR Log DIR Files DIR Refs DIR Tags DIR README --- markdown.filter (1194B) --- 1 #!/bin/sh 2 # 3 # A simple markdown filter for u2ps formatting. 4 # 5 6 reset="$(echo -ne "\033[0m")" 7 italicformat="$(echo -ne "\033[3m")" 8 italicreset="$(echo -ne "\033[23m")" 9 boldformat="$(echo -ne "\033[1m")" 10 boldreset="$(echo -ne "\033[22m")" 11 underlineformat="$(echo -ne "\033[4m")" 12 underlinereset="$(echo -ne "\033[0m")" 13 reverseformat="$(echo -ne "\033[7m")" 14 reversereset="$(echo -ne "\033[27m")" 15 16 redcolor="$(tput setaf 1)" 17 greencolor="$(tput setaf 2)" 18 yellowcolor="$(tput setaf 3)" 19 bluecolor="$(tput setaf 4)" 20 purplecolor="$(tput setaf 5)" 21 cyancolor="$(tput setaf 6)" 22 whitecolor="$(tput setaf 7)" 23 darkgreycolor="$(tput setaf 8)" 24 brightredcolor="$(tput setaf 9)" 25 brightgreencolor="$(tput setaf 10)" 26 brightyellowcolor="$(tput setaf 11)" 27 brightbluecolor="$(tput setaf 12)" 28 brightpurplecolor="$(tput setaf 13)" 29 brightcyancolor="$(tput setaf 14)" 30 brightwhitecolor="$(tput setaf 14)" 31 32 while IFS= read -r line; 33 do 34 case "${line}" in 35 "## "*) 36 nline="$(printf "%s\n" "${line}" \ 37 | sed 's,^## ,,')" 38 printf "${boldformat}${underlineformat}%s${underlinereset}${boldreset} \n" \ 39 "${nline}" 40 ;; 41 " "*) 42 printf "${redcolor} %s${reset}\n" "${line}" 43 ;; 44 *) 45 printf "%s\n" "${line}" 46 ;; 47 esac 48 done 49