html_tag.go
func (e *htmlTag) setAttributes() error {
	parsedTokens := e.parseTokens()

	var i int
	var token string
	var setTextValue bool

	// Set attributes to the element.
	for i, token = range parsedTokens {
		kv := strings.Split(token, equal)

		if len(kv) < 2 {
			setTextValue = true
			break
		}

		k := kv[0]
		v := strings.Join(kv[1:], equal)

		// Remove the prefix and suffix of the double quotes.
		if len(v) > 1 && strings.HasPrefix(v, doubleQuote) && strings.HasSuffix(v, doubleQuote) {
			v = v[1 : len(v)-1]
		}

		switch k {
		case attributeNameID:
			if e.id != "" {
				return fmt.Errorf("multiple IDs are specified [file: %s][line: %d]", e.ln.fileName(), e.ln.no)
			}
			e.id = v
		case e.opts.AttributeNameClass:
			e.classes = append(e.classes, strings.Split(v, space)...)
		default:
			e.attributes = append(e.attributes, htmlAttribute{k, v})
		}
	}

	// Set a text value to the element.
	if setTextValue {
		e.textValue = strings.Join(parsedTokens[i:], space)
	}

	return nil
}
func (e *htmlTag) setAttributes() error {
	parsedTokens := e.parseTokens()

	var i int
	var token string
	var setTextValue bool

	// Set attributes to the element.
	for i, token = range parsedTokens {
		kv := strings.Split(token, equal)

		if len(kv) < 2 {
			setTextValue = true
			break
		}

		k := kv[0]
		v := strings.Join(kv[1:], equal)

		// Remove the prefix and suffix of the double quotes.
		if len(v) > 1 && strings.HasPrefix(v, doubleQuote) && strings.HasSuffix(v, doubleQuote) {
			v = v[1 : len(v)-1]
		}

		switch k {
		case attributeNameID:
			if e.id != "" {
				return fmt.Errorf("multiple IDs are specified [file: %s][line: %d]", e.ln.fileName(), e.ln.no)
			}
			e.id = v
		case e.opts.AttributeNameClass:
			e.classes = append(e.classes, strings.Split(v, space)...)
		default:
			e.attributes = append(e.attributes, htmlAttribute{k, v})
		}
	}

	// Set a text value to the element.
	if setTextValue {
		e.textValue = strings.Join(parsedTokens[i:], space)
	}

	return nil
}
// setAttributes parses the tokens and set attributes to the element.