You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Standard Extensions add extra LF character to html #1003
Extra linefeed characters are shown after code blocks in the html file. The extra white space is carried over to mkdocs but it does not affect rendering.
index.md
python test
```python
pass
```
Next test
```
random
```
html test
```html
<p>empty</p>
```
end
python -m markdown .\docs\index.md >index.html
<p>python test</p><p><code>python
pass</code></p><p>Next test
<code>random</code></p><p>html test
<code>html
<p>empty</p></code>
end</p>
With extra extension:
python -m markdown -x extra .\docs\index.md >index.html
This is the correct behavior. A code block should always end with a line break.
Note, however, that you are using fence code blocks, which are a non-standard feature. In your first example, you have not activated the fenced_code extension and the code blocks are being parsed as code spans. Of course, code spans have whitespace striped from the ends as required by the rules. Therefore, the behavior is different there.
In your other two examples, you have activated the extra extension, which includes fenced_code. Therefore, the blocks are parsed as fenced code blocks and the line break is preserved.
Wouldn't that require a line break to divide in the last example rather than the double line break after it now?
First of all, the output of the codehilite extension is generated by Pigments. We simply pass through what Pigments provides. Therefore, of there was an issue it would need to be addressed upstream.
Second, adding a line break there would make no difference. As that is outside of the <pre> tag, the browser would render using 'normal" behavior. Specifically, all whitespace is collapsed to a single space. In other words, adding a newline would result in a single space. As it stands now, the two lines after the <div> are rendered as a single space. The only reason any space would appear between the <div> and the <p> that follows it would be because margin and/or padding are defined in CSS on one or both of those elements. The whitespace in the markup is completely insignificant.
Activity
waylan commentedon Jul 17, 2020
This is the correct behavior. A code block should always end with a line break.
Note, however, that you are using fence code blocks, which are a non-standard feature. In your first example, you have not activated the
fenced_codeextension and the code blocks are being parsed as code spans. Of course, code spans have whitespace striped from the ends as required by the rules. Therefore, the behavior is different there.In your other two examples, you have activated the
extraextension, which includesfenced_code. Therefore, the blocks are parsed as fenced code blocks and the line break is preserved.I'm closing this as there is no issue here.
flywire commentedon Jul 17, 2020
Wouldn't that require a line break to divide
</pre></div>in the last example rather than the double line break after it now?waylan commentedon Jul 18, 2020
First of all, the output of the codehilite extension is generated by Pigments. We simply pass through what Pigments provides. Therefore, of there was an issue it would need to be addressed upstream.
Second, adding a line break there would make no difference. As that is outside of the
<pre>tag, the browser would render using 'normal" behavior. Specifically, all whitespace is collapsed to a single space. In other words, adding a newline would result in a single space. As it stands now, the two lines after the<div>are rendered as a single space. The only reason any space would appear between the<div>and the<p>that follows it would be because margin and/or padding are defined in CSS on one or both of those elements. The whitespace in the markup is completely insignificant.