2013-06-22 57 views
0

也许,问题出在我对于应该发生什么的理解上。这是我做的:python markdown没有得到预期的结果

>>> import markdown2 
>>> rawtext = "Getting the Gist of Markdown's Formatting Syntax ------------------------------------------------ This page offers a brief " 
>>> html = markdown2.markdown(rawtext) 
>>> html 
u"<p>Getting the Gist of Markdown's Formatting Syntax ------------------------------------------------ This page offers a brief </p>\n" 

我试过用markdown而不是markdown2,但得到了相同的结果。我希望很多“ - ”可以让“Markdown的格式化语法的要点”呈现为H1。我错过了什么?

回答

2

它会为<h1>渲染只有在划线是对自己的行下面文字:

>>> import markdown2 
>>> rawtext = "Getting the Gist of Markdown's Formatting Syntax\n------------------------------------------------\nThis page offers a brief " 
>>> markdown2.markdown(rawtext) 
u"<h2>Getting the Gist of Markdown's Formatting Syntax</h2>\n\n<p>This page offers a brief </p>\n" 
+0

我傻,你是正确。谢谢! – rossdavidh

3

插入一些新行:

rawtext = "Getting the Gist of Markdown's Formatting Syntax\n------------------------------------------------\nThis page offers a brief " 

降价只会让破折号之前的文本为<h1>如果破折号和文本是在单独一行。 (否则Wow - I never knew that会变成Wow<h1>