MCPcopy
hub / github.com/golang/net / Token

Method Token

html/token.go:1255–1274  ·  view source on GitHub ↗

Token returns the current Token. The result's Data and Attr values remain valid after subsequent Next calls.

()

Source from the content-addressed store, hash-verified

1253// Token returns the current Token. The result's Data and Attr values remain
1254// valid after subsequent Next calls.
1255func (z *Tokenizer) Token() Token {
1256 t := Token{Type: z.tt}
1257 switch z.tt {
1258 case TextToken, CommentToken, DoctypeToken:
1259 t.Data = string(z.Text())
1260 case StartTagToken, SelfClosingTagToken, EndTagToken:
1261 name, moreAttr := z.TagName()
1262 for moreAttr {
1263 var key, val []byte
1264 key, val, moreAttr = z.TagAttr()
1265 t.Attr = append(t.Attr, Attribute{"", atom.String(key), string(val)})
1266 }
1267 if a := atom.Lookup(name); a != 0 {
1268 t.DataAtom, t.Data = a, a.String()
1269 } else {
1270 t.DataAtom, t.Data = 0, string(name)
1271 }
1272 }
1273 return t
1274}
1275
1276// SetMaxBuf sets a limit on the amount of data buffered during tokenization.
1277// A value of 0 means unlimited.

Callers 5

TestTokenizerFunction · 0.95
benchmarkTokenizerFunction · 0.95
TestHTML5LibTestsFunction · 0.95
TestUnicodeAttributeCaseFunction · 0.95
parseMethod · 0.45

Calls 6

TextMethod · 0.95
TagNameMethod · 0.95
TagAttrMethod · 0.95
StringFunction · 0.92
LookupFunction · 0.92
StringMethod · 0.65

Tested by 4

TestTokenizerFunction · 0.76
benchmarkTokenizerFunction · 0.76
TestHTML5LibTestsFunction · 0.76
TestUnicodeAttributeCaseFunction · 0.76