about summary refs log tree commit diff stats
path: root/ht.awk
diff options
context:
space:
mode:
authorCase Duckworth2022-05-24 17:16:49 -0500
committerCase Duckworth2022-05-24 17:16:49 -0500
commit849013a6d2ae99ea1b088298b8f2067818b7404d (patch)
treeec3b58022c90b82425e855fd3c8f864f2671071d /ht.awk
parentUse rsync -u to avoid .last_build (diff)
downloadhat-trick-849013a6d2ae99ea1b088298b8f2067818b7404d.tar.gz
hat-trick-849013a6d2ae99ea1b088298b8f2067818b7404d.zip
Generate a feed
Diffstat (limited to 'ht.awk')
-rwxr-xr-xht.awk9
1 files changed, 3 insertions, 6 deletions
diff --git a/ht.awk b/ht.awk index 5328361..faa729d 100755 --- a/ht.awk +++ b/ht.awk
@@ -15,6 +15,7 @@ function buflush() {
15} 15}
16 16
17function esc(t) { 17function esc(t) {
18 # This is of much more limited utility than I initially realized.
18 gsub(/&/, "\\&", t); 19 gsub(/&/, "\\&", t);
19 gsub(/</, "\\&lt;", t); 20 gsub(/</, "\\&lt;", t);
20 gsub(/>/, "\\&gt;", t); 21 gsub(/>/, "\\&gt;", t);
@@ -30,8 +31,8 @@ function esc(t) {
30} 31}
31 32
32/^=>/ { # Links (Gemini-style) 33/^=>/ { # Links (Gemini-style)
33 link = "<a href=\"" esc($2) "\">" esc($3); 34 link = "<a href=\"" esc($2) "\">" $3;
34 for (i=4;i<=NF;i++) link = link " " esc($i); 35 for (i=4;i<=NF;i++) link = link " " $i;
35 link = link "</a>"; 36 link = link "</a>";
36 bufpush(link); 37 bufpush(link);
37 next; 38 next;
@@ -39,20 +40,17 @@ function esc(t) {
39 40
40/^-/ { # Unordered lists 41/^-/ { # Unordered lists
41 if (! (tag == "ul")) tag = "ul"; 42 if (! (tag == "ul")) tag = "ul";
42 esc($0);
43 sub(/^-[ \t]*/, "<li>"); 43 sub(/^-[ \t]*/, "<li>");
44} 44}
45 45
46/^[0-9]+\./ { # Ordered lists 46/^[0-9]+\./ { # Ordered lists
47 if (! (tag == "ol")) tag = "ol"; 47 if (! (tag == "ol")) tag = "ol";
48 esc($0);
49 sub(/^[0-9]+\.[ \t]/, "<li>"); 48 sub(/^[0-9]+\.[ \t]/, "<li>");
50} 49}
51 50
52/^>/ { # Blockquotes 51/^>/ { # Blockquotes
53 if (! (tag == "blockquote")) tag = "blockquote"; 52 if (! (tag == "blockquote")) tag = "blockquote";
54 sub(/^>[ \t]*/,""); 53 sub(/^>[ \t]*/,"");
55 esc($0);
56} 54}
57 55
58/^#+/ { # Headers 56/^#+/ { # Headers
@@ -62,7 +60,6 @@ function esc(t) {
62 tag = "h" RLENGTH; 60 tag = "h" RLENGTH;
63 } 61 }
64 sub(/^#+[ \t]*/,""); 62 sub(/^#+[ \t]*/,"");
65 esc($0);
66} 63}
67 64
68/^$/ { 65/^$/ {