go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
45.11k stars 5.49k forks source link

Extend markdown links with renderers #26195

Open lunny opened 1 year ago

lunny commented 1 year ago

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

h3xx commented 1 year ago

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.