rich text editing html encoding and restructuring