mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-12 02:24:21 -05:00
External renderers and included files #3065
Open
opened 2025-11-02 04:59:27 -06:00 by GiteaMirror
·
22 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16.1
v1.16.0
v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2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#3065
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @gautaz on GitHub (Mar 18, 2019).
Gitea version 8670dec built with: bindata, sqlitegit version 2.15.3[x]):Description
Hello,
I'm currently using
asciidoctorto render asciidoc readme files. These files contains include directives that the current process is unable to render correctly. The failure message displayed isUnresolved directive in <stdin> - include::filepath[]My current understanding is that
asciidoctoris unable to find the included file from the environment it is run within. This seems pretty obvious as the content to render is given through the standard input.Is there a way to circumvent this issue ?
What is the environment in which an external renderer is run within in order to produce the displayed markup ?
@lunny commented on GitHub (Mar 18, 2019):
Could you have a similiar config with below?
@gautaz commented on GitHub (Mar 18, 2019):
This is in fact my current configuration (taken as is from here).
@gautaz commented on GitHub (Apr 2, 2019):
@lunny Is there a way to pass
asciidoctora path to the project sources by using the--base-diroption?@stale[bot] commented on GitHub (Jun 7, 2019):
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
@gautaz commented on GitHub (Jun 7, 2019):
Sorry to insist but the current way to integrate external renderers by using the standard input to feed them will not work for any renderer using other files from the project (for instance in case of document sources including project files).
It seems to me that Asciidoctor is just an example among others.
As Gitea is a collaborative project, I also totally understand that this issue cannot be resolved for now unless someone skilled enough has the time to handle it but I do not understand how closing automatically the issue will help.
Am I the only one thinking that the current external renderer integration method cannot cover all use cases?
Perhaps an agreement on this point is necessary as a preamble to adding an item in the Gitea roadmap?
@zeripath commented on GitHub (Jun 7, 2019):
Why don't you write a script that will set up the environment correctly for ascidoctor?
You can send the stdin to a temporary file run ascidoctor on that or deal with the input file and then cat the output back out.
@gautaz commented on GitHub (Jun 7, 2019):
@zeripath Are you saying that this script would be executed instead of asciidoctor and will hand the missing elements over to asciidoctor once it gathered all the missing pieces?
How is this script supposed to access the other files of the git repository where the document source is located? This script will get the same data than asciidoctor, that is a standard input with the content of the document source to process but no information about where to get the other parts of the git repository.
@stale[bot] commented on GitHub (Aug 7, 2019):
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
@Jim-Bar commented on GitHub (Sep 26, 2019):
Interested as well in a solution to this problem. Including other files doesn't work with e.g. AsciiDoc which is unfortunate because it's a great feature. As such, our documentation cannot be properly viewed from Gitea.
@gautaz Thanks for opening this issue ;)
@shomodj commented on GitHub (May 1, 2021):
Also interested in solution for this...
Can we fund this?
@raylee commented on GitHub (Mar 2, 2022):
I have the same issue, but for a different file format. If the external renderer could be passed the path to the git repository as a substitution or environment variable in RENDER_COMMAND, the rest could be handled outside of Gitea.
Something like
would work fine. (Or if the user is running on Windows, they could use the %VAR% form for the command.)
The external renderer would then be able to check out the necessary supporting files which are needed.
@lunny commented on GitHub (Mar 3, 2022):
OK. So I think the requirement is
Expose related renderer context information as variables for the RENDER_COMMAND.@lunny commented on GitHub (Mar 3, 2022):
Let's make a sample. Assume we have a git directory in a repository like this.
Then I want to display the logo image in the HTML file if I enabled the third-party renderer for
.htmlextensions.Is that you want?
@raylee commented on GitHub (Mar 3, 2022):
For my use case, the renderer needs to get at the git history to show summaries of what changed. So while this bug itself is about related files, I need to rummage around the git history. Hence my request for an environment variable (or command substitution) of a path to the repo.
This would address both my use case (looking back in time), as well as this bug's request (finding supporting files).
@johnnybubonic commented on GitHub (Mar 6, 2022):
Just hit this one myself. :/ Bummer.
How is the render executed? Is a checkout performed or does it pull the browser-requested file specifically from git? If the former, this should be fairly easy - just provide a RENDER_CMD directive in
markup.*ofapp.inithat provides the directory of the cloned repository as an env var. A couple wrapper scripts or programs and rendering can be performed however desired. I suspect this is not how it's done, however, as that'd be a nightmare to implement for multiple requests and refs in parallel.If the latter, however... it's not really possible, as gitea itself would need to be parser-aware of each markup language they wanted to support, which defeats the entire purpose of a "modular" system like it currently is designed to be.
So I'd personally probably classify this as WONTFIX because I suspect it's impossible.
For those needing a solution, however, how I've implemented this in the past is simply with a pre-commit hook that just renders to e.g. an HTML file (I'm a heavy user of Asciidoctor). Unfortunate that it then needs to be on every machine though. There are some proposed solutions (including setting
DISABLE_GIT_HOOKStofalse).I find that https://github.com/gabyx/Githooks is probably the most elegant approach.
@lunny commented on GitHub (Mar 6, 2022):
Since you could do that in markdown with
to render an image, I don't think this is not impossible for images. We just need to parse image elements and replace the relative link to Gitea's file raw link.For CSS, Javascript, we need to assess whether there are some security problem.
@johnnybubonic commented on GitHub (Mar 6, 2022):
Markdown is not the only text markup out there. This bug was opened initially for Asciidoctor.
@lunny commented on GitHub (Mar 6, 2022):
We already have two environment could be used.
see https://docs.gitea.io/en-us/config-cheat-sheet/#markup-markup
@ExplodingDragon commented on GitHub (May 10, 2022):
有一种临时替代的方法,但此方法有安全隐患,如果处理不当将导致严重的安全问题
There is a temporary workaround, but this method has security implications and can lead to serious security issues if not handled properly.
/usr/bin/asciidoc-format,然后执行chmod +x /usr/bin/asciidoc-format/usr/bin/asciidoc-format, then executechmod +x /usr/bin/asciidoc-format@luolong commented on GitHub (Mar 23, 2023):
The root issue seems to be that when rendering external documents from standard input, the renderer has no idea how to find included resources.
For example, Asciidoc includes allow rendering the content of the included document inline within the rendered document.
When an asciidoctor command line utility starts rendering from stdin and encounters an
include:directive, it tries to read the referred document and replace the directive with a rendered content of the included file.Because stdin has no concept of file paths, the renderer fails (semi-gracefully) and renders the failure to include a requested file.
It seems to me that rendering of documents needs to be extended to allow for external renderer to request documents (based on relative paths) as they process the rendering request.
An example.
Given two asciidoc files:
README.adoc:doc/install.adoc:Then final rendering of the
READMe.adocfile should look as as though the stdin contained the following:@sehari24jam commented on GitHub (Jun 20, 2024):
Recently I have successfuly configured app.ini to display included asciidoctor files, with some notes.
Let said the ROOT_URL of gitea is
https://gitea.my.local.Then
app.inishall have:So the trick is to override
docdirattribute with URL pointing to ROOT_URL + $GITEA_PREFIX_RAW variable. Explicit docdir is needed, because running asciidoctor-renderer against stdin would have no idea where the docdir.And modify the related asciidoc files to have
{docdir}as prefix.Let said
README.adoc:And
include/sub.adoc:Adding prefix
{docdir}will also work under asciidoctor cli. So doing this will make the files both work in gitea-renderer and asciidoctor-cli.Repository visibility setting need to be set to non-private (under repo setting).
Due asciidoctor-renderer need to access
ROOT_URL$GITEA_PREFIX_RAW/include/sub.adocwithout restriction.Use of gitea user-token (https://token@domain) does not work for asciidoctor-renderer.
@luolong commented on GitHub (Jun 21, 2024):
That is a clever hack, but adding
{docdir}to every link seems onwieldy.I've been playing around in my head with the idea of implementing a virtual filesystem inside gitea, serving content of the current repository commit directly from the git tree and using that for the asciidoctor, but I am no Go expert and I wouldn't know if that scheme would work with asciidoctor invocation at all.
But if that would work, it would help tremendously with asciidoctor rendering.