Defect #40715
closedWiki (markdown syntax): "Edit this section" does not extract ATX headings correctly
0%
Description
Abstraction¶
"Edit this section" in Wiki with the Markdown syntax does not extract ATX headings correctly.
ATX headings:
# Headline ## Headline
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:
@text.split(/(^(?:\S+\r?\n\r?(?:\=+|\-+)|#+.+|(?:~~~|```).*)\s*$)/).each do |part|
elsif part =~ /\A(#+).+/
level = $1.size
How to reproduce¶
Prepare Wiki with the Markdown syntax as follows.
# Wiki
## Section A
A
##1 : this is a ticket reference.
AA
## Section B
B
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":
A ##1 : this is a ticket reference. AA
The expected result when clicking the button of "Section B":
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
<!-- MarkdownTOC -->
<!-- /MarkdownTOC -->
Files
Related issues