summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/redmine/wiki_formatting/markdown/formatter.rb14
-rw-r--r--test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb55
2 files changed, 61 insertions, 8 deletions
diff --git a/lib/redmine/wiki_formatting/markdown/formatter.rb b/lib/redmine/wiki_formatting/markdown/formatter.rb
index c959c3a06..c7611d977 100644
--- a/lib/redmine/wiki_formatting/markdown/formatter.rb
+++ b/lib/redmine/wiki_formatting/markdown/formatter.rb
@@ -94,15 +94,13 @@ module Redmine
i = 0
l = 1
inside_pre = false
- @text.split(/(^(?:.+\r?\n\r?(?:\=+|\-+)|#+.+|~~~.*)\s*$)/).each do |part|
+ @text.split(/(^(?:.+\r?\n\r?(?:\=+|\-+)|#+.+|(?:~~~|```).*)\s*$)/).each do |part|
level = nil
- if part =~ /\A~{3,}(\S+)?\s*$/
- if $1
- if !inside_pre
- inside_pre = true
- end
- else
- inside_pre = !inside_pre
+ if part =~ /\A(~{3,}|`{3,})(\S+)?\s*$/
+ if !inside_pre
+ inside_pre = true
+ elsif !$2
+ inside_pre = false
end
elsif inside_pre
# nop
diff --git a/test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb b/test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb
index 04083dd0f..a2f864c24 100644
--- a/test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb
+++ b/test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb
@@ -122,5 +122,60 @@ EXPECTED
assert_equal expected.gsub(%r{[\r\n\t]}, ''), @formatter.new(text).to_html.gsub(%r{[\r\n\t]}, '')
end
+ STR_WITH_PRE = [
+ # 0
+"# Title
+
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero.",
+ # 1
+"## Heading 2
+
+~~~ruby
+ def foo
+ end
+~~~
+
+Morbi facilisis accumsan orci non pharetra.
+
+```
+Pre Content:
+
+## Inside pre
+
+<tag> inside pre block
+
+Morbi facilisis accumsan orci non pharetra.
+```",
+ # 2
+"### Heading 3
+
+Nulla nunc nisi, egestas in ornare vel, posuere ac libero."]
+
+ def test_get_section_should_ignore_pre_content
+ text = STR_WITH_PRE.join("\n\n")
+
+ assert_section_with_hash STR_WITH_PRE[1..2].join("\n\n"), text, 2
+ assert_section_with_hash STR_WITH_PRE[2], text, 3
+ end
+
+ def test_update_section_should_not_escape_pre_content_outside_section
+ text = STR_WITH_PRE.join("\n\n")
+ replacement = "New text"
+
+ assert_equal [STR_WITH_PRE[0..1], "New text"].flatten.join("\n\n"),
+ @formatter.new(text).update_section(3, replacement)
+ end
+
+ private
+
+ def assert_section_with_hash(expected, text, index)
+ result = @formatter.new(text).get_section(index)
+
+ assert_kind_of Array, result
+ assert_equal 2, result.size
+ assert_equal expected, result.first, "section content did not match"
+ assert_equal Digest::MD5.hexdigest(expected), result.last, "section hash did not match"
+ end
+
end
end
value='backport/43025/stable28'>backport/43025/stable28 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/l10n/nl.json
blob: 63e9e17843aaa26023bae01ce6e3d32a60ddc8ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127