Make sure closing sequence is removed correctly

This commit is contained in:
Aidan Woods 2019-01-27 21:12:23 +00:00
parent 30763a0f38
commit 49dd8b113d
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
5 changed files with 14 additions and 1 deletions

View File

@ -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);
}

View File

@ -0,0 +1 @@
<h1>foo#</h1>

View File

@ -0,0 +1 @@
# foo#

View File

@ -0,0 +1,3 @@
<h3>foo ###</h3>
<h2>foo ###</h2>
<h1>foo #</h1>

View File

@ -0,0 +1,3 @@
### foo \###
## foo #\##
# foo \#