summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2021-10-03 19:20:04 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2021-10-03 19:20:04 +0000
commit715ffcda434b8ad224127d008f3376adfbcc2c85 (patch)
tree98a7e477b5c1b02b476effaa01498b6c4121a9d4 /lib
parent09618a274bb1f7a1353ff1a8ad4d90fa3efef74c (diff)
downloadredmine-715ffcda434b8ad224127d008f3376adfbcc2c85.tar.gz
redmine-715ffcda434b8ad224127d008f3376adfbcc2c85.zip
Append two spaces to lines when importing an email on CommonMark with hardbreaks disabled (#32424).
Patch by Jens Krämer. git-svn-id: http://svn.redmine.org/redmine/trunk@21228 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r--lib/redmine/wiki_formatting/common_mark/append_spaces_to_lines.rb30
-rw-r--r--lib/redmine/wiki_formatting/common_mark/formatter.rb2
2 files changed, 31 insertions, 1 deletions
diff --git a/lib/redmine/wiki_formatting/common_mark/append_spaces_to_lines.rb b/lib/redmine/wiki_formatting/common_mark/append_spaces_to_lines.rb
new file mode 100644
index 000000000..73c5a4177
--- /dev/null
+++ b/lib/redmine/wiki_formatting/common_mark/append_spaces_to_lines.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+# Redmine - project management software
+# Copyright (C) 2006-2021 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module Redmine
+ module WikiFormatting
+ module CommonMark
+ class AppendSpacesToLines
+ def self.call(string)
+ string&.gsub(/(?<! |\\)(\r?\n)/, " \\1")
+ end
+ end
+ end
+ end
+end
diff --git a/lib/redmine/wiki_formatting/common_mark/formatter.rb b/lib/redmine/wiki_formatting/common_mark/formatter.rb
index 3c2f3ad09..3a50f78a3 100644
--- a/lib/redmine/wiki_formatting/common_mark/formatter.rb
+++ b/lib/redmine/wiki_formatting/common_mark/formatter.rb
@@ -46,7 +46,7 @@ module Redmine
],
}.freeze
- if Redmine::Configuration['common_mark_enable_hardbreaks'] === true
+ if Redmine::Configuration['common_mark_enable_hardbreaks'] == true
PIPELINE_CONFIG[:commonmarker_render_options].push(:HARDBREAKS)
end
PIPELINE_CONFIG[:commonmarker_render_options].freeze