diff options
author | Case Duckworth | 2024-01-22 09:44:38 -0600 |
---|---|---|
committer | Case Duckworth | 2024-01-22 09:44:38 -0600 |
commit | 128d8c4bcddf9570da5785ff171e70c97c1a54b5 (patch) | |
tree | ce6111d0697a9adef71665898b5f809d317cf4fd | |
parent | Initial commit (diff) | |
download | et-128d8c4bcddf9570da5785ff171e70c97c1a54b5.tar.gz et-128d8c4bcddf9570da5785ff171e70c97c1a54b5.zip |
Update
-rw-r--r-- | README.md | 5 | ||||
-rwxr-xr-x | et | 21 | ||||
-rw-r--r-- | etlib.sh | 3 | ||||
-rw-r--r-- | test.et | 1 |
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 | |||
3 | not-quite-html that generates a shell script with groff-sorta input | ||
4 | |||
5 | 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 @@ | |||
3 | # usage: et <file> | sh | 3 | # usage: et <file> | sh |
4 | 4 | ||
5 | BEGIN { | 5 | BEGIN { |
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\\&#g;'" \ | ||
15 | " -e 's#([^\\\\]|^)<#\\1\\<#g;'" \ | ||
16 | " -e 's#([^\\\\]|^)>#\\1\\>#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 | ||
17 | end[endn] && $0 == end[endn] { | 24 | end[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 | ||
31 | alias p='html_el p' | 31 | alias p='html_el p' |
32 | alias a='html_el a' | ||
32 | alias h1='html_el h1' | 33 | alias h1='html_el h1' |
33 | alias blockquote='html_el blockquote' | 34 | alias blockquote='html_el blockquote' |
34 | alias bq=blockquote | 35 | 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 @@ | |||
2 | alias verse=cat | 2 | alias verse=cat |
3 | ... | 3 | ... |
4 | here's a test file | 4 | here'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 | ||