Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store lightweight formatting (Textile, Markdown) in database?

I'm going to be implementing a lightweight formatting language (probably Textile, maybe Markdown) in a project I'm working on, and I'm wonder how best to store it in the database.

If the user is able to edit the content they're posting, it makes sense to me that the original, non-converted markup be stored so that the user doesn't have to edit HTML the next time around. But since the content is going to be displayed a whole lot more than edited, it also makes sense to store a converted copy of the content so that the original doesn't have to be sent through Textile on every page view.

So, is the common practice to store both the original and converted content side-by-side in the database? Is there a better way?

Thanks!

like image 846
Justin Stayton Avatar asked Jan 29 '09 17:01

Justin Stayton


1 Answers

Store markdown:

  • Every view = conversion
  • Every edit = no processing

Store html

  • Every view = no processing
  • Every edit = convert to markdown and back

Store both

  • Every view = no processing
  • Every edit = convert to html after edit

You have to weigh up your processing costs vs. your storage cost.

like image 111
cjk Avatar answered Oct 09 '22 19:10

cjk