Gitea: Only first embedded image get correctly resolved to media/branch

Created on 18 May 2020  路  11Comments  路  Source: go-gitea/gitea

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

revieweduplicate reviewefixed

Most helpful comment

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.

All 11 comments

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 does this occur on try?

@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)

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.

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.

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?!

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 :-)

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.

Yup I think that PR is incorrect.

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.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

flozz picture flozz  路  3Comments

jorise7 picture jorise7  路  3Comments

internalfx picture internalfx  路  3Comments

kifirkin picture kifirkin  路  3Comments

lunny picture lunny  路  3Comments