Defect #40715
closedWiki (markdown syntax): "Edit this section" does not extract ATX headings correctly
Description
Abstraction¶
"Edit this section" in Wiki with the Markdown syntax does not extract ATX headings correctly.
ATX headings:
The current trunk(rev.22841) and v5.0.2 extracts it by the regexp '#+.+', but this would not be sufficient.
Especially, since it does not consider the following condition, it mishandles ticket references such as "#11111" or "##11111".
The opening sequence of # characters must be followed by a space or by the end of line.
I explain the details in "How to reproduce".
Note: the regexps about extracting ATX headings:
How to reproduce¶
Prepare Wiki with the Markdown syntax as follows.

We can click each section's "Edit this section" button (surrounded by red rectangles in the image above).
However, we can't edit each section correctly since the ticket reference "##1" is wrongly detected as a level 2 section.
When clicking the button of "Section A":
(URI: "Wiki/edit?section=2")

When clicking the button of "Section B":
(URI: "Wiki/edit?section=3")

The expected result when clicking the button of "Section A":
The expected result when clicking the button of "Section B":
Environment¶
$ RAILS_ENV=development bin/about
Environment:
Redmine version 5.1.2.devel
Ruby version 3.2.2-p53 (2023-03-30) [x86_64-linux]
Rails version 7.1.2
Environment development
Database adapter SQLite
Mailer queue ActiveJob::QueueAdapters::AsyncAdapter
Mailer delivery smtp
Redmine settings:
Redmine theme Default
SCM:
Subversion 1.13.0
Git 2.25.1
Filesystem
Redmine plugins:
no plugin installed
Files
Updated by daijiro fukuda over 2 years ago
Sorry, I accidentally submitted this in the middle.
Could you please discard this ticket as I recreate this?
Updated by daijiro fukuda over 2 years ago
I recreate the issue:
Sorry for the trouble. please discard this ticket.
Updated by Marius BĂLTEANU over 2 years ago
- Status changed from New to Closed
- Resolution set to Duplicate
Updated by Marius BĂLTEANU over 2 years ago
- Is duplicate of Defect #40716: "Edit this section" on Wiki pages misinterprets issue links with double hash (##nnn) as ATX headings added