package main import ( "fmt" "os" "path/filepath" "rescribe.xyz/go.git/lib/line" ) func copylineimg(fn string, l line.Detail) error { f, err := os.Create(fn) if err != nil { return err } defer f.Close() return l.Img.CopyLineTo(f) } func htmlout(dir string, lines line.Details) error { err := os.MkdirAll(dir, 0700) if err != nil { return err } fn := filepath.Join(dir, "index.html") f, err := os.Create(fn) if err != nil { return err } defer f.Close() _, err = fmt.Fprintf(f, ""+ "\n\n") if err != nil { return err } for _, l := range lines { fn = filepath.Base(l.OcrName) + "_" + l.Name + ".png" err = copylineimg(filepath.Join(dir, fn), l) if err != nil { return err } _, err = fmt.Fprintf(f, "\n"+ "\n"+ "\n"+ "\n"+ "\n", l.Avgconf, l.OcrName, l.Name, fn, l.Text) if err != nil { return err } } _, err = fmt.Fprintf(f, "

%.4f%%

%s %s
%s
\n\n") if err != nil { return err } return nil }