1
0
mirror of https://github.com/golang/go synced 2024-11-20 10:14:43 -07:00

html: small documentation fix.

R=rsc
CC=golang-dev
https://golang.org/cl/4169058
This commit is contained in:
Nigel Tao 2011-02-18 10:35:49 +11:00
parent 063125dfcf
commit 42ed1ad4a6

View File

@ -377,9 +377,9 @@ func (z *Tokenizer) Text() []byte {
} }
// TagName returns the lower-cased name of a tag token (the `img` out of // TagName returns the lower-cased name of a tag token (the `img` out of
// `<IMG SRC="foo">`), and whether the tag has attributes. // `<IMG SRC="foo">`) and whether the tag has attributes.
// The contents of the returned slice may change on the next call to Next. // The contents of the returned slice may change on the next call to Next.
func (z *Tokenizer) TagName() (name []byte, remaining bool) { func (z *Tokenizer) TagName() (name []byte, hasAttr bool) {
i := z.p0 + 1 i := z.p0 + 1
if i >= z.p1 { if i >= z.p1 {
z.p0 = z.p1 z.p0 = z.p1
@ -389,14 +389,14 @@ func (z *Tokenizer) TagName() (name []byte, remaining bool) {
i++ i++
} }
name, z.p0 = z.lower(i) name, z.p0 = z.lower(i)
remaining = z.p0 != z.p1 hasAttr = z.p0 != z.p1
return return
} }
// TagAttr returns the lower-cased key and unescaped value of the next unparsed // TagAttr returns the lower-cased key and unescaped value of the next unparsed
// attribute for the current tag token, and whether there are more attributes. // attribute for the current tag token and whether there are more attributes.
// The contents of the returned slices may change on the next call to Next. // The contents of the returned slices may change on the next call to Next.
func (z *Tokenizer) TagAttr() (key, val []byte, remaining bool) { func (z *Tokenizer) TagAttr() (key, val []byte, moreAttr bool) {
key, i := z.lower(z.p0) key, i := z.lower(z.p0)
// Get past the "=\"". // Get past the "=\"".
if i == z.p1 || z.buf[i] != '=' { if i == z.p1 || z.buf[i] != '=' {
@ -432,7 +432,7 @@ loop:
} }
} }
val, z.p0 = z.buf[i:dst], z.trim(src) val, z.p0 = z.buf[i:dst], z.trim(src)
remaining = z.p0 != z.p1 moreAttr = z.p0 != z.p1
return return
} }
@ -445,10 +445,10 @@ func (z *Tokenizer) Token() Token {
t.Data = string(z.Text()) t.Data = string(z.Text())
case StartTagToken, EndTagToken, SelfClosingTagToken: case StartTagToken, EndTagToken, SelfClosingTagToken:
var attr []Attribute var attr []Attribute
name, remaining := z.TagName() name, moreAttr := z.TagName()
for remaining { for moreAttr {
var key, val []byte var key, val []byte
key, val, remaining = z.TagAttr() key, val, moreAttr = z.TagAttr()
attr = append(attr, Attribute{string(key), string(val)}) attr = append(attr, Attribute{string(key), string(val)})
} }
t.Data = string(name) t.Data = string(name)