@@ -14,6 +14,7 @@ import (
14
14
"code.gitea.io/gitea/modules/log"
15
15
"code.gitea.io/gitea/modules/markup"
16
16
"code.gitea.io/gitea/modules/markup/markdown"
17
+ "code.gitea.io/gitea/modules/optional"
17
18
"code.gitea.io/gitea/modules/setting"
18
19
"code.gitea.io/gitea/modules/svg"
19
20
"code.gitea.io/gitea/modules/util"
@@ -74,7 +75,7 @@ func TestRender_StandardLinks(t *testing.T) {
74
75
Links : markup.Links {
75
76
Base : FullURL ,
76
77
},
77
- IsWiki : true ,
78
+ ContentMode : markup . RenderContentAsWiki ,
78
79
}, input )
79
80
assert .NoError (t , err )
80
81
assert .Equal (t , strings .TrimSpace (expectedWiki ), strings .TrimSpace (string (buffer )))
@@ -306,9 +307,10 @@ func TestTotal_RenderWiki(t *testing.T) {
306
307
Links : markup.Links {
307
308
Base : FullURL ,
308
309
},
309
- Repo : newMockRepo (testRepoOwnerName , testRepoName ),
310
- Metas : localMetas ,
311
- IsWiki : true ,
310
+ Repo : newMockRepo (testRepoOwnerName , testRepoName ),
311
+ Metas : localMetas ,
312
+ ContentMode : markup .RenderContentAsWiki ,
313
+ UseHardLineBreak : optional .Some (true ),
312
314
}, sameCases [i ])
313
315
assert .NoError (t , err )
314
316
actual := strings .ReplaceAll (string (line ), ` data-markdown-generated-content=""` , "" )
@@ -334,7 +336,7 @@ func TestTotal_RenderWiki(t *testing.T) {
334
336
Links : markup.Links {
335
337
Base : FullURL ,
336
338
},
337
- IsWiki : true ,
339
+ ContentMode : markup . RenderContentAsWiki ,
338
340
}, testCases [i ])
339
341
assert .NoError (t , err )
340
342
actual := strings .ReplaceAll (string (line ), ` data-markdown-generated-content=""` , "" )
@@ -354,8 +356,9 @@ func TestTotal_RenderString(t *testing.T) {
354
356
Base : FullURL ,
355
357
BranchPath : "master" ,
356
358
},
357
- Repo : newMockRepo (testRepoOwnerName , testRepoName ),
358
- Metas : localMetas ,
359
+ Repo : newMockRepo (testRepoOwnerName , testRepoName ),
360
+ Metas : localMetas ,
361
+ UseHardLineBreak : optional .Some (true ),
359
362
}, sameCases [i ])
360
363
assert .NoError (t , err )
361
364
actual := strings .ReplaceAll (string (line ), ` data-markdown-generated-content=""` , "" )
@@ -428,7 +431,7 @@ func TestRenderSiblingImages_Issue12925(t *testing.T) {
428
431
expected := `<p><a href="/image1" target="_blank" rel="nofollow noopener"><img src="/image1" alt="image1"></a><br>
429
432
<a href="/image2" target="_blank" rel="nofollow noopener"><img src="/image2" alt="image2"></a></p>
430
433
`
431
- res , err := markdown .RenderRawString (& markup.RenderContext {Ctx : git .DefaultContext }, testcase )
434
+ res , err := markdown .RenderRawString (& markup.RenderContext {Ctx : git .DefaultContext , UseHardLineBreak : optional . Some ( true ) }, testcase )
432
435
assert .NoError (t , err )
433
436
assert .Equal (t , expected , res )
434
437
}
@@ -997,7 +1000,12 @@ space</p>
997
1000
}
998
1001
999
1002
for i , c := range cases {
1000
- result , err := markdown .RenderString (& markup.RenderContext {Ctx : context .Background (), Links : c .Links , IsWiki : c .IsWiki }, input )
1003
+ result , err := markdown .RenderString (& markup.RenderContext {
1004
+ Ctx : context .Background (),
1005
+ Links : c .Links ,
1006
+ ContentMode : util .Iif (c .IsWiki , markup .RenderContentAsWiki , markup .RenderContentAsDefault ),
1007
+ UseHardLineBreak : optional .Some (true ),
1008
+ }, input )
1001
1009
assert .NoError (t , err , "Unexpected error in testcase: %v" , i )
1002
1010
actual := strings .ReplaceAll (string (result ), ` data-markdown-generated-content=""` , "" )
1003
1011
assert .Equal (t , c .Expected , actual , "Unexpected result in testcase %v" , i )
0 commit comments