summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2025-05-27 01:55:37 +0000
committerGo MAEDA <maeda@farend.jp>2025-05-27 01:55:37 +0000
commit9beb9d9c5cda47438cf43a935a009e0cead32e2c (patch)
treec44a92abe45e1ad30fb534609d3b7d3825bc41ef
parent2c9699ece134c478c2afefc85522b3c35cd0fbe4 (diff)
downloadredmine-9beb9d9c5cda47438cf43a935a009e0cead32e2c.tar.gz
redmine-9beb9d9c5cda47438cf43a935a009e0cead32e2c.zip
"Edit this section" button is missing for headings rendered as multiline HTML (#42332).
Patch by Abe Tomoaki (user:abetomo). git-svn-id: https://svn.redmine.org/redmine/trunk@23802 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/helpers/application_helper.rb2
-rw-r--r--test/helpers/application_helper_test.rb40
2 files changed, 41 insertions, 1 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 847fb9fdd..99a760c1d 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1386,7 +1386,7 @@ module ApplicationHelper
<|
$)
}x
- HEADING_RE = /(<h(\d)( [^>]+)?>(.+?)<\/h(\d)>)/i unless const_defined?(:HEADING_RE)
+ HEADING_RE = /(<h(\d)( [^>]+)?>(.+?)<\/h(\d)>)/im unless const_defined?(:HEADING_RE)
def parse_sections(text, project, obj, attr, only_path, options)
return unless options[:edit_section_links]
diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb
index f959744e2..c9ec72467 100644
--- a/test/helpers/application_helper_test.rb
+++ b/test/helpers/application_helper_test.rb
@@ -1732,6 +1732,46 @@ class ApplicationHelperTest < Redmine::HelperTest
end
end
+ def test_section_edit_links_with_multiline_heading
+ raw = <<~RAW
+ # Wiki
+
+ ## `Foo` Bar
+
+ The heading above generates multiline HTML.
+ Don't assume heading tags are always single-line.
+
+ ```
+ <h2>
+ <code>Foo</code> Bar</h2>
+ ```
+ RAW
+ @project = Project.find(1)
+ set_language_if_valid 'en'
+ with_settings :text_formatting => 'common_mark' do
+ result =
+ textilizable(
+ raw,
+ :edit_section_links =>
+ {:controller => 'wiki', :action => 'edit',
+ :project_id => '1', :id => 'Test'}
+ ).delete("\n")
+
+ assert_match(
+ Regexp.new(
+ '<div class="contextual heading-2" title="Edit this section" id="section-2">' \
+ '<a class="icon-only icon-edit" href="/projects/1/wiki/Test/edit\?section=2">' \
+ '<svg class="s18 icon-svg" aria-hidden="true"><use href="/assets/icons-.*\.svg#icon--edit"></use></svg>' \
+ '<span class="icon-label">Edit this section</span>' \
+ '</a></div>' \
+ '<a name="Foo-Bar"></a>' \
+ '<h2 ><code>Foo</code> Bar<a href="#Foo-Bar" class="wiki-anchor">&para;</a></h2>'
+ ),
+ result
+ )
+ end
+ end
+
def test_default_formatter
with_settings :text_formatting => 'unknown' do
text = 'a *link*: http://www.example.net/'