This is an interview question. What data structure would you use to store the text in a text editor?
You might find this interesting, even if it does not exactly answer your question:
Most efficient data structure to add styles to text
I am hoping that the discussion will go to fascinating places :-)