A markdown relative link to another markdown file with a line break in the wrong position makes the link not work #11724

Closed
opened 2025-11-02 09:45:51 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @ell1e on GitHub (Sep 25, 2023).

Description

A markdown relative link to another markdown file with a line break in the wrong position makes the link not work. See here:

https://try.gitea.io/blablablablab/BlaTest/src/branch/main/linktest.md

Affected markdown:

This is a [test to linking an external file with a relative path](
A B/filewithaverylongnamethatmightjustifybreakingapartalinktosavesomescreenspace.md).

The link isn't recognized, even though the target file actually exists inside the repository: https://try.gitea.io/blablablablab/BlaTest/src/branch/main/A%20B/filewithaverylongnamethatmightjustifybreakingapartalinktosavesomescreenspace.md I get that due to the space character in the link target (which is needed to cause this bug!) some heuristic might decide it's less likely to be a link, but that heuristic should take into account if it actually links to an existing file. Since it does link to existing file, then if in doubt it should assume it's a link.

Using %20 instead of a space works around this which is nice, but in a well-readable markdown document this is still kind of an undesired HTML artifact that shouldn't be required IMHO.

Gitea Version

1.22.0+dev-32-g7047df36d

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

See linked example above

Git Version

whatever is used on try.gitea.io

Operating System

whatever is used on try.gitea.io

How are you running Gitea?

tested on try.gitea.io

Database

None

Originally created by @ell1e on GitHub (Sep 25, 2023). ### Description A markdown relative link to another markdown file with a line break in the wrong position makes the link not work. See here: https://try.gitea.io/blablablablab/BlaTest/src/branch/main/linktest.md Affected markdown: ``` This is a [test to linking an external file with a relative path]( A B/filewithaverylongnamethatmightjustifybreakingapartalinktosavesomescreenspace.md). ``` The link isn't recognized, even though the target file actually exists inside the repository: https://try.gitea.io/blablablablab/BlaTest/src/branch/main/A%20B/filewithaverylongnamethatmightjustifybreakingapartalinktosavesomescreenspace.md I get that due to the space character in the link target (which is needed to cause this bug!) some heuristic might decide it's less likely to be a link, but that heuristic should take into account if it actually links to an existing file. Since it does link to existing file, then if in doubt it should assume it's a link. Using `%20` instead of a space works around this which is nice, but in a well-readable markdown document this is still kind of an undesired HTML artifact that shouldn't be required IMHO. ### Gitea Version 1.22.0+dev-32-g7047df36d ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots See linked example above ### Git Version whatever is used on try.gitea.io ### Operating System whatever is used on try.gitea.io ### How are you running Gitea? tested on try.gitea.io ### Database None
GiteaMirror added the issue/needs-feedback label 2025-11-02 09:45:51 -06:00
Author
Owner

@KN4CK3R commented on GitHub (Feb 28, 2024):

It's the same behaviour as Github.

@KN4CK3R commented on GitHub (Feb 28, 2024): It's the same behaviour as Github.
Author
Owner

@GiteaBot commented on GitHub (Mar 30, 2024):

We close issues that need feedback from the author if there were no new comments for a month. 🍵

@GiteaBot commented on GitHub (Mar 30, 2024): We close issues that need feedback from the author if there were no new comments for a month. :tea:
Author
Owner

@ell1e commented on GitHub (Mar 30, 2024):

What feedback would be needed?

@ell1e commented on GitHub (Mar 30, 2024): What feedback would be needed?
Author
Owner

@lunny commented on GitHub (Mar 30, 2024):

It's the same behaviour as Github.

@lunny commented on GitHub (Mar 30, 2024): > It's the same behaviour as Github.
Author
Owner

@ell1e commented on GitHub (Apr 1, 2024):

I think the best deciding factor would be if anyone writing this markdown would expect this to be a link, and whether it can cause conflicts with situations where it's not intended to be one. Having worked on some markdown parsing code myself, I didn't come across a situation yet where it makes sense not to treat this as a link.

@ell1e commented on GitHub (Apr 1, 2024): I think the best deciding factor would be if anyone writing this markdown would expect this to be a link, and whether it can cause conflicts with situations where it's not intended to be one. Having worked on some markdown parsing code myself, I didn't come across a situation yet where it makes sense *not* to treat this as a link.
Author
Owner

@GiteaBot commented on GitHub (May 1, 2024):

We close issues that need feedback from the author if there were no new comments for a month. 🍵

@GiteaBot commented on GitHub (May 1, 2024): We close issues that need feedback from the author if there were no new comments for a month. :tea:
Author
Owner

@wxiaoguang commented on GitHub (May 1, 2024):

Thank you for your feedback .... but all markdown renders work this way, I think it's good to follow the major behaviors and the standards.

@wxiaoguang commented on GitHub (May 1, 2024): Thank you for your feedback .... but all markdown renders work this way, I think it's good to follow the major behaviors and the standards.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#11724