2012-11-16 80 views
1

我有問題得到一個正確的呈現給html降價。我正在使用 python-markdown在appengine 2.7Appengine和Markdown導致間隔文本:< p >世界和世界</p >

我的問題是我在HTML - 命名空間中的字符之間的許多空間?像這樣<code>code</code >

這裏是我的類:

class Text(webapp2.RequestHandler): 
    def post(self): 
     text = self.request.get('content') 
     html = markdown.markdown(text) 

     template_values = {'html': html} 

這裏是我的html:

<html> 
<head> 
    <meta charset="utf-8"/> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/> 
</head> 
<body> 
    {% for html in html %} 
     {{ html }} 
    {% endfor %} 
</body> 
</html> 

這裏發生了什麼事的多了一個樣本:

# Word 

變爲:

< h 1 >Word</h 1 > 

回答

3

您正在解釋返回的HTML列表;通過遍歷文本創建單個字符:

>>> for ch in 'sample': 
...  print ch, 
s a m p l e 

就直接插值html變量:這是解決我的情況

<body> 
    {{ html }} 
</body> 
+0

感謝。 –

相關問題