in reply to Parsing HTML code for formatting into JavaScript
If it were me, I'd start with Jemplate instead of doing whatever it is you are trying to do here...