Gitea: [Bug/Feature Request] Markdown parse Relative Links

Created on 4 Nov 2019  路  7Comments  路  Source: go-gitea/gitea

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 ...

Most helpful comment

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.

All 7 comments

related to: #8813

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.

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.

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.

still not solved

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.

>

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tuxfanou picture tuxfanou  路  3Comments

kifirkin picture kifirkin  路  3Comments

thehowl picture thehowl  路  3Comments

mirhec picture mirhec  路  3Comments

internalfx picture internalfx  路  3Comments