问题可能在于我对应该发生的事情的理解。这是我做的:
>>> 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。我错过了什么?
答案 0 :(得分:3)
插入一些换行符:
rawtext = "Getting the Gist of Markdown's Formatting Syntax\n------------------------------------------------\nThis page offers a brief "
如果短划线和文字位于单独的一行,则Markdown只会将短划线前的文字转换为<h1>
。 (否则Wow - I never knew that
会将Wow
变为<h1>
。)
答案 1 :(得分: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"