"))
test.Bytes(t, l.Text(), nil)
test.Bytes(t, l.AttrVal(), nil)
_, data = l.Next()
test.Bytes(t, data, []byte("text"))
test.Bytes(t, l.Text(), []byte("text"))
test.Bytes(t, l.AttrVal(), nil)
_, data = l.Next()
test.Bytes(t, data, []byte(""))
test.Bytes(t, l.Text(), []byte("comment"))
test.Bytes(t, l.AttrVal(), nil)
_, data = l.Next()
test.Bytes(t, data, []byte(""))
test.Bytes(t, l.Text(), []byte(" doctype"))
test.Bytes(t, l.AttrVal(), nil)
_, data = l.Next()
test.Bytes(t, data, []byte(""))
test.Bytes(t, l.Text(), []byte("cdata"))
test.Bytes(t, l.AttrVal(), nil)
}
func TestOffset(t *testing.T) {
z := parse.NewInputString(`text
`)
l := NewLexer(z)
test.T(t, z.Offset(), 0)
_, _ = l.Next()
test.T(t, z.Offset(), 4) //
_, _ = l.Next()
test.T(t, z.Offset(), 20) // text
_, _ = l.Next()
test.T(t, z.Offset(), 26) //
}
////////////////////////////////////////////////////////////////
func ExampleNewLexer() {
l := NewLexer(parse.NewInputString("John Doe"))
var out strings.Builder
for {
tt, data := l.Next()
if tt == ErrorToken {
break
}
out.WriteString(string(data))
}
fmt.Println(out.String())
// Output: John Doe
}