Skip to content

Issue and pull request references unexpectedly interpreted as headings #3189

Closed
@pluehne

Description

@pluehne

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue/confirmedIssue has been reviewed and confirmed to be present or accepted to be implementedtopic/uiChange the appearance of the Gitea UItype/enhancementAn improvement of existing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions