thephpleague / commonmark

Highly-extensible PHP Markdown parser which fully supports the CommonMark and GFM specs.
https://commonmark.thephpleague.com
BSD 3-Clause "New" or "Revised" License
2.75k stars 194 forks source link

Last backslash before a heading/table gets preserved #1000

Closed DKhalil closed 1 year ago

DKhalil commented 1 year ago

Version(s) affected

2.4.1

Description

A forced line break with a backslash works as long as there's no heading or table element following it.

How to reproduce

# Hello
\
\
## Hello again
colinodell commented 1 year ago

That behavior is intentional. According to the CommonMark spec:

Hard line breaks are for separating inline content within a block. Neither syntax for hard line breaks works at the end of a paragraph or other block element

See https://spec.commonmark.org/0.29/#hard-line-breaks, as well as https://babelmark.github.io/?text=%23+Hello%0A%5C%0A%5C%0A%23%23+Hello+again showing how all CommonMark-compliant parsers behave this way.