views:

126

answers:

2

Google app engine question: What is a good way to take formatted text (does not have to be rich text) from the user and then store it in a text or blog property in the datastore? Mainly what I'm looking for is it to store newlines and strings of spaces, so that the text comes back looking the same as when it was submitted.

+2  A: 

The text will always "come back" the same as how you put it in. You will lose some formatting rendering to HTML (as you noticed line endings and spaces). One solution might be to render the text into a <pre> element (which implies preformatted text).

<pre>
This text     will

be formatted correctly
</pre>

Another way would be to convert your format into HTML which is well formatted. Typically a Wiki might do this: store the text as markup, and render it to HTML. It's probably exactly what this site is doing with it's posts etc. If you do choose this route, I can recommend the creoleparser library, and it works well on Appengine.

Ali A
+2  A: 

Other commonly used simplified markups include Textile and Markdown.

zgoda