Skip to content
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

Issue and pull request references unexpectedly interpreted as headings #3189

Closed
2 of 7 tasks
pluehne opened this issue Dec 13, 2017 · 9 comments
Closed
2 of 7 tasks
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented topic/ui Change the appearance of the Gitea UI type/enhancement An improvement of existing functionality

Comments

@pluehne
Copy link
Contributor

pluehne commented Dec 13, 2017

Description

When writing issue or pull request comments, lines that start with a # character are unconditionally rendered as headings. This takes precedence over interpreting the # character as the beginning of an issue or pull request reference such as #3189. This was unexpected for me, because I sometimes start sentences with an issue or pull request ID.

Consider the following comment in Markdown:

This is a reference to #1.

#1 addressed this issue first.

#100000 doesn’t exist yet.

# Leading hash used with space = heading

#Leading hash without space = normal text

This is rendered by Gitea as follows:


screenshot from 2017-12-14 00-44-04


Note that the same text is treated very differently by GitHub:


screenshot from 2017-12-14 00-46-23


The reason for the difference seems to be that GitHub only considers lines starting with # as headings if the # is separated from the text by at least one whitespace.

I guess that GitHub shouldn’t serve as the only source of truth in such decisions. However, quoting CommonMark as a more objective source:

4.2 ATX headings

… The opening sequence of # characters must be followed by a space or by the end of line. …

… Note that many implementations currently do not require the space. However, the space was required by the original ATX implementation, and it helps prevent things like the following from being parsed as headings:

Example 34

#5 bolt

#hashtag

I think that this specification detail is reasonable, considering the examples mentioned above in the CommonMark document as well as the use of # for referencing issues and pull requests. For this reason, I suggest adjusting Gitea’s Markdown implementation for consistency with CommonMark.

@lafriks lafriks added the type/enhancement An improvement of existing functionality label Dec 14, 2017
@pluehne
Copy link
Contributor Author

pluehne commented Dec 19, 2017

I just read in issue #3231 that Gitea is using Blackfriday as a Markdown processor. Is this issue something I should file in the Blackfriday repository instead?

I still think it would be best to follow the Commonmark specification, but I’m not sure whether Blackfriday adheres to this standard.

@lafriks
Copy link
Member

lafriks commented Dec 19, 2017

Not really as issue/PR linkng is happening in gitea side

@stale
Copy link

stale bot commented Feb 10, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale stale bot added the issue/stale label Feb 10, 2019
@zeripath zeripath added topic/ui Change the appearance of the Gitea UI issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented and removed issue/stale labels Feb 10, 2019
@pluehne
Copy link
Contributor Author

pluehne commented Feb 28, 2019

Just to keep this issue from being discarded by the stale bot, I can still reproduce this behavior on Gitea 1.7.3. I think it would be good to have Gitea’s interpretation of Markdown match GitHub’s. I’d be willing to work on this, but I’m pretty busy with other things at the moment.

@lafriks: Can you elaborate what you mean by “PR linking is happening in Gitea side”? That’s what I would expect, can’t it be changed?

@lafriks
Copy link
Member

lafriks commented Mar 10, 2019

Just that changes need to be done in Gitea code not in blackfriday library

@samurous
Copy link

When using lists of issues, they are also sometimes interpreted as headings but not always as demonstrated in this example: https://try.gitea.io/samurous/markdown_test/src/branch/master/README.md

Here

* #1 My 1st Issue.
* #2 My 2nd Issue.


* A new List.
* With another point.

Is rendered to:
grafik

It seems only the last point will be rendered as a heading.

@guillep2k
Copy link
Member

guillep2k commented Nov 13, 2019

Issue still present in master pre 1.11 (7b75603) with blackfriday/v2:

image

@guillep2k
Copy link
Member

This can be closed as it was fixed when we migrated out of blackfriday.

https://try.gitea.io/guillep2k/charset-problem/issues/2#issuecomment-25596

@pluehne
Copy link
Contributor Author

pluehne commented Jan 8, 2020

@guillep2k: How cool, thanks for pointing this out!

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented topic/ui Change the appearance of the Gitea UI type/enhancement An improvement of existing functionality
Projects
None yet
Development

No branches or pull requests

5 participants