1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
#! /bin/sed -f
# html_uc.sed -- turn html tags to uppercase
# Just to be sure
s/°/°/g
# Multiple lines are handled by storing a flag in hold space
# Fool the regexps below by adding a leading < (we'll remove
# it later)
x
/^j/ { x; s/^/</; x; }
x
# put ° before each tag name
s/<[ ]*/&°/g
# put ° before each attribute name
t attr
: attr
s/\(<[^>]*[ ]\+\)\([A-Za-z/]\+=[^> ]\+\)/\1°\2/g
s/\(<[^>]*[ ]\+\)\([A-Za-z/]\+="[^"]*"\)/\1°\2/g
s/\(<[^>]*[ ]\+\)\([A-Za-z/]\+\)/\1°\2/g
t attr
# add conversion table: °° table
# table format: <to-char> <from-char>
# characters not in the table stop the conversion
s,$,°°//AAaBBbCCcDDdEEeFFfGGgHHhIIiJJjKKkLLlMMmNNnOOoPPpQQqRRrSSsTTtUUuVVvWWwXXxYYyZZz,
# substitute every char that's part of a tag or attribute and which follows a °
# also moves ° after the char
ta
:a
s/°\(.\)\(.*°°.*\)\(.\)\1/\3°\2\3\1/
ta
# cleanup...
s/°°.*//
s/°//g
# Check if the hold space flag is to be set:
# j = this line continued the previous one
# J = this line will be continued by the next one
# jJ = both things
/<[^>]*$/ { x; s/$/J/; x; }
# If the hold space `j' flag was set, remove it, and also delete
# the leading < from pattern space
x
/^j/ { x; s/^.//; x; s/j//; }
# Change the `J' flag to `j' and go on with the next line
s/J/j/
x
|