我是按照这个教程上的 Using the markdown language
我的代码 :
from flask import Markup
import markdown
from flask import Flask
from flask import render_template
@app.route('/mark')
def mark():
con = """
Chapter
=======
Section
-------
* Item 1
* Item 2
"""
contents= Markup(markdown.markdown(con))
return render_template('mark.html', content=contents)
html代码:
<html>
<head>
<title>Markdown Snippet</title>
</head>
<body>
{% if content %}
{{ content }}
{% endif %}
</body>
</html>
访问结果是这样, 原封不动输出:
Chapter
=======
Section
-------
* Item 1
* Item 2