March 20, 2003
3:17 p.m.
The following replacement code allows HTML4css1.py to support the use of charents. It can be easily adapted to the other writers, I'm sure. def encode(self, text): """Encode special characters in `text` & return.""" # @@@ A codec to do these and all other HTML entities would be nice. # text = text.replace("&", "&") # match standard charent forms (&NUM; &xHEXNUM; and &namedEntity;) text = re.sub(r'&(?!(([a-zA-Z]{2,};)|(#(x|X)?[0-9a-fA-F]{2,4};)))', r'&', text) text = text.replace("<", "<") text = text.replace('"', """) text = text.replace(">", ">") text = text.replace("@", "@") # may thwart some address harvesters return text