Skip to content

Commit 4b95399

Browse files
authored
Merge pull request #169 from Sylry/fix_issue_168
Fix Line starting with * too much escaped.
2 parents 5ca5dad + 8db7600 commit 4b95399

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Converter/HardBreakConverter.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ public function convert(ElementInterface $element)
3535
$next_value = $next->getValue();
3636
if ($next_value) {
3737
if (in_array(substr($next_value, 0, 2), array('- ', '* ', '+ '))) {
38-
$return .= '\\';
38+
$parent = $element->getParent();
39+
if ($parent && $parent->getTagName() == 'li') {
40+
$return .= '\\';
41+
}
3942
}
4043
}
4144
}

tests/HtmlConverterTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ public function test_sanitization()
290290
$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!");
291291
$this->html_gives_markdown('<p>Foo<br>--<br>Bar<br>Foo--</p>', "Foo \n\\-- \nBar \nFoo--");
292292
$this->html_gives_markdown('<ul><li>Foo<br>- Bar</li></ul>', "- Foo \n \\- Bar");
293+
$this->html_gives_markdown('Foo<br />* Bar', "Foo \n\\* Bar");
293294
$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'");
294295
$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");
295296
$this->html_gives_markdown('<p>You forgot the &lt;!--more--&gt; tag!</p>', 'You forgot the \<!--more--> tag!');

0 commit comments

Comments
 (0)