mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Make sure closing sequence is removed correctly
This commit is contained in:
parent
30763a0f38
commit
49dd8b113d
@ -68,7 +68,12 @@ final class Header implements Block
|
||||
$text = \trim($text, " \t");
|
||||
|
||||
# remove closing sequence
|
||||
$text = \rtrim(\rtrim($text, '#'), " \t");
|
||||
$removedClosing = \rtrim($text, '#');
|
||||
$lastChar = \substr($removedClosing, -1, 1);
|
||||
|
||||
if (\trim($lastChar, " \t") === '') {
|
||||
$text = \rtrim($removedClosing, " \t");
|
||||
}
|
||||
|
||||
return new self($text, $level);
|
||||
}
|
||||
|
1
tests/commonmark/45-ATX_headings.html
Normal file
1
tests/commonmark/45-ATX_headings.html
Normal file
@ -0,0 +1 @@
|
||||
<h1>foo#</h1>
|
1
tests/commonmark/45-ATX_headings.md
Normal file
1
tests/commonmark/45-ATX_headings.md
Normal file
@ -0,0 +1 @@
|
||||
# foo#
|
3
tests/commonmark/46-ATX_headings.html
Normal file
3
tests/commonmark/46-ATX_headings.html
Normal file
@ -0,0 +1,3 @@
|
||||
<h3>foo ###</h3>
|
||||
<h2>foo ###</h2>
|
||||
<h1>foo #</h1>
|
3
tests/commonmark/46-ATX_headings.md
Normal file
3
tests/commonmark/46-ATX_headings.md
Normal file
@ -0,0 +1,3 @@
|
||||
### foo \###
|
||||
## foo #\##
|
||||
# foo \#
|
Loading…
Reference in New Issue
Block a user