xoofx / markdig

A fast, powerful, CommonMark compliant, extensible Markdown processor for .NET
BSD 2-Clause "Simplified" License
4.21k stars 444 forks source link

AutoLinks: URL that contain underscore at end are not parsed correctly #798

Closed hey-red closed 2 months ago

hey-red commented 2 months ago

Markdig 0.37.0

Example link: https://github.com/xoofx/markdig_ Result: <p><a href="https://github.com/xoofx/markdig">https://github.com/xoofx/markdig</a>_</p>

var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build();
var result = Markdown.ToHtml("https://github.com/xoofx/markdig_", pipeline);

Console.WriteLine(result); //-> <p><a href="https://github.com/xoofx/markdig">https://github.com/xoofx/markdig</a>_</p>

Github has same behaviour, so it's not a bug I guess? https://github.com/xoofx/markdig_

MihaZupan commented 2 months ago

This is intentional - some trailing punctuation characters are trimmed from autolinks. See https://github.github.com/gfm/#extended-autolink-path-validation

I'd suggest enclosing potentially problematic links in brackets manually <https://github.com/xoofx/markdig_>

hey-red commented 2 months ago

Okay. Thanks for response.