@@ -18,56 +18,88 @@ func TestTextParser(t *testing.T) {
18
18
input : `abcdef<a href="https://example.com">More</a>` ,
19
19
expected : Text {
20
20
Value : "abcdef" ,
21
+ Range : Range {
22
+ From : Position {Index : 0 , Line : 0 , Col : 0 },
23
+ To : Position {Index : 6 , Line : 0 , Col : 6 },
24
+ },
21
25
},
22
26
},
23
27
{
24
28
name : "Text ends at a templ expression start" ,
25
- input : `abcdef{%= "test" % }` ,
29
+ input : `abcdef{ "test" }` ,
26
30
expected : Text {
27
31
Value : "abcdef" ,
32
+ Range : Range {
33
+ From : Position {Index : 0 , Line : 0 , Col : 0 },
34
+ To : Position {Index : 6 , Line : 0 , Col : 6 },
35
+ },
28
36
},
29
37
},
30
38
{
31
39
name : "Text may contain spaces" ,
32
- input : `abcdef ghijk{%= "test" % }` ,
40
+ input : `abcdef ghijk{ "test" }` ,
33
41
expected : Text {
34
42
Value : "abcdef ghijk" ,
43
+ Range : Range {
44
+ From : Position {Index : 0 , Line : 0 , Col : 0 },
45
+ To : Position {Index : 12 , Line : 0 , Col : 12 },
46
+ },
35
47
},
36
48
},
37
49
{
38
50
name : "Text may contain named references" ,
39
- input : `abcdef ghijk{%= "test" % }` ,
51
+ input : `abcdef ghijk{ "test" }` ,
40
52
expected : Text {
41
53
Value : "abcdef ghijk" ,
54
+ Range : Range {
55
+ From : Position {Index : 0 , Line : 0 , Col : 0 },
56
+ To : Position {Index : 17 , Line : 0 , Col : 17 },
57
+ },
42
58
},
43
59
},
44
60
{
45
61
name : "Text may contain base 10 numeric references" ,
46
- input : `abcdef ghijk{%= "test" % }` ,
62
+ input : `abcdef ghijk{ "test" }` ,
47
63
expected : Text {
48
64
Value : "abcdef ghijk" ,
65
+ Range : Range {
66
+ From : Position {Index : 0 , Line : 0 , Col : 0 },
67
+ To : Position {Index : 16 , Line : 0 , Col : 16 },
68
+ },
49
69
},
50
70
},
51
71
{
52
72
name : "Text may contain hexadecimal numeric references" ,
53
- input : `abcdef ghijk{%= "test" % }` ,
73
+ input : `abcdef ghijk{ "test" }` ,
54
74
expected : Text {
55
75
Value : "abcdef ghijk" ,
76
+ Range : Range {
77
+ From : Position {Index : 0 , Line : 0 , Col : 0 },
78
+ To : Position {Index : 17 , Line : 0 , Col : 17 },
79
+ },
56
80
},
57
81
},
58
82
{
59
83
name : "Multiline text is colected line by line" ,
60
84
input : "Line 1\n Line 2" ,
61
85
expected : Text {
62
- Value : "Line 1" ,
86
+ Value : "Line 1" ,
87
+ Range : Range {
88
+ From : Position {Index : 0 , Line : 0 , Col : 0 },
89
+ To : Position {Index : 6 , Line : 0 , Col : 6 },
90
+ },
63
91
TrailingSpace : "\n " ,
64
92
},
65
93
},
66
94
{
67
95
name : "Multiline text is colected line by line (Windows)" ,
68
96
input : "Line 1\r \n Line 2" ,
69
97
expected : Text {
70
- Value : "Line 1" ,
98
+ Value : "Line 1" ,
99
+ Range : Range {
100
+ From : Position {Index : 0 , Line : 0 , Col : 0 },
101
+ To : Position {Index : 6 , Line : 0 , Col : 6 },
102
+ },
71
103
TrailingSpace : "\n " ,
72
104
},
73
105
},
0 commit comments