diff options
| author | Thomas Schwinge <thomas@codesourcery.com> | 2012-05-24 23:08:09 +0200 |
|---|---|---|
| committer | Thomas Schwinge <thomas@codesourcery.com> | 2012-05-24 23:08:09 +0200 |
| commit | 2910b7c5b1d55bc304344b584a25ea571a9075fb (patch) | |
| tree | bfbfbc98d4c0e205d2726fa44170a16e8421855e /purify_html | |
| parent | 35b719f54c96778f571984065579625bc9f15bf5 (diff) | |
Prepare toolchain/logs/master branch.
Diffstat (limited to 'purify_html')
| -rwxr-xr-x | purify_html | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/purify_html b/purify_html deleted file mode 100755 index 9c3a7862..00000000 --- a/purify_html +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - -# Mangle the rendered files to cause fewer differences after re-rendering. - -# Written by Thomas Schwinge <thomas@schwinge.name>. - -# Un-mangle mailto links: convert HTML character entities to real characters. -find ./ -name \*.html -print0 \ - | 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 /<a href="mailto:/; - s%\&#(x?)([^;]*);%$discard = 0; chr(length($1) ? hex($2) : $2);%eg if $replacing; - $replacing = 0 if /<\/a>/; - } continue { - print or die "print: $file: $!"; - } - - END { - if ($discard) { - unlink("$file.new") or die "unlink: $file: $!"; - } else { - rename("$file.new", $file) or die "rename: $file: $!"; - } - }' - -# Compared to using ``perl -p -i -l'', this solution maintains the files' -# original timestamps unless they're actually modified. |
