github / cmark-gfm

GitHub's fork of cmark, a CommonMark parsing and rendering library and program in C
Other
893 stars 173 forks source link

Bug: Markdown links don't work when the the link contents are an image asset hosted on GitHub #342

Open DenverCoder1 opened 1 year ago

DenverCoder1 commented 1 year ago

This is an issue I noticed with markdown on Github.com. I do not know if it is also an upstream issue. I also opened a discussion in the GitHub community.

Description

Markdown links in repositories, issues, discussions, and other locations don't link to the correct location when the the link is around an image hosted on GitHub, for example when pasted into the input box to get a https://github.com/.../.../assets/... url.

Note, most other images do work including GitHub asset urls such as https://github.com/DenverCoder1.png.

Example 1 - :heavy_check_mark: Working

This example correctly links to https://github.com/DenverCoder1 when clicked and displays the image properly.

Markdown

[![Example 1](https://github.com/DenverCoder1.png?size=60)](https://github.com/DenverCoder1)

Preview

Example 1

Output

<a href="https://github.com/DenverCoder1"><img src="https://github.com/DenverCoder1.png?size=60" alt="Example 1" style="max-width: 100%;"></a>

Example 2 - :x: Not working

This example should also link to https://github.com/DenverCoder1 but instead it goes to https://github.com/community/community/assets/20955511/22851a85-cfb8-4816-b6e5-f2044f2b06ab.

Markdown

[![Example 2](https://github.com/community/community/assets/20955511/22851a85-cfb8-4816-b6e5-f2044f2b06ab)](https://github.com/DenverCoder1)

Preview

Example 2

Expected output

<a href="https://github.com/DenverCoder1"><img src="https://github.com/community/community/assets/20955511/22851a85-cfb8-4816-b6e5-f2044f2b06ab" alt="Example 2" style="max-width: 100%;"></a>

Actual ouput

<a href="https://github.com/DenverCoder1"><gh:secured-asset-reference resource_type="UserAsset" resource_id="254099377"></gh:secured-asset-reference></a>
<a target="_blank" rel="noopener noreferrer" href="https://github.com/community/community/assets/20955511/22851a85-cfb8-4816-b6e5-f2044f2b06ab"><img src="https://github.com/community/community/assets/20955511/22851a85-cfb8-4816-b6e5-f2044f2b06ab" alt="Example 2" style="max-width: 100%;"></a>