parse.go
func parseBytes(data []byte, rslt *result, src *source, opts *Options, f *File) ([]element, error) {
	var elements []element

	lines := strings.Split(formatLF(string(data)), lf)

	i := 0
	l := len(lines)

	// Ignore the last empty line.
	if l > 0 && lines[l-1] == "" {
		l--
	}

	for i < l {
		// Fetch a line.
		ln := newLine(i+1, lines[i], opts, f)
		i++

		// Ignore the empty line.
		if ln.isEmpty() {
			continue
		}

		if ln.isTopIndent() {
			e, err := newElement(ln, rslt, src, nil, opts)
			if err != nil {
				return nil, err
			}

			// Append child elements to the element.
			if err := appendChildren(e, rslt, lines, &i, l, src, opts, f); err != nil {
				return nil, err
			}

			elements = append(elements, e)
		}
	}

	return elements, nil
}
func parseBytes(data []byte, rslt *result, src *source, opts *Options, f *File) ([]element, error) {
	var elements []element

	lines := strings.Split(formatLF(string(data)), lf)

	i := 0
	l := len(lines)

	// Ignore the last empty line.
	if l > 0 && lines[l-1] == "" {
		l--
	}

	for i < l {
		// Fetch a line.
		ln := newLine(i+1, lines[i], opts, f)
		i++

		// Ignore the empty line.
		if ln.isEmpty() {
			continue
		}

		if ln.isTopIndent() {
			e, err := newElement(ln, rslt, src, nil, opts)
			if err != nil {
				return nil, err
			}

			// Append child elements to the element.
			if err := appendChildren(e, rslt, lines, &i, l, src, opts, f); err != nil {
				return nil, err
			}

			elements = append(elements, e)
		}
	}

	return elements, nil
}
// parseBytes parses the byte data and returns the elements.