Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
def ampersands(string): """Allow terminated entities but escape wild ampersands.""" splits = string.split('&') if len(splits) == 1: return string result = splits[0] for split in splits[1:]: if split: for char in split: if char.isspace(): result += "&" + split; break elif char == ';': result += "&" + split; break else: # end of split result += "&" + split else: # empty split result += "&" return result
This paste will be private.
From the Design Piracy series on my blog: