Reputation: 1058
I am using a Markdown package inside my Laravel 4 application to store user input from textareas into my DB.
https://github.com/vtalbot/markdown
This works perfectly using:
Markdown::string('#test');
However, when I edit a record and set the value of a textarea to the existing data in the DB (the data that was formatted for entry), elements such as P tags are shown, which isn't ideal.
Does anyone know of a way to "reverse" markdown for this? Maybe I should be approaching this differently?
Thanks.
Upvotes: 1
Views: 1220
Reputation: 2116
You don't reverse it. You store the unparsed version in the database and parse it when you display it to the user. And if you want to save on some overhead when parsing then you can cache it in some form. Either via an actual cache, like redis or memcached, or you store it in an additional field in the database and update the parsed version whenever it is updated.
Upvotes: 10