of course, u always have the question of how do word processors store all that data
I think I know what you're referring to (some trick with dealing with storing it in one long byte string), but these days if you're writing a new one you'd probably just go the easy route and use parse-trees.
Look at XML's DOM for the general idea (use a separate object for each chunk of text that has an attribute; if you select some text in a chunk and change the formatting of half of it, it splits the chunk into two chunks, and adds extra info onto the piece that you changed).
This is, literally, the easiest way for a computer to deal with the info; programmatically accessing and altering it, AND converting to any other form is easiest if it starts in this form.
Of course, this is precisely why DOM was adopted for manipulating XML docs: because it's the most convenient arrangement for humans to write code to access / change / interpret.