How do i convert WMD markdown syntax to HTML on my site?

有些话、适合烂在心里 提交于 2019-12-05 02:24:15

问题


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.



来源:https://stackoverflow.com/questions/763087/how-do-i-convert-wmd-markdown-syntax-to-html-on-my-site

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!