From 128d8c4bcddf9570da5785ff171e70c97c1a54b5 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 22 Jan 2024 09:44:38 -0600 Subject: Update --- README.md | 5 +++++ et | 21 ++++++++++++++------- etlib.sh | 3 ++- test.et | 1 + 4 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..010e4a9 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# et --- excited text + +not-quite-html that generates a shell script with groff-sorta input + +idk maybe i should call this frankentext diff --git a/et b/et index 06cbf4c..0e03aa3 100755 --- a/et +++ b/et @@ -3,15 +3,22 @@ # usage: et | sh BEGIN { - xend = xend ? xend : "...xend..." - dend = dend ? dend : "...dend..." + xend = xend ? xend : "...end...shexpand..." + dend = dend ? dend : "...end...document..." # We shell out to sed for this because awk doesn't do capture groups ;-; - shellfix = "sed -E -e 's/`/\\\\`/g' " \ - "-e 's/(^|[^\\$])\\$([^\\$]|$)/\\1\\\\$\\2/g' " \ - "-e 's/(^|[^\\$])\\$(\\$+)([^\\$]|$)/\\1\\2\\3/g'" + shellfix = "sed -E" \ + " -e 's/`/\\\\`/g'" \ + " -e 's/(^|[^\\$])\\$([^\\$]|$)/\\1\\\\$\\2/g'" \ + " -e 's/(^|[^\\$])\\$(\\$+)([^\\$]|$)/\\1\\2\\3/g'" + htmlfix = "sed -E" \ + " -e 's#([^\\\\]|^)&#\\1\\&#g;'" \ + " -e 's#([^\\\\]|^)<#\\1\\<#g;'" \ + " -e 's#([^\\\\]|^)>#\\1\\>#g;'" \ + " -e 's#\\\\([&<>])#\\1#g;'" true = 1 ; false = 0 - print "shellexpand()(eval \"$(echo \"cat<<'"xend"'\";cat;echo "xend")\")" + print "shexpand()(eval \"$(echo \"cat<<'"xend"'\";cat;echo "xend")\")" print "shellfix()(" shellfix ")" + print "htmlfix()(" htmlfix ")" } end[endn] && $0 == end[endn] { @@ -32,7 +39,7 @@ end[endn] && $0 == end[endn] { docp = !docp docend = $2 ? $2 : dend if (docp) - print "shellexpand<<" docend + print "shexpand<<" docend else print docend "\n" next diff --git a/etlib.sh b/etlib.sh index 971b879..bdf1846 100644 --- a/etlib.sh +++ b/etlib.sh @@ -15,7 +15,7 @@ html_el(){ # el TAG [ATTRS...] [TEXT...] [< INPUT] for arg do case "$arg" in - (*=*) attrs="$attrs ${arg%%=*}=\"${arg#*=}\""; shift ;; + (*=*) attrs="$attrs ${arg%%=*}=${arg#*=}"; shift ;; (*) break ;; esac done @@ -29,6 +29,7 @@ html_el(){ # el TAG [ATTRS...] [TEXT...] [< INPUT] } alias p='html_el p' +alias a='html_el a' alias h1='html_el h1' alias blockquote='html_el blockquote' alias bq=blockquote diff --git a/test.et b/test.et index d62a243..927a4af 100644 --- a/test.et +++ b/test.et @@ -2,6 +2,7 @@ alias verse=cat ... here's a test file +.a href="https://example.com" a link or something!! .h1 it has "headers" or whatever -- cgit 1.4.1-21-gabe81