How do i convert WMD markdown syntax to HTML on my

2019-03-31 14:16发布

问题:

Am using django and am implementing WMD on my site, am just wondering how do i convert the markdown syntax to HTML for display purposes, is there some sort of function i should call to do this conversion?

What is the best way to handle markdown ie. do i save the markdown as is to the database then parse it when displaying it or should i save the converted HTML then convert it to markup during editing?

回答1:

Check out the markup add-on which comes with Django. That is what you are looking for.

To activate these filters, add 'django.contrib.markup' to your INSTALLED_APPS setting. Once you’ve done that, use {% load markup %} in a template, and you’ll have access to these filters. For more documentation, read the source code in django/contrib/markup/templatetags/markup.py.

Also check out this article for some more details if you're still stuck.