mirror of
https://github.com/redmine/redmine.git
synced 2026-05-09 00:37:29 +02:00
Fixes Wiki "Edit this section" does not extract SeText headings correctly in CommonMark Markdown (#40918).
git-svn-id: https://svn.redmine.org/redmine/trunk@24434 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -42,7 +42,7 @@ module Redmine
|
|||||||
i = 0
|
i = 0
|
||||||
l = 1
|
l = 1
|
||||||
inside_pre = false
|
inside_pre = false
|
||||||
@text.split(/(^(?:\S+\r?\n\r?(?:=+|-+)|#+ .+|(?:~~~|```).*)\s*$)/).each do |part|
|
@text.split(/(^(?:(?!\s*$|#).+\r?\n\r?(?:=+|-+)|#+ .+|(?:~~~|```).*)\s*$)/).each do |part|
|
||||||
level = nil
|
level = nil
|
||||||
if part =~ /\A(~{3,}|`{3,})(\s*\S+)?\s*$/
|
if part =~ /\A(~{3,}|`{3,})(\s*\S+)?\s*$/
|
||||||
if !inside_pre
|
if !inside_pre
|
||||||
|
|||||||
@@ -403,6 +403,39 @@ class WikiControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_edit_section_with_common_mark_should_correctly_extract_setext_heading
|
||||||
|
text = <<~STR
|
||||||
|
A new MarkDown page
|
||||||
|
===================
|
||||||
|
This text is the first section.
|
||||||
|
|
||||||
|
First subsection
|
||||||
|
----------------
|
||||||
|
Here would be a first subsection
|
||||||
|
|
||||||
|
Second subsection
|
||||||
|
-----------------
|
||||||
|
Here would be a second subsection
|
||||||
|
STR
|
||||||
|
|
||||||
|
page = WikiPage.find_by_title('Page_with_sections')
|
||||||
|
page.content.text = text
|
||||||
|
page.content.save!
|
||||||
|
|
||||||
|
with_settings :text_formatting => 'common_mark' do
|
||||||
|
@request.session[:user_id] = 2
|
||||||
|
get :edit, :params => {:project_id => 'ecookbook', :id => 'Page_with_sections', :section => 2}
|
||||||
|
|
||||||
|
assert_response :success
|
||||||
|
|
||||||
|
section, hash = Redmine::WikiFormatting::CommonMark::Formatter.new(page.content.text).get_section(2)
|
||||||
|
|
||||||
|
assert_select 'textarea[name=?]', 'content[text]', :text => section
|
||||||
|
assert_select 'input[name=section][type=hidden][value="2"]'
|
||||||
|
assert_select 'input[name=section_hash][type=hidden][value=?]', hash
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_edit_invalid_section_should_respond_with_404
|
def test_edit_invalid_section_should_respond_with_404
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :edit, :params => {:project_id => 'ecookbook', :id => 'Page_with_sections', :section => 10}
|
get :edit, :params => {:project_id => 'ecookbook', :id => 'Page_with_sections', :section => 10}
|
||||||
|
|||||||
Reference in New Issue
Block a user