Extend markdown links with renderers #11353

Closed
opened 2025-11-02 09:35:07 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @lunny on GitHub (Jul 28, 2023).

Feature Description

This proposal is inspired by #26190 and extends to all markdown rendering.

Background

Currently, Gitea has many renderers even supported third-party renderers. All these renderers will be used in Git file view, including LFS files. They can render PDFs, SVGs, CSV, asciinema, console log and many others.

Purpose

If these renderers could be used in all markdown syntax, it would be good. Then we can use them in issues, comments, wikis, and other places which support markdown syntax.

How to

Both plain internal links and markdown image internal links could invoke renderers to render the content. According to the file name extension names stored in databases or in git path, we can get to know the file type and which renderer should be chosen.

Difficulties

We can change goldmark.go and the ASTTransformer struct and when get an image or link markdown, we can replace them. But currently, the renderer will output to an io.Writer but goldmark creates tags via ast methods.

Screenshots

No response

Originally created by @lunny on GitHub (Jul 28, 2023). ### Feature Description This proposal is inspired by #26190 and extends to all markdown rendering. # Background Currently, Gitea has many renderers even supported third-party renderers. All these renderers will be used in Git file view, including LFS files. They can render PDFs, SVGs, CSV, asciinema, console log and many others. # Purpose If these renderers could be used in all markdown syntax, it would be good. Then we can use them in issues, comments, wikis, and other places which support markdown syntax. # How to Both plain internal links and markdown image internal links could invoke renderers to render the content. According to the file name extension names stored in databases or in git path, we can get to know the file type and which renderer should be chosen. # Difficulties We can change `goldmark.go` and the `ASTTransformer` struct and when get an image or link markdown, we can replace them. But currently, the renderer will output to an `io.Writer` but goldmark creates tags via ast methods. ### Screenshots _No response_
GiteaMirror added the type/proposal label 2025-11-02 09:35:07 -06:00
Author
Owner

@h3xx commented on GitHub (Aug 2, 2023):

Should also probably apply to the Markdown rendering in the Wiki pages.

Related: I found an issue with how links are rendered in the README.md view vs. the Wiki markdown view:

Given a Markdown link with the syntax [text](/h3xx/test-gitea-bug/raw/branch/main/README.md):

Suggested workaround (just for this issue): Always supply full link URL inside the Markdown.

@h3xx commented on GitHub (Aug 2, 2023): Should also probably apply to the Markdown rendering in the Wiki pages. Related: I found an issue with how links are rendered in the README.md view vs. the Wiki markdown view: Given a Markdown link with the syntax `[text](/h3xx/test-gitea-bug/raw/branch/main/README.md)`: - Wiki page (incorrect) = https://codeberg.org/h3xx/test-gitea-bug/h3xx/test-gitea-bug/raw/branch/main/README.md - README view (correct) = https://codeberg.org/h3xx/test-gitea-bug/raw/branch/main/README.md Suggested workaround (just for this issue): Always supply full link URL inside the Markdown.
Author
Owner

@wxiaoguang commented on GitHub (Nov 25, 2024):

It should have been fully fixed by recent markdown refactorings.

It follows github's rules: use current path as base path.

So /foo/bar will be resolved to:

  1. wiki: /owner/repo/wiki/foo/bar
  2. file (eg: readme): /owner/repo/{raw|src}/branch/main/foo/bar
@wxiaoguang commented on GitHub (Nov 25, 2024): It should have been fully fixed by recent markdown refactorings. It follows github's rules: use current path as base path. So `/foo/bar` will be resolved to: 1. wiki: `/owner/repo/wiki/foo/bar` 2. file (eg: readme): `/owner/repo/{raw|src}/branch/main/foo/bar`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#11353