From 7ee6c3a206d202d97c3aad98175e49787f1e40d1 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 6 Feb 2024 00:10:44 -0600 Subject: rename st.sh to html.st.sh --- html.st.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 html.st.sh (limited to 'html.st.sh') diff --git a/html.st.sh b/html.st.sh new file mode 100644 index 0000000..ab4ab72 --- /dev/null +++ b/html.st.sh @@ -0,0 +1,41 @@ +# -*- 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#[ ]([.!-;:,.?])$#'"$tag"'>\1#' -e t \ + -e '$s,$,'"$tag"'>,' +} + +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
+}
--
cgit 1.4.1-21-gabe81