git-svn-id: http://svn.redmine.org/redmine/trunk@21227 e93f8b46-1217-0410-a6f0-8f06a7374b81tags/5.0.0
@@ -19,7 +19,17 @@ | |||
<p><%= setting_select :protocol, [['HTTP', 'http'], ['HTTPS', 'https']] %></p> | |||
<p><%= setting_select :text_formatting, Redmine::WikiFormatting.formats_for_select, :blank => :label_none %></p> | |||
<p><%= setting_select :text_formatting, Redmine::WikiFormatting.formats_for_select, :blank => :label_none %> | |||
<span id="common_mark_info" class="<%= "hidden" unless Setting.text_formatting == "common_mark" %>"> | |||
<label class="block"> | |||
<%= check_box_tag(nil, '', Redmine::Configuration['common_mark_enable_hardbreaks'] === true, disabled: true) %> | |||
Hardbreaks | |||
</label> | |||
<em class="info"> | |||
<%= l(:text_setting_config_change) %> | |||
</em> | |||
</span> | |||
</p> | |||
<p><%= setting_check_box :cache_formatted_text %></p> | |||
@@ -32,3 +42,16 @@ | |||
<%= submit_tag l(:button_save) %> | |||
<% end %> | |||
<%= javascript_tag do %> | |||
$('#settings_text_formatting').on('change', function(e){ | |||
const formatter = e.target.value; | |||
const parent_block = document.getElementById("common_mark_info"); | |||
if (formatter == "common_mark") { | |||
parent_block.classList.remove('hidden'); | |||
} else { | |||
parent_block.classList.add('hidden'); | |||
} | |||
}); | |||
<% end %> |
@@ -224,6 +224,13 @@ default: | |||
#avatar_server_url: https://www.gravatar.com # default | |||
#avatar_server_url: https://seccdn.libravatar.org | |||
# Configure CommonMark hardbreaks behaviour | |||
# | |||
# allowed values: true, false | |||
# true: treats regular line break (\n) as hardbreaks | |||
# false: switches to default common mark where two or more spaces are required | |||
# common_mark_enable_hardbreaks: true | |||
# specific configuration options for production environment | |||
# that overrides the default ones | |||
production: |
@@ -1287,7 +1287,7 @@ en: | |||
text_avatar_server_config_html: The current avatar server is <a href="%{url}">%{url}</a>. You can configure it in config/configuration.yml. | |||
text_no_subject: no subject | |||
text_allowed_queries_to_select: Public (to any users) queries only selectable | |||
text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. | |||
default_role_manager: Manager | |||
default_role_developer: Developer |
@@ -24,7 +24,8 @@ module Redmine | |||
@defaults = { | |||
'avatar_server_url' => 'https://www.gravatar.com', | |||
'email_delivery' => nil, | |||
'max_concurrent_ajax_uploads' => 2 | |||
'max_concurrent_ajax_uploads' => 2, | |||
'common_mark_enable_hardbreaks' => true | |||
} | |||
@config = nil |
@@ -42,11 +42,15 @@ module Redmine | |||
# https://github.com/gjtorikian/commonmarker#render-options | |||
commonmarker_render_options: [ | |||
:HARDBREAKS, | |||
:UNSAFE | |||
].freeze, | |||
], | |||
}.freeze | |||
if Redmine::Configuration['common_mark_enable_hardbreaks'] === true | |||
PIPELINE_CONFIG[:commonmarker_render_options].push(:HARDBREAKS) | |||
end | |||
PIPELINE_CONFIG[:commonmarker_render_options].freeze | |||
MarkdownPipeline = HTML::Pipeline.new [ | |||
MarkdownFilter, | |||
SanitizationFilter, |