Only first embedded image get correctly resolved to media/branch #5421

Closed
opened 2025-11-02 06:24:27 -06:00 by GiteaMirror · 11 comments
Owner

Originally created by @CMiksche on GitHub (May 18, 2020).

Im am writing this issue because #10484 and #10506 are closed but the issue isn't fixed.

Description

When you embed images only the first embedded image is shown.

E.g.:

![Coverage Branches](./coverage/badge-branches.png)
![Coverage Lines](./coverage/badge-lines.png)
![Coverage Functions](./coverage/badge-functions.png)
![Coverage Statements](./coverage/badge-statements.png)

Only my Coverage Branches gets resolved to media/branch the other images are resolved to a src/branch URL.

I didn't had this problem with old versions from Gitea, but since i upgraded to version 1.11.5 i have this problem too ... (i think i hadn't had this problem with 1.10.4)

Screenshots

gitea_img_resolve

Originally created by @CMiksche on GitHub (May 18, 2020). Im am writing this issue because #10484 and #10506 are closed but the issue isn't fixed. ## Description When you embed images only the first embedded image is shown. E.g.: ``` ![Coverage Branches](./coverage/badge-branches.png) ![Coverage Lines](./coverage/badge-lines.png) ![Coverage Functions](./coverage/badge-functions.png) ![Coverage Statements](./coverage/badge-statements.png) ``` Only my Coverage Branches gets resolved to `media/branch` the other images are resolved to a `src/branch` URL. I didn't had this problem with old versions from Gitea, but since i upgraded to version 1.11.5 i have this problem too ... (i think i hadn't had this problem with 1.10.4) ## Screenshots ![gitea_img_resolve](https://user-images.githubusercontent.com/9869391/82208988-cdd27300-990c-11ea-81fc-49930f8fea76.JPG)
GiteaMirror added the issue/duplicate label 2025-11-02 06:24:27 -06:00
Author
Owner

@CMiksche commented on GitHub (May 18, 2020):

#10515 and the file gitea/modules/markup/html.go should be interesting for debugging i think either visitNode() don't get called on the following elements (with the wrong url path) or some condition in visitNode() is wrong?!

I don't know how big a node is and what the delimiters are which make a node but maybe the block without a break is one node and because there is strings.Replace(prefix, "/src/", "/media/", 1) it only replaces one URL (because of the "1" in the function call)?!

@CMiksche commented on GitHub (May 18, 2020): #10515 and the file gitea/modules/markup/html.go should be interesting for debugging i think either visitNode() don't get called on the following elements (with the wrong url path) or some condition in visitNode() is wrong?! I don't know how big a node is and what the delimiters are which make a node but maybe the block without a break is one node and because there is `strings.Replace(prefix, "/src/", "/media/", 1)` it only replaces one URL (because of the "1" in the function call)?!
Author
Owner

@zeripath commented on GitHub (May 19, 2020):

@CMiksche does this occur on try?

@zeripath commented on GitHub (May 19, 2020): @CMiksche does this occur on try?
Author
Owner

@CMiksche commented on GitHub (May 19, 2020):

@CMiksche does this occur on try?

What do you exactly mean?

I haven't looked further into debugging but i can definitely say there is a problem with the html markup creation. The first element also gets a link around it:

<p><a href="/<my repo>/media/branch/master/coverage/badge-branches.png" rel="nofollow"><img src="/<my repo>/media/branch/master/coverage/badge-branches.png" alt="Coverage Branches"></a>
<img src="./coverage/badge-lines.png" alt="Coverage Lines">
<img src="./coverage/badge-functions.png" alt="Coverage Functions">
<img src="./coverage/badge-statements.png" alt="Coverage Statements"></p>

But the markdown is exactly the same on all lines:

