summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2022-08-13 19:14:26 -0500
committerCase Duckworth2022-08-13 19:14:26 -0500
commit85d8a2d6b4a5335db6e4bda799c454664fb859d1 (patch)
treef7994a8439bc1e049f0de458ab61d4c0790e5c9b
parentUpdate documentation (diff)
downloadht-85d8a2d6b4a5335db6e4bda799c454664fb859d1.tar.gz
ht-85d8a2d6b4a5335db6e4bda799c454664fb859d1.zip
Move template-escaping before raw handling
-rwxr-xr-xht.awk21
1 files changed, 13 insertions, 8 deletions
diff --git a/ht.awk b/ht.awk index 04506a9..bf9db1e 100755 --- a/ht.awk +++ b/ht.awk
@@ -14,6 +14,19 @@ BEGIN {
14 ATTR = DEFATTR 14 ATTR = DEFATTR
15} 15}
16 16
17# Sure, let's do templating! This makes it less... weird.
18# This has to come before raw handling so that code doesn't get expanded in raw sections.
19/\$/ {
20 if (RAW) {
21 gsub(/\$/, "\\\\&", $0)
22 } else {
23 # XXX: This is probably the dumbest way to do it.
24 gsub(/\$\$/, "$\a", $0)
25 gsub(/\$[^\a]/, "\\\\&", $0)
26 gsub(/\$\a/, "$", $0)
27 }
28}
29
17# Handle raw sections 30# Handle raw sections
18$0 ~ CONFIG["raw_delim"] { 31$0 ~ CONFIG["raw_delim"] {
19 RAW = ! RAW 32 RAW = ! RAW
@@ -45,14 +58,6 @@ $0 ~ ("^" COMMENT_DELIM) {
45 next 58 next
46} 59}
47 60
48# Sure, let's do templating! This makes it less... weird.
49/\$/ {
50 # XXX: This is probably the dumbest way to do it.
51 gsub(/\$\$/, "$\a", $0)
52 gsub(/\$[^\a]/, "\\\\&", $0)
53 gsub(/\$\a/, "$", $0)
54}
55
56# Blocks of text 61# Blocks of text
57/./ { 62/./ {
58 # EOL escape 63 # EOL escape