Skip to content

Always suffix indented code block with a newline#799

Merged
rlidwka merged 1 commit intomarkdown-it:masterfrom
hukkin:fix-no-codeblock-end-newline
Jul 15, 2021
Merged

Always suffix indented code block with a newline#799
rlidwka merged 1 commit intomarkdown-it:masterfrom
hukkin:fix-no-codeblock-end-newline

Conversation

@hukkin
Copy link
Copy Markdown
Contributor

@hukkin hukkin commented Jul 12, 2021

Currently

    codeblock\n

(where \n represents a trailing newline) renders differently to

    codeblock

(no trailing newline).

The former renders to

<pre><code>codeblock
</code></pre>

and the latter to

<pre><code>codeblock</code></pre>

This PR makes the two examples render to the same HTML by always adding a trailing newline to code block content.

The spec is not overly clear about this corner case, but this PR makes

@rlidwka
Copy link
Copy Markdown
Member

rlidwka commented Jul 15, 2021

Merged, thanks!

Is code block the only place where the absense of trailing newline in original input matters?

@hukkin
Copy link
Copy Markdown
Contributor Author

hukkin commented Jul 15, 2021

Is code block the only place where the absense of trailing newline in original input matters?

This I don't have an answer to right now, I haven't tested. I found this issue while fuzzing mdformat and if there are other similar issues with other syntax then the fuzzer should find them when I have the time to get back into it.

@hukkin hukkin deleted the fix-no-codeblock-end-newline branch July 15, 2021 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants