无法从python降价中获得预期结果

2024-06-26 00:22:45 发布

您现在位置:Python中文网/ 问答频道 /正文

也许,问题在于我对应该发生什么的理解。以下是我所做的:

>>> 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。我错过了什么?你知道吗


Tags: ofthehtmlpagethismarkdownformattinggist
2条回答

插入一些新行:

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

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

仅当破折号位于文本下方的行上时,它才会呈现为<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"

相关问题 更多 >