我是按照这个教程上的 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
1
imlonghao 2015-06-10 10:44:09 +08:00
你的con前面被你加了空格?
|
2
imlonghao 2015-06-10 10:45:01 +08:00
con = """
Chapter ======= Section ------- * Item 1 * Item 2 """ |
4
imlonghao 2015-06-10 10:48:08 +08:00
|
5
imlonghao 2015-06-10 10:48:23 +08:00
|
6
elvis_w 2015-06-11 15:48:22 +08:00
|