>>92If I was writing in c I would lex using a statemachine that was machine generated with lex or flex. But I'm using python instead of c. I could write the statemachine myself in python but it would be slow as fuck to do that kind of processing at the script level. The only thing I can think of would be to use multiple regular expressions and perform multiple passes and craft the expressions so they somehow don't substitute within each other, but it's difficult and opens doors for html injection if things go wrong. It's frustrating to have a library that can do regex but can't do this conveniently.