# -*- sh -*- html_fix() { sed -E \ -e 's#([^\\]|^)&#\1\&#g' \ -e 's#([^\\]|^)<#\1\<#g' \ -e 's#([^\\]|^)>#\1\>#g' \ -e 's#\\([&<>])#\1#g' } html_el(){ # el TAG [ATTRS...] [TEXT...] [< INPUT] tag="$1"; attrs= ; text= shift for arg do case "$arg" in (*=*) attrs="$attrs ${arg%%=*}=${arg#*=}"; shift ;; (*) break ;; esac done printf '<%s%s>%s' "$tag" "$attrs" handle_input "$@" | sed -E \ -e '$s#[ ]([.!-;:,.?])$#\1#' -e t \ -e '$s,$,,' } for el in h1 h2 h3 p a blockquote ul ol li em strong b i dl dt dd do alias $el="html_el $el" done alias @=html_el code() { in="$(handle_input "$@")" if test $? -ne 0 then html_el code "$@" # runs thru input twice, meh else echo "
$in
" fi } nl()(echo)