@@ -5,6 +5,7 @@ package markdown_test
5
5
6
6
import (
7
7
"context"
8
+ "html/template"
8
9
"os"
9
10
"strings"
10
11
"testing"
@@ -58,7 +59,7 @@ func TestRender_StandardLinks(t *testing.T) {
58
59
},
59
60
}, input )
60
61
assert .NoError (t , err )
61
- assert .Equal (t , strings .TrimSpace (expected ), strings .TrimSpace (buffer ))
62
+ assert .Equal (t , strings .TrimSpace (expected ), strings .TrimSpace (string ( buffer ) ))
62
63
63
64
buffer , err = markdown .RenderString (& markup.RenderContext {
64
65
Ctx : git .DefaultContext ,
@@ -68,7 +69,7 @@ func TestRender_StandardLinks(t *testing.T) {
68
69
IsWiki : true ,
69
70
}, input )
70
71
assert .NoError (t , err )
71
- assert .Equal (t , strings .TrimSpace (expectedWiki ), strings .TrimSpace (buffer ))
72
+ assert .Equal (t , strings .TrimSpace (expectedWiki ), strings .TrimSpace (string ( buffer ) ))
72
73
}
73
74
74
75
googleRendered := `<p><a href="https://google.com/" rel="nofollow">https://google.com/</a></p>`
@@ -93,7 +94,7 @@ func TestRender_Images(t *testing.T) {
93
94
},
94
95
}, input )
95
96
assert .NoError (t , err )
96
- assert .Equal (t , strings .TrimSpace (expected ), strings .TrimSpace (buffer ))
97
+ assert .Equal (t , strings .TrimSpace (expected ), strings .TrimSpace (string ( buffer ) ))
97
98
}
98
99
99
100
url := "../../.images/src/02/train.jpg"
@@ -303,7 +304,7 @@ func TestTotal_RenderWiki(t *testing.T) {
303
304
IsWiki : true ,
304
305
}, sameCases [i ])
305
306
assert .NoError (t , err )
306
- assert .Equal (t , answers [i ], line )
307
+ assert .Equal (t , template . HTML ( answers [i ]) , line )
307
308
}
308
309
309
310
testCases := []string {
@@ -328,7 +329,7 @@ func TestTotal_RenderWiki(t *testing.T) {
328
329
IsWiki : true ,
329
330
}, testCases [i ])
330
331
assert .NoError (t , err )
331
- assert .Equal (t , testCases [i + 1 ], line )
332
+ assert .Equal (t , template . HTML ( testCases [i + 1 ]) , line )
332
333
}
333
334
}
334
335
@@ -348,7 +349,7 @@ func TestTotal_RenderString(t *testing.T) {
348
349
Metas : localMetas ,
349
350
}, sameCases [i ])
350
351
assert .NoError (t , err )
351
- assert .Equal (t , answers [i ], line )
352
+ assert .Equal (t , template . HTML ( answers [i ]) , line )
352
353
}
353
354
354
355
testCases := []string {}
@@ -361,7 +362,7 @@ func TestTotal_RenderString(t *testing.T) {
361
362
},
362
363
}, testCases [i ])
363
364
assert .NoError (t , err )
364
- assert .Equal (t , testCases [i + 1 ], line )
365
+ assert .Equal (t , template . HTML ( testCases [i + 1 ]) , line )
365
366
}
366
367
}
367
368
@@ -428,7 +429,7 @@ func TestRenderEmojiInLinks_Issue12331(t *testing.T) {
428
429
`
429
430
res , err := markdown .RenderString (& markup.RenderContext {Ctx : git .DefaultContext }, testcase )
430
431
assert .NoError (t , err )
431
- assert .Equal (t , expected , res )
432
+ assert .Equal (t , template . HTML ( expected ) , res )
432
433
}
433
434
434
435
func TestColorPreview (t * testing.T ) {
@@ -462,7 +463,7 @@ func TestColorPreview(t *testing.T) {
462
463
for _ , test := range positiveTests {
463
464
res , err := markdown .RenderString (& markup.RenderContext {Ctx : git .DefaultContext }, test .testcase )
464
465
assert .NoError (t , err , "Unexpected error in testcase: %q" , test .testcase )
465
- assert .Equal (t , test .expected , res , "Unexpected result in testcase %q" , test .testcase )
466
+ assert .Equal (t , template . HTML ( test .expected ) , res , "Unexpected result in testcase %q" , test .testcase )
466
467
467
468
}
468
469
@@ -529,7 +530,7 @@ func TestMathBlock(t *testing.T) {
529
530
for _ , test := range testcases {
530
531
res , err := markdown .RenderString (& markup.RenderContext {Ctx : git .DefaultContext }, test .testcase )
531
532
assert .NoError (t , err , "Unexpected error in testcase: %q" , test .testcase )
532
- assert .Equal (t , test .expected , res , "Unexpected result in testcase %q" , test .testcase )
533
+ assert .Equal (t , template . HTML ( test .expected ) , res , "Unexpected result in testcase %q" , test .testcase )
533
534
534
535
}
535
536
}
@@ -567,12 +568,12 @@ foo: bar
567
568
for _ , test := range testcases {
568
569
res , err := markdown .RenderString (& markup.RenderContext {Ctx : git .DefaultContext }, test .testcase )
569
570
assert .NoError (t , err , "Unexpected error in testcase: %q" , test .testcase )
570
- assert .Equal (t , test .expected , res , "Unexpected result in testcase %q" , test .testcase )
571
+ assert .Equal (t , template . HTML ( test .expected ) , res , "Unexpected result in testcase %q" , test .testcase )
571
572
}
572
573
}
573
574
574
575
func TestRenderLinks (t * testing.T ) {
575
- input := ` space @mention-user
576
+ input := ` space @mention-user
576
577
/just/a/path.bin
577
578
https://example.com/file.bin
578
579
[local link](file.bin)
@@ -593,7 +594,7 @@ com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
593
594
594
595
@mention-user test
595
596
#123
596
- space
597
+ space
597
598
`
598
599
cases := []struct {
599
600
Links markup.Links
@@ -957,6 +958,6 @@ space</p>
957
958
for i , c := range cases {
958
959
result , err := markdown .RenderString (& markup.RenderContext {Ctx : context .Background (), Links : c .Links , IsWiki : c .IsWiki }, input )
959
960
assert .NoError (t , err , "Unexpected error in testcase: %v" , i )
960
- assert .Equal (t , c .Expected , result , "Unexpected result in testcase %v" , i )
961
+ assert .Equal (t , template . HTML ( c .Expected ) , result , "Unexpected result in testcase %v" , i )
961
962
}
962
963
}
0 commit comments