-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relative links not working in asciidoc render #26203
Comments
Currently I found another strange thing: It is not working as described above when clicking the But when I go to the Link to Now (for some reason) relative links in So at the end I'm not sure if this is really a asciidoc render issue or a general behavior of |
I have exactly the same issue on two different Gitea's. tl;dr of the above is
With
|
Because GitHub must have had the same issue (I guess), I found github/markup#1039 which might be a good start so find out, how it was solved there. Hopefully then also Maybe @mojavelinux could as least give a hint on how to solve the issue here (as well) ... |
Please don't @ me in projects I'm not involved with. You are welcome to ask in the Asciidoctor project chat at https://chat.asciidoctor.org. |
@deparcus, do you want to ask for help in the asciidoctor chat since you started the issue? If not, please let me know and I'll try to do it myself. |
@Mo-Gul : Of course I could try, but I think you might be able to explain the details and background probably much better than I could. |
@deparcus, I'd say you give it a first try and can give a hint to this issue, which I guess is a good start. Then you can add the link to the chat here so I (and others) can follow the conversation. If it is useful that I add my few cents I'll join it ... |
@Mo-Gul : There seems to be a solution in the asciidoctor chat. Looks like How can we proceed here? |
The bug is that Gitea does not add a trailing slash in links to repos/folders. Consider this situation: The user views Relative links in the auto-rendered What "folder" is that? If Gitea adds the trailing slash to repo/folder links, then when the user clicks the You can manually add a trailing slash (and reload the page) to any repo/folder view and click a relative link in an auto-generated I used |
Seems you are right and the "same" problem exists for markdown files as well. See #18592. |
hmm... as I wrote in my first to posts, I cannot reproduce the behaviour when using |
I can confirm that with Gitea v1.19.0 a from a README.md in the docs folder work to another MD file in the docs folder works regardless of how the README.md is shown. Unfortunately, I couldn't find out why so far. But maybe this has something to do with the Slugify rules for Gitea. @deparcus, could you setup some dummy Gitea servers with previous versions so we could drill down since when the links are working? Maybe then it is easier to find out exactly why/how this is working for markdown files and thus there hopefully is a good start for a asciidoctor solution. |
@Mo-Gul : sure. Do you have a feeling from which version I should start? Then I would start updating version by version and try to find out when the discussed Markdown links are working. |
Not really, but I guess I would start with v1.11 and then do a "binary search" when it isn't working there up to <v1.19 where it is working. Maybe it also a good idea to start with v1.16.1 which release date is before the above mentioned bug report from me. Good luck!! |
ok, thanks. I'll start with Currently I have limited access to the internet (and cannot download large files) due to a few days off. So I can start checking the issues earliest at end of september / beginning of october. If this is too late, then probably somebody else could jump in? |
@Mo-Gul : Sorry for answering that late. I now set up a gitea 1.11.0 instance based on docker-compose to test the relative md-links. To me it seems that it's working in that version, but I want to doublecheck if I'm testing the right things, before I continue playing around with the version (what is really easy with docker). Attached you find a zip-file of my testing repo: relative-md-links-master.zip Here's my version: "3"
networks:
gitea:
external: false
volumes:
gitea:
driver: local
mysql:
driver: local
services:
server:
image: gitea/gitea:1.11.0
container_name: gitea
environment:
- USER_UID=1000
- USER_GID=1000
- GITEA__database__DB_TYPE=mysql
- GITEA__database__HOST=db:3306
- GITEA__database__NAME=gitea
- GITEA__database__USER=gitea
- GITEA__database__PASSWD=gitea
restart: always
networks:
- gitea
volumes:
- gitea:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "222:22"
depends_on:
- db
db:
image: mysql:8
restart: always
environment:
- MYSQL_ROOT_PASSWORD=gitea
- MYSQL_USER=gitea
- MYSQL_PASSWORD=gitea
- MYSQL_DATABASE=gitea
networks:
- gitea
volumes:
- mysql:/var/lib/mysql Setup instructions:
It would be nice if you can confirm:
Thanks a lot :) |
I don't have much of a clue about docker, so I trust whatever you are doing. But maybe a bit simpler test is Good luck finding the Gitea version where the link isn't working (properly) any more!! |
I did some more testing, but still got no real result. First, I found out that binary testing works not that good when descreasing versions. So everytime the database had to be cleared and initial setup and repo creation has to be done. So I first tested:
Then I decided just to go versions up and test every .0 version. What I did:
Result:
So to be honest I do not know how to proceed here. Probably I'm testing something wrong (that's why I asked for a doublecheck ;-) ). I think it might be more efficient to search in the code for the hint how to handle asciidoc links similar to md links. Sorry for not getting a better result here. But btw: I was really interesting how gitea look, features and console log output changed from the beginning to the latest version :-) Due to docker the test with version switch (when going up) can be done really quickly. |
Since I currently can't setup (easily) other Gitea's myself and I trust your results, I agree that this maybe is a dead end. |
Sorry, me neither, because I also don't know the programming language. |
That is the obvious way, but I have not much hope here, because up to now nobody else than jtiee commented here. I'd be happy to proven wrong. |
Sorry @jtiee , I did not see, that you were the one writing in AsciiDoctor Chat. |
I've updated my PoC so that I have AsciiDoc and Markdown files with the same content:
I used Then I compared the links rendered by Gitea in
As you can see, both implement relative links. When Gitea renders these:
As you can see, the rendered Asciidoc files have the relative links as defined in the file. Whereas the Markdown files have an absolute link from the document root. That's the problem. I don't know if Gitea is making the rendered Markdown links absolute or whether the Markdown renderer used by Gitea is doing that. But nothing is making the AsciiDoc links absolute. Either Gitea needs to add slashes after folder names, or it needs to make relative links absolute in rendered AsciiDoc files. Adding the slashes after folder names would avoid this issue for any other auto-rendered files. And there's no reason both solutions couldn't be applied. |
There are two envs to help with your asciidoc command. About how to use, please see https://docs.gitea.com/next/administration/config-cheat-sheet?_highlight=gitea_prefix_src#markup-markup |
@lunny, I have stumbled over these variables at different places so far, e.g. also at #6359 (comment), but unfortunately I couldn't find out how exactly to use these (with a concrete example). I just gave it some tries with
but unfortunately none of them worked. What am I doing wrong it these environment variables (really) should be able to solve the problem? |
Description
I activated asciidoc file render based on https://docs.gitea.com/next/administration/external-renderers:
apt install asciidoctor
app.ini
Then I created a branch in one of my repositories and migrated Markdown files to adoc files.
In the main
*.adoc
file I use relative links to link to other*.adoc
files.Therefore I followed the asciidoctor documentation.
Example file
docs/README.adoc
:I also tried other relative links:
In VSCode the links are working and I can navigate to the files in subdirectories by clicking the link in the main file.
The link is interpreted as it starts from the root of the branch. So
/docs/
is missing. But as theREADME.adoc
is in the folderdocs
, the links should be interpreted as starting from there.This is shown in the screenshot below:
I discovered that issue also in another repository, where I first tried it.
When I use Markdown (currently my master branch), everything works as is should.
Example file
doc/README.md
:Working links, see screenshot:
Am I doing something wrong?
Or is there maybe an issue with
asciidoctor
or theasciidoctor
command inapp.ini
?Would be great if anybody could help me.
Gitea Version
1.20.1
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
Git Version
2.30.2
Operating System
Raspbian/Debian 11.7
How are you running Gitea?
Local install with binary and systemd service.
Database
MySQL
The text was updated successfully, but these errors were encountered: