[Bug/Feature Request] Markdown parse Relative Links #4239

Closed
opened 2025-11-02 05:43:36 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @6543 on GitHub (Nov 4, 2019).

Version: 1.11.0+dev-163-g86a44f6b4

for example:
![picture](img/00.png)
currently: https://<gitea-instance/<user>/img/00.png
how it should be: https://<gitea-instance/<user>/s/raw/branch/<branch>/img/00.png

we also should parse something like:
this: <img src="metadata/en-US/phoneScreenshots/02.png" width="200" />
to: <img src="https://<gitea-instance/<user>/s/raw/branch/<branch>/metadata/en-US/phoneScreenshots/02.png" width="200" />

since other github and gitlab? support this avter repo migration lot of broken links hapen ...

Originally created by @6543 on GitHub (Nov 4, 2019). Version: 1.11.0+dev-163-g86a44f6b4 ## Support Relative Links for example: `![picture](img/00.png)` **currently:** `https://<gitea-instance/<user>/img/00.png` **how it should be:** `https://<gitea-instance/<user>/s/raw/branch/<branch>/img/00.png` we also should parse something like: **this:** `<img src="metadata/en-US/phoneScreenshots/02.png" width="200" />` **to:** `<img src="https://<gitea-instance/<user>/s/raw/branch/<branch>/metadata/en-US/phoneScreenshots/02.png" width="200" />` since other github and gitlab? support this avter repo migration lot of broken links hapen ...
Author
Owner

@6543 commented on GitHub (Nov 4, 2019):

related to: #8813

@6543 commented on GitHub (Nov 4, 2019): related to: #8813
Author
Owner

@guillep2k commented on GitHub (Nov 5, 2019):

It can be done. I wonder what are the possible ramifications (e.g. is there any security concern?); it shouldn't use the branch but the commit sha, I guess.

@guillep2k commented on GitHub (Nov 5, 2019): It can be done. I wonder what are the possible ramifications (e.g. is there any security concern?); it shouldn't use the branch but the commit sha, I guess.
Author
Owner

@pztrn commented on GitHub (Nov 28, 2019):

In Gitlab for example specifying:

[the text](/the/url)

link will be rendered with root prefix (branch, commit SHA, etc), so URL will be valid in any mode (commit, branch viewing).

Right now it doesn't do prefixing and links are unusable (will get 404 when trying to load it). See my Gitea instance running 1.10.0 as example, "This is a snip from example configuration file" phrase, it contains unusable link.

@pztrn commented on GitHub (Nov 28, 2019): In Gitlab for example specifying: ``` [the text](/the/url) ``` link will be rendered with root prefix (branch, commit SHA, etc), so URL will be valid in any mode (commit, branch viewing). Right now it doesn't do prefixing and links are unusable (will get 404 when trying to load it). See [my Gitea instance running 1.10.0](https://sources.dev.pztrn.name/pztrn/stabonator/src/branch/master/doc/configuration.md) as example, "This is a snip from example configuration file" phrase, it contains unusable link.
Author
Owner

@stale[bot] commented on GitHub (Jan 27, 2020):

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale[bot] commented on GitHub (Jan 27, 2020): This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.
Author
Owner

@6543 commented on GitHub (Jan 27, 2020):

still not solved

@6543 commented on GitHub (Jan 27, 2020): still not solved
Author
Owner

@zeripath commented on GitHub (Jan 27, 2020):

What do we make the links absolute to and how do we determine that?

There are multiple places that markdown is rendered.

We'd either need to have a set path that a markdown path is relative to (likely different for each type of markdown) or need to detect the relative path at the time of saving and absolute it. We would need to be careful about how we send the absolute path to the renderer over the API too.

It's not an insurmountable problem but it does need a bit of thought.

@zeripath commented on GitHub (Jan 27, 2020): What do we make the links absolute to and how do we determine that? There are multiple places that markdown is rendered. We'd either need to have a set path that a markdown path is relative to (likely different for each type of markdown) or need to detect the relative path at the time of saving and absolute it. We would need to be careful about how we send the absolute path to the renderer over the API too. It's not an insurmountable problem but it does need a bit of thought.
Author
Owner

@guillep2k commented on GitHub (Feb 25, 2020):

What do we make the links absolute to and how do we determine that?

We could have different repo meta contexts. The repo meta drives the creation of links and such.

@guillep2k commented on GitHub (Feb 25, 2020): > > What do we make the links absolute to and how do we determine that? We could have different repo meta contexts. The repo meta drives the creation of links and such.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4239