commit d82b009b00c88a380c73ad5c67330bae3134b9da
parent 0caffac3988e627fabeebb005e7ad03dc97dd5c4
Author: uriel@engel.se.cat-v.org <unknown>
Date: Sat, 20 Dec 2008 22:56:49 +0100
New html_handler that replaces gnu/sed with awk by sqweek, sorry for taking so long and thanks!
Diffstat:
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/bin/werc.rc b/bin/werc.rc
@@ -79,7 +79,12 @@ fn md_handler { cat $* | $formatter }
fn tpl_handler { template $1 }
fn html_handler {
- cat $1 | /bin/sed '0,/<[Bb][Oo][Dd][Yy][^>]*>/d; /<\/[Bb][Oo][Dd][Yy]>/,$d'
+ # body states: 0 = no <body> found, 2 = after <body>, 1 = after <body></body>, -1 = after </body>
+ awk 'gsub(".*<[Bb][Oo][Dd][Yy][^>]*>", "") > 0 {body=2}
+ gsub("</ *[Bb][Oo][Dd][Yy][^>]*>.*", "") > 0 {print; body=body-1}
+ body==2 {print}
+ body==0 {buf=buf "\n" $0}
+ END {if(body<=0) {print buf}}' < $1
}
fn txt_handler {