I have a text file (e.g. a Gutenberg book) I want to display in an HTML page dynamically. I know how to load the file using Javascript, but I’m not sure how to properly display it. Simple document.write-ing it is not good since it destroyes line breaks (and maybe other things?).
I can put the text inside TextArea and then it’ll look fine, but I want one more thing: To be able to color specific letters in the text in different colors (e.g. color the fifth “h” in blue and the seventh “h” in red). I don’t think TextArea can do it; I thought simply to wrap the letter by some div and use CSS.
So, how do I transform the text from the file to something that is HTML-friendly?
You can use PRE tag for this, I have created a jsFiddle with an example – http://jsfiddle.net/X68Af/4/