gitea: Relative links not working in asciidoc render
Description
I activated asciidoc file render based on https://docs.gitea.com/next/administration/external-renderers:
- install asciidoctor via
apt install asciidoctor
- add external render in
app.ini
[markup.asciidoc]
ENABLED = true
FILE_EXTENSIONS = .adoc,.asciidoc
RENDER_COMMAND = "asciidoctor -s -a showtitle --out-file=- -"
; Input is not a standard input but a file
IS_INPUT_FILE = false
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
:
= Network documentation
== Index
* link:general/[General]
** link:general/netplan.drawio.svg[Netplan]
** link:general/Patchpanels.adoc[Patchpanels]
** link:general/static-IPs.adoc[Static IPs]
I also tried other relative links:
= Network documentation
== Index
* link:./general/[General]
** link:./general/netplan.drawio.svg[Netplan]
** link:./general/Patchpanels.adoc[Patchpanels]
** link:./general/static-IPs.adoc[Static IPs]
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 the README.adoc
is in the folder docs
, 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
:
# Network documentation
## Index
* [General](./general/)
* [Netplan](./general/netplan.drawio.svg)
* [Patchpanels](./general/Patchpanels.md)
* [Static IPs](./general/static-IPs.md)
Working links, see screenshot:
Am I doing something wrong?
Or is there maybe an issue with asciidoctor
or the asciidoctor
command in app.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
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 1
- Comments: 26 (1 by maintainers)
I’ve updated my PoC so that I have AsciiDoc and Markdown files with the same content:
I used
docs/READ.md
instead ofdocs/README.md
to avoid auto-rendering the Markdown file.Then I compared the links rendered by Gitea in
docs/index.adoc
anddocs/index.md
. First, here is the markup for the links:docs/index.adoc
:docs/index.md
:As you can see, both implement relative links. When Gitea renders these:
docs/index.adoc
:docs/index.md
: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.
ok, thanks. I’ll start with
v1.11.0
untilv1.19.x
and do the first probe for the binary search atv1.16.1
.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? Otherwise I’ll let you all know when I have the first results.