Exemplo n.º 1
0
// This function is used to create a new TokenChain from a re-sliced slice
// of an existing TokenChain
//
// Actually it can be used to build a chain from any slice of html.Token
func (q *Query) GetTokenChain(tokenChain []html.Token) *tokenutil.Chain {
	var (
		tChain *tokenutil.Chain
		end    bool
	)

	tChain = new(tokenutil.Chain)

	for _, token := range tokenChain {
		// we reached the end of our chain
		if end {
			break
		}

		tChain, end = tChain.Add(token, nil)
	}

	return tChain
}