package ace import ( "fmt" "io" ) // Doctypes var doctypes = map[string]string{ "html": ``, "xml": ``, "transitional": ``, "strict": ``, "frameset": ``, "1.1": ``, "basic": ``, "mobile": ``, } // helperMethodDoctype represents a helper method doctype. type helperMethodDoctype struct { elementBase doctype string } // WriteTo writes data to w. func (e *helperMethodDoctype) WriteTo(w io.Writer) (int64, error) { i, err := w.Write([]byte(doctypes[e.doctype])) return int64(i), err } // newHelperMethodDoctype creates and returns a helper method doctype. func newHelperMethodDoctype(ln *line, rslt *result, src *source, parent element, opts *Options) (*helperMethodDoctype, error) { if len(ln.tokens) < 3 { return nil, fmt.Errorf("doctype is not specified [file: %s][line: %d]", ln.fileName(), ln.no) } doctype := ln.tokens[2] if _, ok := doctypes[doctype]; !ok { return nil, fmt.Errorf("doctype is invalid [file: %s][line: %d][doctype: %s]", ln.fileName(), ln.no, doctype) } e := &helperMethodDoctype{ elementBase: newElementBase(ln, rslt, src, parent, opts), doctype: doctype, } return e, nil }