#! /usr/local/bin/perl -w # # html-lcase - convert all elements and attributes in html into small letters. # # Copyright (C) 1999 Satoru Takabayashi # All rights reserved. # This is free software with ABSOLUTELY NO WARRANTY. # # You can redistribute it and/or modify it under the terms of # the GNU General Public License version 2. # use strict; my $content = join '', <>; $content =~ s/(<\/?)([A-Z]\w*)((?:\s+[A-Z]\w*(?:\s*=\s*(?:(["']).*?\4|[\w\-.]+))?)*)(\s*>)/ $1 . lc($2) . lc_attr($3) . $5/gsixe; print $content; sub lc_attr { my ($attrs) = @_; $attrs =~ s/\n/ /g; $attrs =~ s!(\s+)([A-Z]\w*)((?:\s*=\s*(?:(["']).*?\4|[\w\-.]+)))?! $1 . lc($2) . $3!gies; return $attrs; }