From 224cb73643074f8f0654b688df7df13dd7b8ae4a Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Sat, 21 Mar 2009 14:45:53 +0100 Subject: purify_html: New. --- purify_html | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 purify_html (limited to 'purify_html') diff --git a/purify_html b/purify_html new file mode 100755 index 00000000..a9ead881 --- /dev/null +++ b/purify_html @@ -0,0 +1,11 @@ +#!/bin/sh + +# Un-mangle mailto links: convert HTML character entities to real characters. +find ./ -name \*.html -print0 \ + | xargs -0 \ + perl -p -i -l -e \ + 'BEGIN { $replacing = 0; } + # The replacing-toggling logic is a bit rough, but so is life. + $replacing = 1 if //;' + | xargs -0 --no-run-if-empty -n 1 \ + perl -e \ + 'BEGIN { + $file = $ARGV[0]; + $discard = 1; + $replacing = 0; + + # TODO: could use a proper temporary file. + open(OUT, ">$file.new") or die "open: $file: $!"; + select(OUT) or die "select: $file: $!"; + } + + while (<>) { + # The replacing-toggling logic is a bit rough, but so is life. + $replacing = 1 if /