diff --git a/src/Converter/LinkConverter.php b/src/Converter/LinkConverter.php index f0765f3..74b49a7 100644 --- a/src/Converter/LinkConverter.php +++ b/src/Converter/LinkConverter.php @@ -15,7 +15,7 @@ public function convert(ElementInterface $element) { $href = $element->getAttribute('href'); $title = $element->getAttribute('title'); - $text = trim($element->getValue()); + $text = trim($element->getValue(), "\t\n\r\0\x0B"); if ($title !== '') { $markdown = '[' . $text . '](' . $href . ' "' . $title . '")'; diff --git a/tests/HtmlConverterTest.php b/tests/HtmlConverterTest.php index 24a793b..7c8a23c 100644 --- a/tests/HtmlConverterTest.php +++ b/tests/HtmlConverterTest.php @@ -102,6 +102,8 @@ public function test_anchor() $this->html_gives_markdown('http://modernnerd.net', ''); $this->html_gives_markdown('Modern Nerd', '[Modern Nerd](http://modernnerd.net "Title")'); $this->html_gives_markdown('Modern Nerd Modern Nerd', '[Modern Nerd](http://modernnerd.net "Title") [Modern Nerd](http://modernnerd.net "Title")'); + $this->html_gives_markdown('

Modern Nerd

', '[### Modern Nerd](http://modernnerd.net)'); + $this->html_gives_markdown('The Modern Nerd (MN)', 'The [Modern Nerd ](http://modernnerd.net)(MN)'); $this->html_gives_markdown('alt text', '[![alt text](/path/img.jpg "Title")](http://modernnerd.net/ "Title")'); $this->html_gives_markdown('alt text Test', '[![alt text](/path/img.jpg "Title") Test](http://modernnerd.net/ "Title")');