s;>[ \t]+\.([^< \t]+); class="\1">;g;
s;>[ \t]+#([^< \t]+); id="\1">;g;
s;>[ \t]+([^ \t=<]+=("[^"]*"|'[^']*'|[^< \t]*)); \1>;g;
-s;(<input type="(checkbox|radio)" [^>]+)>[ \t]+checked;\1 checked="checked">;g;
+t attribs;
+s;(<input ([^>]+ )?type=(radio|"radio"|'radio')( [^>]+)?)>[ \t]+checked;\1 checked="checked">;g;
+s;(<input ([^>]+ )?type=(checkbox|"checkbox"|'checkbox')( [^>]+)?)>[ \t]+checked;\1 checked="checked">;g;
+s;(<option( [^>]+))>[ \t]+(checked|selected);\1 selected="selected">;g;
t attribs;
s;(<[^/][^>]*>)[ \t]*;\1;g;