Skip to content

Different behaviors when generating Markdown links for headings containing punctuations and other symbols #19745

@federico-ntr

Description

@federico-ntr

Description

When you use double quotes in a heading, Gitea removes them from the reference link.

Example:

If you use a header with double quotes like:

## Header with "double quotes"

Gitea generated link to that header is <URL>#header-with-double-quotes instead of <URL>#header-with-"double-quotes".
This behaviour leads to inconsistency between renderers, even between those which follow CommonMark specs. For example VSCode's Markdown preview (which follows CommonMark specs) keeps the double quotes in the links.

I reproduced the issue here

Gitea Version

1.16.8

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

Irrelevant

Operating System

Ubuntu 20.04

How are you running Gitea?

The instance runs on a virtual machine without containerization. I don't know which DB is used since I didn't installed it myself. By the way I don't think it's relevant here.

Database

No response

Activity

silverwind

silverwind commented on May 18, 2022

@silverwind
Member

Can you push that file to GitHub as well to see how they do it?

federico-ntr

federico-ntr commented on May 18, 2022

@federico-ntr
Author

Here's the repo. The behaviour seems to be the same.
I guess it's a matter of parser then. VSCode uses markdown-it, while Gitea uses goldmark. Also, I didn't find any reference to this behaviour among CommonMark's specs.

EDIT: I imported the repo from try.gitea.io, I didn't create one from scratch. I don't know if it makes any difference.

wxiaoguang

wxiaoguang commented on May 19, 2022

@wxiaoguang
Contributor

I would say it's more like a feature but not a bug, because Markdown is not a strict system, and there seems no unique standard.

There are various characters would be removed&replaced during URL generation. For example, the single quote ' in your demo file, too.

https://github.com/federico-ntr/gitea-double-quotes-test#placeholder-to-force-scrolling-on-links-click
https://try.gitea.io/federico-ntr/double-quotes-test#placeholder-to-force-scrolling-on-link-s-click

Since there is no standard, so there is no right or wrong, as long as it works.

Maybe the answer to the question could be: if there is a definition in CommonMark, then make upstream goldmark use CommonMark standard.

added
issue/needs-feedbackFor bugs, we need more details. For features, the feature must be described in more detail
type/upstreamThis is an issue in one of Gitea's dependencies and should be reported there
and removed on May 19, 2022
changed the title [-]Broken links due to removed double quotes in headings[/-] [+]Different behaviors when generating Markdown links for headings containing punctuations and other symbols[/+] on May 19, 2022
federico-ntr

federico-ntr commented on May 19, 2022

@federico-ntr
Author

I tried to search on CommonMark and I didn't find anything related to this matter. I think it's a free different choice made by goldmark and markdown-it.

I'll format my links according to what goldmark does, since it's more important for me that they are working on Gitea rather than on VSCode md preview.

wxiaoguang

wxiaoguang commented on Jun 18, 2022

@wxiaoguang
Contributor

Thank you for your confirmation. Since there is no standard, I think we can close this issue at the moment, until there are some standards in the future (I believe that on that day, there will be new issues for it)

locked and limited conversation to collaborators on May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue/needs-feedbackFor bugs, we need more details. For features, the feature must be described in more detailoutdated/theme/markdowntype/upstreamThis is an issue in one of Gitea's dependencies and should be reported there

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @silverwind@wxiaoguang@federico-ntr

        Issue actions

          Different behaviors when generating Markdown links for headings containing punctuations and other symbols · Issue #19745 · go-gitea/gitea