thephpleague / html-to-markdown

Convert HTML to Markdown with PHP
MIT License
1.77k stars 205 forks source link

links with url as anchor text not working #133

Closed chorsnell closed 7 years ago

chorsnell commented 7 years ago

I am having issues converting the following, which seems to be because the URL is the anchor text. If I change the anchor to a non URL it works.

$html = '<h1>yoyo</h1><p>See <a href="https://github.com/quilljs/quill/issues/81" target="_blank">https://github.com/quilljs/quill/issues/81</a></p>';

$converter = new HtmlConverter();
$markdown = $converter->convert($html);

echo $markdown;

This returns

yoyo
====

See <https://github.com/quilljs/quill/issues/81>

Seems to be converting ok over here - https://domchristie.github.io/to-markdown/

Interesting, I am getting a very similar issue in another PHP library over here - https://github.com/Elephant418/Markdownify/issues/23

colinodell commented 7 years ago

When both the href and text are the same, we convert that to Markdown's autolink syntax. Based on the example you sent, it seems like this is working as intended.

chorsnell commented 7 years ago

@colinodell thanks for the quick response, wasn't aware that was a thing :+1: