Make autolinking issues and PRs in markdown files configurable #14153

Closed
opened 2025-11-02 11:04:37 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @neonmoe on GitHub (Feb 18, 2025).

Originally assigned to: @wxiaoguang on GitHub.

Description

Previously, in at least 1.19.3, linking to PRs and issues with e.g. #123 in a markdown file resulted in them being autolinked when the markdown was rendered, but in 1.23.3 (and the dev version at demo.gitea.com), this is no longer the case.

I reproduced this in a testing instance with the following docker compose (and whatever defaults it gave in the install step), just changing the version from 1.19.3 to 1.23.3.

networks:
  gitea_testing:
    external: false

services:
  server:
    image: docker.io/gitea/gitea:1.19.3
    container_name: gitea_testing
    environment:
      - USER_UID=1000
      - USER_GID=1000
    restart: always
    networks:
      - gitea_testing
    volumes:
      - ./gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "4480:3000"
      - "4422:22"

And just for completeness, here's the README.md seen in the screenshot:

linking issue #1

Even if this is intentional, it would be nice if the previous behavior could be re-enabled with a configuration option. I couldn't find any issues, PRs, or release notes about this topic.

Reproduced on demo.gitea.com: https://demo.gitea.com/neonmoe/testing-repo

Gitea Version

1.23.3

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

Image

Git Version

No response

Operating System

No response

How are you running Gitea?

Both demo.gitea.com and using the docker-compose config I pasted in the main issue description.

Database

SQLite

Originally created by @neonmoe on GitHub (Feb 18, 2025). Originally assigned to: @wxiaoguang on GitHub. ### Description Previously, in at least 1.19.3, linking to PRs and issues with e.g. `#123` in a markdown file resulted in them being autolinked when the markdown was rendered, but in 1.23.3 (and the dev version at demo.gitea.com), this is no longer the case. I reproduced this in a testing instance with the following docker compose (and whatever defaults it gave in the install step), just changing the version from 1.19.3 to 1.23.3. ```yaml networks: gitea_testing: external: false services: server: image: docker.io/gitea/gitea:1.19.3 container_name: gitea_testing environment: - USER_UID=1000 - USER_GID=1000 restart: always networks: - gitea_testing volumes: - ./gitea:/data - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro ports: - "4480:3000" - "4422:22" ``` And just for completeness, here's the README.md seen in the screenshot: ```md linking issue #1 ``` Even if this is intentional, it would be nice if the previous behavior could be re-enabled with a configuration option. I couldn't find any issues, PRs, or release notes about this topic. Reproduced on demo.gitea.com: https://demo.gitea.com/neonmoe/testing-repo ### Gitea Version 1.23.3 ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots ![Image](https://github.com/user-attachments/assets/34ac6031-0f64-4d75-a145-51694f644352) ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? Both demo.gitea.com and using the docker-compose config I pasted in the main issue description. ### Database SQLite
GiteaMirror added the type/proposal label 2025-11-02 11:04:37 -06:00
Author
Owner

@wxiaoguang commented on GitHub (Feb 19, 2025):

Thank you for the report, will take a look

@wxiaoguang commented on GitHub (Feb 19, 2025): Thank you for the report, will take a look
Author
Owner

@wxiaoguang commented on GitHub (Feb 19, 2025):

It seems to be a change in 1.22 or early (but not 1.23). Need to figure out why ......

Image

@wxiaoguang commented on GitHub (Feb 19, 2025): It seems to be a change in 1.22 or early (but not 1.23). Need to figure out why ...... <details> ![Image](https://github.com/user-attachments/assets/a1a2e736-e5ec-4a3e-adb5-05a129893dec) </details>
Author
Owner

@wxiaoguang commented on GitHub (Feb 19, 2025):

The change is from #26365, to match GitHub behavior.

The workaround is "using full URL link" ......

See GitHub:

Image

@wxiaoguang commented on GitHub (Feb 19, 2025): The change is from #26365, to match GitHub behavior. The workaround is "using full URL link" ...... See GitHub: ![Image](https://github.com/user-attachments/assets/0262e126-98c6-4082-a669-70fc2581fa8a)
Author
Owner

@neonmoe commented on GitHub (Feb 19, 2025):

That's understandable, but would it be possible to add a configuration option for this? It would be quite a lot of work to manually replace all the autolinks with a real link, and we'd need to update our development tooling to generate real links. It was very convenient how e.g. commit messages and PR titles could previously be copied as-is into a changelog file, and it'd just work.

@neonmoe commented on GitHub (Feb 19, 2025): That's understandable, but would it be possible to add a configuration option for this? It would be quite a lot of work to manually replace all the autolinks with a real link, and we'd need to update our development tooling to generate real links. It was very convenient how e.g. commit messages and PR titles could previously be copied as-is into a changelog file, and it'd just work.
Author
Owner

@wxiaoguang commented on GitHub (Feb 19, 2025):

I could try if I get time.


If you are able to build your own binary program, you could apply this patch (only 1 line):

diff --git a/models/repo/repo.go b/models/repo/repo.go
index c5060a419f..d1fd8d4982 100644
--- a/models/repo/repo.go
+++ b/models/repo/repo.go
@@ -537,6 +537,7 @@ func (repo *Repository) ComposeDocumentMetas(ctx context.Context) map[string]str
        // does document(file) need the "teams" and "org" from common metas?
        metas := maps.Clone(repo.composeCommonMetas(ctx))
        metas["markdownLineBreakStyle"] = "document"
+       metas["markupAllowShortIssuePattern"] = "true"
        return metas
 }

Then

TAGS="bindata sqlite sqlite_unlock_notify" make build

Then mount the docker volume to host:

    volumes:
      - ./gitea-app/gitea:/app/gitea
      - (others....)

Then use your own binary to replace ./gitea-app/gitea and restart the container.

@wxiaoguang commented on GitHub (Feb 19, 2025): I could try if I get time. ---- If you are able to build your own binary program, you could apply this patch (only 1 line): ```diff diff --git a/models/repo/repo.go b/models/repo/repo.go index c5060a419f..d1fd8d4982 100644 --- a/models/repo/repo.go +++ b/models/repo/repo.go @@ -537,6 +537,7 @@ func (repo *Repository) ComposeDocumentMetas(ctx context.Context) map[string]str // does document(file) need the "teams" and "org" from common metas? metas := maps.Clone(repo.composeCommonMetas(ctx)) metas["markdownLineBreakStyle"] = "document" + metas["markupAllowShortIssuePattern"] = "true" return metas } ``` Then `TAGS="bindata sqlite sqlite_unlock_notify" make build` Then mount the docker volume to host: ``` volumes: - ./gitea-app/gitea:/app/gitea - (others....) ``` Then use your own binary to replace `./gitea-app/gitea` and restart the container.
Author
Owner

@neonmoe commented on GitHub (Feb 19, 2025):

Thank you very much for the patch, that works great!

@neonmoe commented on GitHub (Feb 19, 2025): Thank you very much for the patch, that works great!
Author
Owner

@wxiaoguang commented on GitHub (Apr 4, 2025):

-> Fix markdown render behaviors #34122

@wxiaoguang commented on GitHub (Apr 4, 2025): -> Fix markdown render behaviors #34122
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#14153