forked from ego008/go-markdown
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtml_inline_fsm_test.go
More file actions
76 lines (74 loc) · 2.02 KB
/
html_inline_fsm_test.go
File metadata and controls
76 lines (74 loc) · 2.02 KB
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
package markdown
import "testing"
func TestMatchHTML(t *testing.T) {
type testCase struct {
in string
want string
}
testCases := []testCase{
{"<!-->", ""},
{"<!-- ->", ""},
{"<!-- -- >", ""},
{"<!-- -*- -->", "<!-- -*- -->"},
{"<!#-- -->", ""},
{"<?...??>", "<?...??>"},
{"<?...?#>", ""},
{"</#>", ""},
{"", ""},
{"</a # >", ""},
{"</a#>", ""},
{"<#a>", ""},
{"<a # >", ""},
{"<a", ""},
{"<a#>", ""},
{"a>", ""},
{"a", ""},
{"</a >", "</a >"},
{"</a >", "</a >"},
{"<a>", "<a>"},
{"<a >", "<a >"},
{"<a h#ref>", ""},
{"<a href #>", ""},
{"<a href= ''>", "<a href= ''>"},
{"<a href=/ >", "<a href=/ >"},
{"<a href = ''>", "<a href = ''>"},
{"<a href >", "<a href >"},
{"<a href=/blog>", "<a href=/blog>"},
{"<a href='/blog'>", "<a href='/blog'>"},
{`<a href="/blog" title="Blog">`, `<a href="/blog" title="Blog">`},
{`<a href="http://google.com">google.com</a>`, `<a href="http://google.com">`},
{"<a href=\x00>", ""},
{"<a l : href>", "<a l : href>"},
{"<a l:href>", "<a l:href>"},
{"<a X>", "<a X>"},
{"<br / >", ""},
{"<br />", "<br />"},
{"<br/>", "<br/>"},
{"<![CDATA[...]] >", ""},
{"<![CDATA[...]# >", ""},
{"<![CDATA[ xxx xxx xxx ]]>", "<![CDATA[ xxx xxx xxx ]]>"},
{"<!-- comment -->", "<!-- comment -->"},
{"<!doctype html>", ""},
{"<!Doctype html>", ""},
{"<!DOCTYPE html>", "<!DOCTYPE html>"},
{"<em><b", "<em>"},
{"<em><b>", "<em><b>"},
{"</em>", "</em>"},
{"<em><", "<em>"},
{`<img src="http://google.com"#/>`, ""},
{`<img src="http://google.com"/>`, `<img src="http://google.com"/>`},
{"<img src=image.jpeg/>", "<img src=image.jpeg/>"},
{`<img src="image.jpg" />`, `<img src="image.jpg" />`},
{"<img src=image\x00.jpeg/>", ""},
{"<img src/>", "<img src/>"},
{"<?processing-instruction?>", "<?processing-instruction?>"},
{"<![XDATA[...]]>", ""},
{"<!-xxx-->", ""},
}
for _, tc := range testCases {
got := matchHTML(tc.in)
if got != tc.want {
t.Errorf("matchHTML(%q) = %q, want %q", tc.in, got, tc.want)
}
}
}