mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 18:51:08 +08:00
FIX: Do not strip email lines having lists.
This commit is contained in:
@ -364,6 +364,10 @@ module Email
|
|||||||
text = text.lines.map! do |line|
|
text = text.lines.map! do |line|
|
||||||
stripped = line.strip << "\n"
|
stripped = line.strip << "\n"
|
||||||
|
|
||||||
|
# Do not strip list items.
|
||||||
|
next line if (stripped[0] == '*' || stripped[0] == '-' || stripped[0] == '+') && stripped[1] == ' '
|
||||||
|
|
||||||
|
# Match beginning and ending of code blocks.
|
||||||
if !in_code && stripped[0..2] == '```'
|
if !in_code && stripped[0..2] == '```'
|
||||||
in_code = '```'
|
in_code = '```'
|
||||||
elsif in_code == '```' && stripped[0..2] == '```'
|
elsif in_code == '```' && stripped[0..2] == '```'
|
||||||
@ -374,6 +378,7 @@ module Email
|
|||||||
in_code = nil
|
in_code = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Strip only lines outside code blocks.
|
||||||
in_code ? line : stripped
|
in_code ? line : stripped
|
||||||
end.join
|
end.join
|
||||||
end
|
end
|
||||||
|
@ -1274,6 +1274,18 @@ describe Email::Receiver do
|
|||||||
This is a line that will not be touched.
|
This is a line that will not be touched.
|
||||||
This is another line that will not be touched.
|
This is another line that will not be touched.
|
||||||
|
|
||||||
|
* list
|
||||||
|
|
||||||
|
* sub-list
|
||||||
|
|
||||||
|
- list
|
||||||
|
|
||||||
|
- sub-list
|
||||||
|
|
||||||
|
+ list
|
||||||
|
|
||||||
|
+ sub-list
|
||||||
|
|
||||||
[code]
|
[code]
|
||||||
1.upto(10).each do |i|
|
1.upto(10).each do |i|
|
||||||
puts i
|
puts i
|
||||||
@ -1308,6 +1320,18 @@ describe Email::Receiver do
|
|||||||
This is a line that will not be touched.
|
This is a line that will not be touched.
|
||||||
This is another line that will not be touched.
|
This is another line that will not be touched.
|
||||||
|
|
||||||
|
* list
|
||||||
|
|
||||||
|
* sub-list
|
||||||
|
|
||||||
|
- list
|
||||||
|
|
||||||
|
- sub-list
|
||||||
|
|
||||||
|
+ list
|
||||||
|
|
||||||
|
+ sub-list
|
||||||
|
|
||||||
[code]
|
[code]
|
||||||
1.upto(10).each do |i|
|
1.upto(10).each do |i|
|
||||||
puts i
|
puts i
|
||||||
|
Reference in New Issue
Block a user