func (e *Element) setIdFromToken(token string) error {
	parts := strings.Split(token, "#")
	switch len(parts) {
	case 1:
	case 2:
		e.setId(strings.Split(parts[1], ".")[0])
	default:
		return e.multipleIdsError()
	}
	return nil
}
setIdFromToken extracts an id from the token and sets it to the element.
package gold
import (
	"bytes"
	"errors"
	"fmt"
	"strings"
)
const (
	TypeTag               = "tag"
	TypeContent           = "content"
	TypeBlock             = "block"
	TypeExpression        = "expression"
	TypeLiteral           = "literal"
	TypeInclude           = "include"
	TypeOutputExpression  = "outputExpression"
	IncludeParaStartIndex = 2
)
var (
	doctypes = map[string]string{
		"html":         "<!DOCTYPE html>",
		"xml":          "<?xml version=\"1.0\" encoding=\"utf-8\" ?>",
		"transitional": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">",
		"strict":       "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">",
		"frameset":     "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">",
		"1.1":          "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">",
		"basic":        "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML Basic 1.1//EN\" \"http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd\">",
		"mobile":       "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.2//EN\" \"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd\">",
	}
)
type Element struct {
	Text             string
	Tokens           []string
	LineNo           int
	Indent           int
	Parent           *Element
	Children         []*Element
	Tag              string
	Attributes       map[string]string
	SingleAttributes []string
	Id               string
	Classes          []string
	TextValues       []string
	Type             string
	Template         *Template
	Block            *Block
	RawContent       bool
}
func (e *Element) parse() error {
	if e.hasNoTokens() {
		return errors.New(fmt.Sprintf("The element has no tokens. (line no: %d)", e.LineNo))
	}
	switch {
	case e.Type == TypeContent || e.Type == TypeBlock || e.Type == TypeExpression || e.Type == TypeLiteral || e.Type == TypeInclude || e.Type == TypeOutputExpression || e.comment():
	default:
		for i, token := range e.Tokens {
			switch {
			case i == 0:
				if err := e.parseFirstToken(token); err != nil {
					return err
				}
			case e.hasTextValues():
				e.appendTextValue(token)
			case attribute(token):
				e.appendAttribute(token)
			case singleAttribute(token):
				e.appendSingleAttribute(token)
			default:
				e.appendTextValue(token)
			}
		}
	}
	return nil
}
func (e *Element) hasNoTokens() bool {
	return len(e.Tokens) == 0
}
func (e *Element) hasTextValues() bool {
	return len(e.TextValues) > 0
}
func (e *Element) parseFirstToken(token string) error {
	switch token {
	case "javascript:":
		e.setTag("script")
		e.appendAttribute("type=text/javascript")
	default:
		if err := e.setTag(token); err != nil {
			return err
		}
	}
	return nil
}
func (e *Element) setTag(token string) error {
	tag := strings.Split(strings.Split(token, "#")[0], ".")[0]
	if tag == "" {
		tag = "div"
	}
	e.Tag = tag
	err := e.setIdFromToken(token)
	if err != nil {
		return err
	}
	e.appendClassesFromToken(token)
	if e.Tag == "script" || e.Tag == "style" || strings.HasSuffix(token, ".") {
		e.RawContent = true
	}
	return nil
}