Python-Markdown / markdown

A Python implementation of John Gruber’s Markdown with Extension support.
https://python-markdown.github.io/
BSD 3-Clause "New" or "Revised" License
3.79k stars 863 forks source link

Why is the converted html in window system different from that in linux system? #1231

Closed zhenzi0322 closed 2 years ago

mitya57 commented 2 years ago

Please provide some details: source markdown, HTML that you get on Windows, HTML that you get on Linux, how exactly you convert, what Python-Markdown version you use.

zhenzi0322 commented 2 years ago

Please provide some details: source markdown, HTML that you get on Windows, HTML that you get on Linux, how exactly you convert, what Python-Markdown version you use.

Why is the output not rendered using the p tag for each line?

test.md:

## 流程

![图片alt](/static/image/20220312/20220312145030.png ''图片title'')
点击`Next`,如下:
![图片alt](/static/image/20220312/20220312145201.png ''图片title'')
选择好之后,下面是我自己的安装路径:
![图片alt](/static/image/20220312/20220312145320.png ''图片title'')
然后点击`Next`,如下:
![图片alt](/static/image/20220312/20220312145355.png ''图片title'')
再点击`Next`,如下:
![图片alt](/static/image/20220312/20220312145422.png ''图片title'')
再点击`Next`,如下:
![图片alt](/static/image/20220312/20220312145441.png ''图片title'')
再点击`Next`,如下:
![图片alt](/static/image/20220312/20220312145523.png  #''图片title'')

markdown to html :

<h2>流程</h2>
<p><img alt="图片alt" src="/static/image/20220312/20220312145030.png" title="图片title">
点击<code>Next</code>,如下:
<img alt="图片alt" src="/static/image/20220312/20220312145201.png" title="图片title">
选择好之后,下面是我自己的安装路径:
<img alt="图片alt" src="/static/image/20220312/20220312145320.png" title="图片title">
然后点击<code>Next</code>,如下:
<img alt="图片alt" src="/static/image/20220312/20220312145355.png" title="图片title">
再点击<code>Next</code>,如下:
<img alt="图片alt" src="/static/image/20220312/20220312145422.png" title="图片title">
再点击<code>Next</code>,如下:
<img alt="图片alt" src="/static/image/20220312/20220312145441.png" title="图片title">
再点击<code>Next</code>,如下:
<img alt="图片alt" src="/static/image/20220312/20220312145523.png" title="图片title"></p>

Why isn't it rendered as the following

<h2>流程</h2>
<p><img alt="图片alt" src="/static/image/20220312/20220312145030.png" title="图片title"></p>
<p>点击<code>Next</code>,如下:</p>
<p><img alt="图片alt" src="/static/image/20220312/20220312145201.png" title="图片title"></p>
选择好之后,下面是我自己的安装路径:</p>
<p><img alt="图片alt" src="/static/image/20220312/20220312145320.png" title="图片title"></p>
<p>然后点击<code>Next</code>,如下:</p>
<p><img alt="图片alt" src="/static/image/20220312/20220312145355.png" title="图片title"></p>
<p>再点击<code>Next</code>,如下:</p>
<p><img alt="图片alt" src="/static/image/20220312/20220312145422.png" title="图片title"></p>
<p>再点击<code>Next</code>,如下:</p>
<p><img alt="图片alt" src="/static/image/20220312/20220312145441.png" title="图片title"></p>
<p>再点击<code>Next</code>,如下:</p>
<p><img alt="图片alt" src="/static/image/20220312/20220312145523.png" title="图片title"></p>
waylan commented 2 years ago

As explained in the rules:

A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines. (A blank line is any line that looks like a blank line — a line containing nothing but spaces or tabs is considered blank.) Normal paragraphs should not be indented with spaces or tabs.

The implication of the “one or more consecutive lines of text” rule is that Markdown supports “hard-wrapped” text paragraphs. This differs significantly from most other text-to-HTML formatters (including Movable Type’s “Convert Line Breaks” option) which translate every line break character in a paragraph into a <br /> tag.

In other words, this is the correct expected behavior. If you want each line to be a separate paragraph, then you need to do this:

## 流程

![图片alt](/static/image/20220312/20220312145030.png ''图片title'')

点击`Next`,如下:

![图片alt](/static/image/20220312/20220312145201.png ''图片title'')
选择好之后,下面是我自己的安装路径:

![图片alt](/static/image/20220312/20220312145320.png ''图片title'')

然后点击`Next`,如下:

![图片alt](/static/image/20220312/20220312145355.png ''图片title'')

再点击`Next`,如下:

![图片alt](/static/image/20220312/20220312145422.png ''图片title'')

再点击`Next`,如下:

![图片alt](/static/image/20220312/20220312145441.png ''图片title'')

再点击`Next`,如下:

![图片alt](/static/image/20220312/20220312145523.png  #''图片title'')