diff --git a/src/Converter/HardBreakConverter.php b/src/Converter/HardBreakConverter.php index d079d91..1be10bd 100644 --- a/src/Converter/HardBreakConverter.php +++ b/src/Converter/HardBreakConverter.php @@ -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 .= '\\'; + } } } } diff --git a/tests/HtmlConverterTest.php b/tests/HtmlConverterTest.php index cde4694..3a075ae 100644 --- a/tests/HtmlConverterTest.php +++ b/tests/HtmlConverterTest.php @@ -290,6 +290,7 @@ public function test_sanitization() $this->html_gives_markdown('

> > Look at me! < <
> Just look at me!

', "\\> > **Look** at me! < < \n\\> Just look at me!"); $this->html_gives_markdown('

Foo
--
Bar
Foo--

', "Foo \n\\-- \nBar \nFoo--"); $this->html_gives_markdown('', "- Foo \n \\- Bar"); + $this->html_gives_markdown('Foo
* Bar', "Foo \n\\* Bar"); $this->html_gives_markdown("

123456789) Foo and 1234567890) Bar!

\n

1. Platz in 'Das große Backen'

", "123456789\\) Foo and 1234567890) Bar!\n\n1\\. Platz in 'Das große Backen'"); $this->html_gives_markdown("

\n+ Siri works well for TV and movies
\n- No 4K support\n

", "\+ Siri works well for TV and movies \n\- No 4K support"); $this->html_gives_markdown('

You forgot the <!--more--> tag!

', 'You forgot the \ tag!');