#!/usr/bin/perl -w # Copyright © 2001 by Julian Fong . All rights reserved. # # Permission to use, copy, modify, distribute, and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appear in all copies and # that both that copyright notice and this permission notice appear in # supporting documentation. No representations are made about the # suitability of this software for any purpose. It is provided "as # is" without express or implied warranty. # # fixtag: converts upper case HTML tags to lowercase, puts quotes # around values, all for helping convert documents to XHTML compliance # set backup file to be filename~ and create a copy in filename $^I = "~"; my ($token, $equals, $pre, $tag, $end); while (<>) { chomp; while (($pre, $tag, $end) = /([^<]*)(<[^!][^>]*>)(.*)/) { $equals = 0; $_ = $end; print $pre; @_ = split(/(\"[^\"]*\"|=)/, $tag); foreach $token (@_) { if (substr($token, 0, 1) eq "\"") { $equals = 0; print $token; } elsif (substr($token, 0, 1) =~ m/\s*=\s*/) { $equals = 1; print '='; } elsif ($token && $equals) { $equals = 0; $token =~ /([^\s\>]*)(\>?\s*)(.*)/; print "\"$1\"$2" . lc ($3); } else { $equals = 0; print lc $token; } } } print; print "\n"; }