-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Remove extra inner linebreak from code blocks #1266
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Forced a new commit that removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
@remyrylan Thanks for the contribution! |
I think both CommonMark spec and GFM spec say last line break should be left as it is. It is a highlighter bug, not marked or spec bug. It must be reverted. |
@hail2u Which example number in the spec are you referencing? |
Example 109 is most clear. This 1 line fenced code block has line break. Also commonmark.js dingus can reproduce this behavior. |
This is a bit strange since the spec doesn't seem to call it out directly. Only the example html output (and consequently the dingus) show this "feature". Example 99 seems to avoid adding a newline. Example 109 seems to add a newline. Our tests show both 99 and 109 as passing but I would expect one to pass and one to fail. @UziTech Is this due to the way |
Most likely an html-differ bug. @hail2u why is this a problem, that the last line break is missing? Did you run into a specific case where adding the line break would be beneficial? |
To be honest, there is no big problem here. Some syntax highlighter shows I think the problem mentioned in this issue is also a little problem. The original markdown, CommonMark, GFM, and marked prior to v0.4.0 leave the last line break as it is. It would be a reasonable and a safest behavior, isn’t it? Markdown has been used for a long time, there might be a tool that depends on this behavior. I find a clear rule about this line break from the CommonMark spec - 4.4 Indented code blocks:
|
Remove extra inner linebreak from code blocks
Description
Currently,
marked
adds a line break before inserting</code></pre>
, some highlighting and parsing tools I've ran into actually interpret this line break (since it's wrapped in a<pre>
) as an extra line break that should be displayed in the output.Essentially the following HTML from marked:
Will produce rendered output with some highlighters as having an extra trailing inner line break:
Expectation
(no trailing inner line break)
Then highlighters will render correctly as:
Contributor
Committer
In most cases, this should be a different person than the contributor.