Alex Rivera | Logout

What is the best way to store and display markdown-entered text?

Asked 2008-11-01T03:00:01.080
14

I've noticed that the wmd editor can either output HTML or markdown. Does it make more sense to store the user input (in a database) as markdown or HTML? If as markdown, what is the best way to display it on a webpage later on (any examples would be greatly appreciated).

Given that the recommendation is store it as markdown, are there any standard converters / stylesheets / anything else to actually display it afterwards?

Edit
Report

1 Answer

0

I think the best way to allow consequent editing would be to store markdown file. After user edited, or uploaded, it's file in markdown syntax save it and generate html and store that generated html.

You only need to 're-generate' html when user updates the markdown file.

I'm not sure what technology you use but there is a python markdown processor, there's pygments for code syntax highlight and python-markdown has build in support for pygments so in one line you get html from markdown file and all source code highlighted.

You need to update the css to include styles to use for code highlight, you can dump default style from pygments and attach it to your page style.

Here is an example how to use markdown and pygments with Blogger.

answered 2010-01-17T22:35:22.583

Your Answer