Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
federico-ntr opened this issue May 18, 2022 · 5 comments
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail outdated/theme/markdown type/upstream This is an issue in one of Gitea's dependencies and should be reported there

Comments

@federico-ntr
Copy link

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

@silverwind
Copy link
Member

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

@federico-ntr
Copy link
Author

federico-ntr commented May 18, 2022

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
Copy link
Contributor

wxiaoguang commented May 19, 2022

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.

@wxiaoguang wxiaoguang added issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail outdated/theme/markdown type/upstream This is an issue in one of Gitea's dependencies and should be reported there and removed type/bug labels May 19, 2022
@wxiaoguang wxiaoguang 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 May 19, 2022
@federico-ntr
Copy link
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
Copy link
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)

@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail outdated/theme/markdown type/upstream This is an issue in one of Gitea's dependencies and should be reported there
Projects
None yet
Development

No branches or pull requests

3 participants