blob: 7c2ab2300a18126055e3c563b8995c9d07aaa4f7 (
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
|
package mdconv
import (
"bytes"
"fmt"
"strings"
"testing"
"tildegit.org/tjp/sliderule/gopher/gophermap"
)
func TestConvert(t *testing.T) {
tests := []struct {
name string
input string
output string
}{
{
name: "basic doc",
input: strings.ReplaceAll(`
iI am informational text localhost 70
icontinued on this line localhost 70
i localhost 70
0this is my text file /file.txt localhost 70
i localhost 70
1here's a sub-menu /sub/ localhost 70
.
`[1:], "\n", "\r\n"),
output: (`
` + "```" + `
I am informational text
continued on this line
` + "```" + `
[this is my text file](/file.txt)
` + "```" + `
` + "```" + `
[here's a sub-menu](/sub/)
`)[1:],
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
doc, err := gophermap.Parse(bytes.NewBufferString(test.input))
if err != nil {
t.Fatal(err)
}
buf := &bytes.Buffer{}
if err := Convert(buf, doc, nil); err != nil {
t.Fatal(err)
}
if buf.String() != test.output {
fmt.Println(">>> expected:")
fmt.Println(test.output)
fmt.Println(">>> got:")
fmt.Println(buf.String())
t.Fatal("html body mismatch")
}
})
}
}
|