{"action":"opened","issue":{"url":"https://api.github.com/repos/go-gitea/gitea/issues/3189","repository_url":"https://api.github.com/repos/go-gitea/gitea","labels_url":"https://api.github.com/repos/go-gitea/gitea/issues/3189/labels{/name}","comments_url":"https://api.github.com/repos/go-gitea/gitea/issues/3189/comments","events_url":"https://api.github.com/repos/go-gitea/gitea/issues/3189/events","html_url":"https://github.com/go-gitea/gitea/issues/3189","id":281937966,"number":3189,"title":"Issue and pull request references unexpectedly interpreted as headings","user":{"login":"pluehne","id":3244280,"avatar_url":"https://avatars1.githubusercontent.com/u/3244280?v=4","gravatar_id":"","url":"https://api.github.com/users/pluehne","html_url":"https://github.com/pluehne","followers_url":"https://api.github.com/users/pluehne/followers","following_url":"https://api.github.com/users/pluehne/following{/other_user}","gists_url":"https://api.github.com/users/pluehne/gists{/gist_id}","starred_url":"https://api.github.com/users/pluehne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pluehne/subscriptions","organizations_url":"https://api.github.com/users/pluehne/orgs","repos_url":"https://api.github.com/users/pluehne/repos","events_url":"https://api.github.com/users/pluehne/events{/privacy}","received_events_url":"https://api.github.com/users/pluehne/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-12-13T23:58:35Z","updated_at":"2017-12-13T23:58:35Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"- Gitea version (or commit ref): 1.3.1 and b6d2243 (try.gitea.io)\r\n- Git version: 2.15.1\r\n- Operating system: Arch Linux\r\n- Database (use `[x]`):\r\n  - [x] PostgreSQL\r\n  - [ ] MySQL\r\n  - [ ] MSSQL\r\n  - [ ] SQLite\r\n- Can you reproduce the bug at https://try.gitea.io:\r\n  - [x] Yes: https://try.gitea.io/test/2017-12-14-debug-leading-hash/issues/1#issuecomment-1620\r\n  - [ ] No\r\n  - [ ] Not relevant\r\n- Log gist: not relevant\r\n\r\n## Description\r\n\r\nWhen 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.\r\n\r\nConsider the following comment in Markdown:\r\n\r\n```\r\nThis is a reference to #1.\r\n\r\n#1 addressed this issue first.\r\n\r\n#100000 doesn’t exist yet.\r\n\r\n# Leading hash used with space = heading\r\n\r\n#Leading hash without space = normal text\r\n```\r\n\r\nThis is rendered by Gitea as follows:\r\n\r\n--------\r\n\r\n![screenshot from 2017-12-14 00-44-04](https://user-images.githubusercontent.com/3244280/33968393-f18c88cc-e067-11e7-89e8-2ed090a1538e.png)\r\n\r\n--------\r\n\r\nNote that the same text is treated very differently by GitHub:\r\n\r\n--------\r\n\r\n![screenshot from 2017-12-14 00-46-23](https://user-images.githubusercontent.com/3244280/33968450-3c95f57e-e068-11e7-82f4-5cfdea696754.png)\r\n\r\n--------\r\n\r\nThe 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.\r\n\r\nI guess that GitHub shouldn’t serve as the only source of truth in such decisions. However, quoting [CommonMark as a more objective source](http://spec.commonmark.org/0.27/#atx-headings):\r\n\r\n> ### 4.2 ATX headings\r\n> … The opening sequence of # characters must be followed by a space or by the end of line. …\r\n>\r\n> … 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:\r\n>\r\n> #### Example 34\r\n> ```\r\n> #5 bolt\r\n>\r\n> #hashtag\r\n> ```\r\n\r\nI 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."}}
{"actor":{"display_login":"pluehne"}}