![Coverage Branches](./coverage/badge-branches.png)
![Coverage Lines](./coverage/badge-lines.png)
![Coverage Functions](./coverage/badge-functions.png)
![Coverage Statements](./coverage/badge-statements.png)
@CMiksche commented on GitHub (May 19, 2020): > @CMiksche does this occur on try? What do you exactly mean? I haven't looked further into debugging but i can definitely say there is a problem with the html markup creation. The first element also gets a link around it: ``` <p><a href="/<my repo>/media/branch/master/coverage/badge-branches.png" rel="nofollow"><img src="/<my repo>/media/branch/master/coverage/badge-branches.png" alt="Coverage Branches"></a> <img src="./coverage/badge-lines.png" alt="Coverage Lines"> <img src="./coverage/badge-functions.png" alt="Coverage Functions"> <img src="./coverage/badge-statements.png" alt="Coverage Statements"></p> ``` But the markdown is exactly the same on all lines: ``` ![Coverage Branches](./coverage/badge-branches.png) ![Coverage Lines](./coverage/badge-lines.png) ![Coverage Functions](./coverage/badge-functions.png) ![Coverage Statements](./coverage/badge-statements.png) ```
Author
Owner

@zeripath commented on GitHub (May 19, 2020):

No I mean do you have an example on try.gitea.io where this does not work.

For example both test cases on the PRs you quote above work on try.gitea.io.

I'm trying to determine if this is fixed on master/1.12 already.

@zeripath commented on GitHub (May 19, 2020): No I mean do you have an example on try.gitea.io where this does not work. For example both test cases on the PRs you quote above work on try.gitea.io. I'm trying to determine if this is fixed on master/1.12 already.
Author
Owner

@zeripath commented on GitHub (May 19, 2020):

This is fixed on 1.12 - the issue is that #10515 is not backported to 1.11 - I'll open a backport for it now.

@zeripath commented on GitHub (May 19, 2020): This **is** fixed on 1.12 - the issue is that #10515 is not backported to 1.11 - I'll open a backport for it now.
Author
Owner

@CMiksche commented on GitHub (May 19, 2020):

I created a test at https://try.gitea.io/cmiksche/test-multiple-local-badges/src/branch/master/README.md

test

I used the same markdown code which i use to display the badges next to each other on my current gitea instance and on github. Why are the badges displayed below each other?!

@CMiksche commented on GitHub (May 19, 2020): I created a test at https://try.gitea.io/cmiksche/test-multiple-local-badges/src/branch/master/README.md ![test](https://user-images.githubusercontent.com/9869391/82301029-f4011d00-99b7-11ea-99d3-081f1bf58e2f.JPG) I used the same markdown code which i use to display the badges next to each other on my current gitea instance and on github. Why are the badges displayed below each other?!
Author
Owner

@CMiksche commented on GitHub (May 19, 2020):

I used the same markdown code which i use to display the badges next to each other on my current gitea instance and on github. Why are the badges displayed below each other?!

Okay, i got it - i have to write the markdown in the next version next to each other to get that result ...

@zeripath Thanks for fixing :-)

@CMiksche commented on GitHub (May 19, 2020): > I used the same markdown code which i use to display the badges next to each other on my current gitea instance and on github. Why are the badges displayed below each other?! Okay, i got it - i have to write the markdown in the next version next to each other to get that result ... @zeripath Thanks for fixing :-)
Author
Owner

@zeripath commented on GitHub (May 19, 2020):

The problem is https://github.com/go-gitea/gitea/pull/11162 switched us to use hard breaks by default.

Looking at it I suspect that selection was incorrect - we should try to render as much as we can like GH.

@zeripath commented on GitHub (May 19, 2020): The problem is https://github.com/go-gitea/gitea/pull/11162 switched us to use hard breaks by default. Looking at it I suspect that selection was incorrect - we should try to render as much as we can like GH.
Author
Owner

@zeripath commented on GitHub (May 19, 2020):

Yup I think that PR is incorrect.

@zeripath commented on GitHub (May 19, 2020): Yup I think that PR is incorrect.
Author
Owner

@zeripath commented on GitHub (May 19, 2020):

OK it looks like GH has two different styles - Markdown files have Soft breaks, comments have Hard breaks. I've put up a PR to fix this.

@zeripath commented on GitHub (May 19, 2020): OK it looks like GH has two different styles - Markdown files have Soft breaks, comments have Hard breaks. I've put up a PR to fix this.
Author
Owner

@CMiksche commented on GitHub (Jun 2, 2020):

I tested the new version and my problems are fixed. I close this issue now ;-)

@CMiksche commented on GitHub (Jun 2, 2020): I tested the new version and my problems are fixed. I close this issue now ;-)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#5421