J. Adam Connor
J. Adam Connor

Reputation: 1734

Preserving Formatting from HTML to textarea

I use markdown for text editing within my project. The markdown is converted to HTML and stored in the database for rendering in the view.

Currently, when users would like to edit a post, for example, the stored text is pulled from the database and used as the initial value in the textarea that my markdown editor/converter makes use of.

It's easy enough to strip the tags from the text so they don't show up in the textarea, but I'd really like to preserve things like line breaks as well.

This seems possible, as Stackoverflow uses markdown and during editing line breaks from the text being edited are preserved in the textarea.

Upvotes: 0

Views: 137

Answers (1)

Quentin
Quentin

Reputation: 943981

The markdown is converted to HTML and stored in the database for rendering in the view.

This is your problem.

You should store the markdown and then use that in your textarea.

Upvotes: 1

Related Questions