0
내가 전체의 밤이 싸우고있다 ... 나는 .md 파일에서 HTML 파일을 생성하고 다른 HTML 파일로를 포함하는 Python markdown를 사용하기 위해 노력하고있어Jinja2 이상한 인코딩 오류
. 아직 내가 무엇을 얻을
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>blog</title>
<link rel="stylesheet" href="{{ css_url }}" type="text/css" />
</head>
<body>
{{ contents }}
</body>
</html>
그리고 :
여기md = markdown.Markdown(encoding="utf-8")
input_file = codecs.open(f, mode="r", encoding="utf-8") # f is the name of the markdown file
text = input_file.read()
html = md.convert(text) # html generated from the markdown file
context = {
'css_url': url_for('static', filename = 'markdown.css'),
'contents': html
}
rendered_file = render_template('blog.html', **context)
output = open(splitext(f)[0] + '.html', 'w') # write the html to disk
output.write(rendered_file)
output.close()
정말 간단 내 "blog.html"템플릿입니다 : 여기
문제가있는 조각이다<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>blog</title>
<link rel="stylesheet" href="/static/markdown.css" type="text/css" />
</head>
<body>
<li>People who love what they are doing</li>
<li></li>
</ol>
</body>
</html>
그래서 이상한 "& gt", "& lt "물건, 비록 내가 이미 'utf - 8'로 인코딩을 지정했습니다. 무엇이 잘못 될 수 있습니까?
감사합니다.
오 세상에, 방금 내 생명을 구했어 ... 정말 고마워 !! –