Skip to content

Commit

Permalink
Merge pull request #169 from Sylry/fix_issue_168
Browse files Browse the repository at this point in the history
Fix Line starting with * too much escaped.
  • Loading branch information
colinodell authored Dec 24, 2018
2 parents 5ca5dad + 8db7600 commit 4b95399
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Converter/HardBreakConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ public function convert(ElementInterface $element)
$next_value = $next->getValue();
if ($next_value) {
if (in_array(substr($next_value, 0, 2), array('- ', '* ', '+ '))) {
$return .= '\\';
$parent = $element->getParent();
if ($parent && $parent->getTagName() == 'li') {
$return .= '\\';
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/HtmlConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ public function test_sanitization()
$this->html_gives_markdown('<p>&gt; &gt; <b>Look</b> at me! &lt; &lt;<br />&gt; Just look at me!</p>', "\\> > **Look** at me! < < \n\\> Just look at me!");
$this->html_gives_markdown('<p>Foo<br>--<br>Bar<br>Foo--</p>', "Foo \n\\-- \nBar \nFoo--");
$this->html_gives_markdown('<ul><li>Foo<br>- Bar</li></ul>', "- Foo \n \\- Bar");
$this->html_gives_markdown('Foo<br />* Bar', "Foo \n\\* Bar");
$this->html_gives_markdown("<p>123456789) Foo and 1234567890) Bar!</p>\n<p>1. Platz in 'Das große Backen'</p>", "123456789\\) Foo and 1234567890) Bar!\n\n1\\. Platz in 'Das große Backen'");
$this->html_gives_markdown("<p>\n+ Siri works well for TV and movies<br>\n- No 4K support\n</p>", "\+ Siri works well for TV and movies \n\- No 4K support");
$this->html_gives_markdown('<p>You forgot the &lt;!--more--&gt; tag!</p>', 'You forgot the \<!--more--> tag!');
Expand Down

0 comments on commit 4b95399

Please sign in to comment.