about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--README.md5
-rwxr-xr-xet21
-rw-r--r--etlib.sh3
-rw-r--r--test.et1
4 files changed, 22 insertions, 8 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..010e4a9 --- /dev/null +++ b/README.md
@@ -0,0 +1,5 @@
1# et --- excited text
2
3not-quite-html that generates a shell script with groff-sorta input
4
5idk maybe i should call this frankentext
diff --git a/et b/et index 06cbf4c..0e03aa3 100755 --- a/et +++ b/et
@@ -3,15 +3,22 @@
3# usage: et <file> | sh 3# usage: et <file> | sh
4 4
5BEGIN { 5BEGIN {
6 xend = xend ? xend : "...xend..." 6 xend = xend ? xend : "...end...shexpand..."
7 dend = dend ? dend : "...dend..." 7 dend = dend ? dend : "...end...document..."
8 # We shell out to sed for this because awk doesn't do capture groups ;-; 8 # We shell out to sed for this because awk doesn't do capture groups ;-;
9 shellfix = "sed -E -e 's/`/\\\\`/g' " \ 9 shellfix = "sed -E" \
10 "-e 's/(^|[^\\$])\\$([^\\$]|$)/\\1\\\\$\\2/g' " \ 10 " -e 's/`/\\\\`/g'" \
11 "-e 's/(^|[^\\$])\\$(\\$+)([^\\$]|$)/\\1\\2\\3/g'" 11 " -e 's/(^|[^\\$])\\$([^\\$]|$)/\\1\\\\$\\2/g'" \
12 " -e 's/(^|[^\\$])\\$(\\$+)([^\\$]|$)/\\1\\2\\3/g'"
13 htmlfix = "sed -E" \
14 " -e 's#([^\\\\]|^)&#\\1\\&amp;#g;'" \
15 " -e 's#([^\\\\]|^)<#\\1\\&lt;#g;'" \
16 " -e 's#([^\\\\]|^)>#\\1\\&gt;#g;'" \
17 " -e 's#\\\\([&<>])#\\1#g;'"
12 true = 1 ; false = 0 18 true = 1 ; false = 0
13 print "shellexpand()(eval \"$(echo \"cat<<'"xend"'\";cat;echo "xend")\")" 19 print "shexpand()(eval \"$(echo \"cat<<'"xend"'\";cat;echo "xend")\")"
14 print "shellfix()(" shellfix ")" 20 print "shellfix()(" shellfix ")"
21 print "htmlfix()(" htmlfix ")"
15} 22}
16 23
17end[endn] && $0 == end[endn] { 24end[endn] && $0 == end[endn] {
@@ -32,7 +39,7 @@ end[endn] && $0 == end[endn] {
32 docp = !docp 39 docp = !docp
33 docend = $2 ? $2 : dend 40 docend = $2 ? $2 : dend
34 if (docp) 41 if (docp)
35 print "shellexpand<<" docend 42 print "shexpand<<" docend
36 else 43 else
37 print docend "\n" 44 print docend "\n"
38 next 45 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]
15 for arg 15 for arg
16 do 16 do
17 case "$arg" in 17 case "$arg" in
18 (*=*) attrs="$attrs ${arg%%=*}=\"${arg#*=}\""; shift ;; 18 (*=*) attrs="$attrs ${arg%%=*}=${arg#*=}"; shift ;;
19 (*) break ;; 19 (*) break ;;
20 esac 20 esac
21 done 21 done
@@ -29,6 +29,7 @@ html_el(){ # el TAG [ATTRS...] [TEXT...] [< INPUT]
29} 29}
30 30
31alias p='html_el p' 31alias p='html_el p'
32alias a='html_el a'
32alias h1='html_el h1' 33alias h1='html_el h1'
33alias blockquote='html_el blockquote' 34alias blockquote='html_el blockquote'
34alias bq=blockquote 35alias bq=blockquote
diff --git a/test.et b/test.et index d62a243..927a4af 100644 --- a/test.et +++ b/test.et
@@ -2,6 +2,7 @@
2alias verse=cat 2alias verse=cat
3... 3...
4here's a test file 4here's a test file
5.a href="https://example.com" a link or something!!
5 6
6.h1 it has "headers" or whatever 7.h1 it has "headers" or whatever
7 8