Your question is confusing. Either you want to let the user modify the HTML on their site (which is fine), or you want to do something really ill-advised, like letting users generate their own PHP or MySQL queries.
If you're looking for the former (which I suspect you are), you don't need to turn to anything fancy. I use a freebie Javascript rich-text editor that produces the HTML and it works great. Check out the demo here. There's a checkbox there so you can see or edit the HTML yourself, if you so choose.
The only thing you have to be concerned with is making sure you sandbox the HTML so it doesn't mess with the rest of your page elements. Should be fairly easy to do.