You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
require_once'vendor/autoload.php';
useLeague\CommonMark\Environment\Environment;
useLeague\CommonMark\Extension\Autolink\AutolinkExtension;
useLeague\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
useLeague\CommonMark\MarkdownConverter;
// Define your configuration, if needed$config = [];
// Configure the Environment with all the CommonMark parsers/renderers$environment = newEnvironment($config);
$environment->addExtension(newCommonMarkCoreExtension());
// Add this extension$environment->addExtension(newAutolinkExtension());
// Instantiate the converter engine and start converting some Markdown!$converter = newMarkdownConverter($environment);
echo$converter->convert('Correct [Visit https://example.com](https://example.com)');
echo$converter->convert('Broken <a href="https://example.com">Visit https://example.com</a>');
The text was updated successfully, but these errors were encountered:
The Autolink extension follows the GFM spec which unfortunately doesn't make exceptions for autolinks found inside of HTML. You can see here that the official GFM parser behaves somewhat similarly, giving this output:
<p>
HTML <ahref="https://example.com" rel="nofollow">Visit
</a><ahref="https://example.com" rel="nofollow">https://example.com
</a></p>
So because this behavior matches both the spec and the official GFM parser I'm inclined to keep this as-is for now. But if they change this upstream in their specification I'd be glad to make this change here to remain aligned with them!
Version(s) affected
2.5
Description
In this HTML, the autolinker adds a nested
<a>
which is invalid.HTML <a href="https://example.com">Visit https://example.com</a>
Becomes
I would expect the autolinker to ignore the URl inside the anchor. For example, this produces correct HTML:
[Visit https://example.com](https://example.com)
How to reproduce
As per https://commonmark.thephpleague.com/2.5/extensions/autolinks/
The text was updated successfully, but these errors were encountered: