0

可能问题在于我对应该发生的事情的理解。这是我所做的:

>>> 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,但得到了相同的结果。我原以为许多“-”会导致“Getting the Gist of Markdown's Formatting Syntax”呈现为 H1。我错过了什么?

4

2 回答 2

3

插入一些换行符:

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

<h1>如果破折号和文本在单独的行上,Markdown 只会将破折号之前的文本变成一个。(否则Wow - I never knew thatWow变成一个<h1>。)

于 2013-06-22T19:54:25.480 回答
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"
于 2013-06-22T19:55:36.060 回答