Skip to content Skip to sidebar Skip to footer

Markdown Or HTML

I have a requirement for users to create, modify and delete their own articles. I plan on using the WMD editor that SO uses to create the articles. From what I can gather SO store

Solution 1:

Storing both is extremely useful/helpful in terms of performance and compatiblity (and eventually also social control).

If you store only Markdown (or whatever non-HTML markup), then there's a performance cost by parsing it into HTML flavor everytime. This is not always noticeably cheap.

If you store only HTML, then you'll risk that bugs are silently creeping in the generated HTML. This would lead to lot of maintenance and bugfixing headache. You'll also lose social control because you don't know anymore what the user has actually filled in. You'd for example as being an admin also like to know which users are trying to do XSS using <script> and so on. Also, the enduser won't be able to edit the data in Markdown format. You'd need to convert it back from HTML.

To update the HTML on every change of Markdown version, you just add one extra field representing the Markdown version being used for generating the HTML output. Whenever this has been changed in the server side at the moment you retrieve the row, re-parse the data using the new version and update the row in the DB. This is only an one-time extra cost.


Solution 2:

By storing both you only have to process the markdown once (when it is posted). You would then retrieve the HTML so that you can load your pages faster.


Solution 3:

If you only stored one, you'd forever have to recreate the other for either the display view or the edit view.


Post a Comment for "Markdown Or HTML"