From c2ca1e0e4214b0ff16429f026f76421b288a93a7 Mon Sep 17 00:00:00 2001 From: Atlas Cove Date: Sat, 11 Feb 2023 18:00:31 +0000 Subject: [PATCH] Added variable CSS support. --- .editorconfig | 2 +- get_sd.awk | 5 ++++- m4/lib.m4 | 7 ++++--- m4/main.html.m4 | 11 +++++------ render.sh | 10 +++++----- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.editorconfig b/.editorconfig index 0d40c64..6cbcd47 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,7 +7,7 @@ insert_final_newline=true [{Makefile,*.s[ac]ss}] indent_style=tab indent_size=1 -[{ignore.txt,*.csv}] +[{ignore.txt,*.csv,m4/*}] insert_final_newline=false [*.rb] indent_style=space diff --git a/get_sd.awk b/get_sd.awk index 42457b8..fc4b20e 100644 --- a/get_sd.awk +++ b/get_sd.awk @@ -1,4 +1,7 @@ #!/usr/bin/awk BEGIN{FS="/";x=2} +function none() {print "main";exit} +NF==1{none()} /\.\//{x++} -{gsub($0,"./","");print $x;exit} +$x~/\.(txti|html|org|md)/{none()} +{if($x=="dnd")none();print $x;exit} diff --git a/m4/lib.m4 b/m4/lib.m4 index cfd8fb6..46841d6 100644 --- a/m4/lib.m4 +++ b/m4/lib.m4 @@ -1,5 +1,6 @@ divert(-1) # extra macros for site structure -define(`ytv',`') -define(`wrap',<$1>$2) -divert +define(`_ytv',`') +define(`_wrap',<$1>$2) +define(`_empty',`') +divert dnl diff --git a/m4/main.html.m4 b/m4/main.html.m4 index f03a317..775bc88 100644 --- a/m4/main.html.m4 +++ b/m4/main.html.m4 @@ -1,14 +1,12 @@ -dnl template.m4.html v1.3-p1 +dnl template.m4.html v1.4-p1 dnl Part of the tape-and-string suite used to construct the website +ifdef(`DEBUG',`traceon')dnl include(`m4/lib.m4')dnl -ifdef(`CSS_INC',`', define(`CSS_INC', `main'))dnl -ifelse(CSS_INC,`dnd',define(`CSS_INC',`main'))dnl -define(`_CSS',`/css/CSS_INC.css')dnl TITLE @@ -17,7 +15,8 @@ define(`_CSS',`/css/CSS_INC.css')dnl Home
-include(`/dev/stdin')dnl Probably not a good idea, but whatever. +temp +dnl include(`/dev/stdin')dnl Probably not a good idea, but whatever.
diff --git a/render.sh b/render.sh index 0afe999..38ea5ad 100755 --- a/render.sh +++ b/render.sh @@ -1,6 +1,6 @@ #!/bin/bash # render.sh: part of the tape-and-string framework. -# v3.3-p1 +# v3.3-p2 #B: Load enable -f /usr/lib/bash/csv csv declare -A title @@ -18,7 +18,7 @@ function wrn { echo -e "\x1B[1;93mWRN\x1B[0m: $*"; } function err { echo -e "\x1B[1;31mERR\x1B[0m: $*"; } function tape { if test -d "$1"; then - err "tape: Passed directory, $1" + err "tape: Passed directory, $1" return 1 fi case $1 in @@ -26,7 +26,7 @@ function tape { *.org) org-ruby --translate html "$1" ;; *.md) comrak --gfm "$1" ;; *.html) cat $1 ;; - *.s[ac]ss) err "Told to render $1, shouldn't happen"; return 1 ;; + *.s[ac]ss) err "Told to render $1, shouldn't happen"; return 1 ;; *) pandoc --columns 168 -t html "$1" || echo "Skipping $i, unknown format" ;; esac } @@ -56,9 +56,9 @@ function docs { o="${i/in/out}" echo "$i => $o" if test -z "${title[$i]}"; then - tape $i | m4 -DCSS_INC=$(awk -f get_sd.awk "$i") m4/main.html.m4 > ${o%.*}.html + tape $i | m4 -DCSSI=$(awk -f get_sd.awk <<< "$i") m4/main.html.m4 > ${o%.*}.html else - tape $i | m4 -DCSS_INC=$(awk -f get_sd.awk "$i") -DTITLE="${title[$i]}" m4/main.html.m4 > ${o%.*}.html + tape $i | m4 -DCSSI=$(awk -f get_sd.awk <<< "$i") -DTITLE="${title[$i]}" m4/main.html.m4 > ${o%.*}.html fi done }