mirror of
https://github.com/go-gitea/gitea
synced 2024-12-23 00:54:28 +00:00
Pass link prefixes to external markup parsers (#5201)
* Pass environment variables for URL prefixes to external markup parser Signed-off-by: Nicolas Lenz <nicolas@eisfunke.com> * Document external markup link prefix environment variables Signed-off-by: Nicolas Lenz <nicolas@eisfunke.com> * Run format on link prefix changes Signed-off-by: Nicolas Lenz <nicolas@eisfunke.com>
This commit is contained in:
parent
e61c6cd3db
commit
220ee6ae42
@ -359,6 +359,10 @@ IS_INPUT_FILE = false
|
||||
- RENDER\_COMMAND: External command to render all matching extensions.
|
||||
- IS\_INPUT\_FILE: **false** Input is not a standard input but a file param followed `RENDER_COMMAND`.
|
||||
|
||||
Two special environment variables are passed to the render command:
|
||||
- `GITEA_PREFIX_SRC`, which contains the current URL prefix in the `src` path tree. To be used as prefix for links.
|
||||
- `GITEA_PREFIX_RAW`, which contains the current URL prefix in the `raw` path tree. To be used as prefix for image paths.
|
||||
|
||||
## Other (`other`)
|
||||
|
||||
- `SHOW_FOOTER_BRANDING`: **false**: Show Gitea branding in the footer.
|
||||
|
5
modules/markup/external/external.go
vendored
5
modules/markup/external/external.go
vendored
@ -76,6 +76,11 @@ func (p *Parser) Render(rawBytes []byte, urlPrefix string, metas map[string]stri
|
||||
}
|
||||
|
||||
cmd := exec.Command(commands[0], args...)
|
||||
cmd.Env = append(
|
||||
os.Environ(),
|
||||
"GITEA_PREFIX_SRC="+urlPrefix,
|
||||
"GITEA_PREFIX_RAW="+strings.Replace(urlPrefix, "/src/", "/raw/", 1),
|
||||
)
|
||||
if !p.IsInputFile {
|
||||
cmd.Stdin = rd
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user