func (pdf *pdfLatex) CompileLatex(fname string) error {
	tmp, err := ioutil.TempDir("", "hplot-htex-")
	if err != nil {
		return fmt.Errorf("htex: could not create tmp dir: %w", err)
	}
	defer os.RemoveAll(tmp)

	var (
		stdout = new(bytes.Buffer)
		args   = []string{
			fmt.Sprintf("-output-directory=%s", tmp),
			fname,
		}
	)

	cmd := exec.Command(pdf.cmd, args...)
	cmd.Stdout = stdout
	cmd.Stderr = stdout

	err = cmd.Run()
	if err != nil {
		return fmt.Errorf(
			"htex: could not generate PDF from vgtex:\n%s\nerror: %w",
			stdout.Bytes(),
			err,
		)
	}

	oname := fname[:len(fname)-len(".tex")] + ".pdf"
	o, err := os.Create(oname)
	if err != nil {
		return fmt.Errorf("htex: could not create output PDF file: %w", err)
	}
	defer o.Close()

	f, err := os.Open(path.Join(tmp, path.Base(oname)))
	if err != nil {
		return fmt.Errorf("htex: could not open generated PDF file: %w", err)
	}
	defer f.Close()

	_, err = io.Copy(o, f)
	if err != nil {
		return fmt.Errorf("htex: could not copy PDF file: %w", err)
	}

	err = o.Close()
	if err != nil {
		return fmt.Errorf("htex: could not close PDF file: %w", err)
	}

	return nil
}
// CompileLatex compiles the provided .tex document.
CompileLatex compiles the provided .tex document.
// CompileLatex compiles the provided . tex document .
func (pdf *pdfLatex) CompileLatex(fname string) error {
	tmp, err := ioutil.TempDir("", "hplot-htex-")
	if err != nil {
		return fmt.Errorf("htex: could not create tmp dir: %w", err)
	}
	defer os.RemoveAll(tmp)
	var (
		stdout = new(bytes.Buffer)
		args   = []string{
			fmt.Sprintf("-output-directory=%s", tmp),
			fname,
		}
	)
	cmd := exec.Command(pdf.cmd, args...)
	cmd.Stdout = stdout
	cmd.Stderr = stdout
	err = cmd.Run()
	if err != nil {
		return fmt.Errorf(
			"htex: could not generate PDF from vgtex:\n%s\nerror: %w",
			stdout.Bytes(),
			err,
		)
	}
	oname := fname[:len(fname)-len(".tex")] + ".pdf"
	o, err := os.Create(oname)
	if err != nil {
		return fmt.Errorf("htex: could not create output PDF file: %w", err)
	}
	defer o.Close()
	f, err := os.Open(path.Join(tmp, path.Base(oname)))
	if err != nil {
		return fmt.Errorf("htex: could not open generated PDF file: %w", err)
	}
	defer f.Close()
	_, err = io.Copy(o, f)
	if err != nil {
		return fmt.Errorf("htex: could not copy PDF file: %w", err)
	}
	err = o.Close()
	if err != nil {
		return fmt.Errorf("htex: could not close PDF file: %w", err)
	}
	return nil
}
func ( pdf * pdfLatex ) CompileLatex ( fname string ) error { tmp , err := ioutil . TempDir ( " " , " " ) if err != nil { return fmt . Errorf ( " " , err ) } defer os . RemoveAll ( tmp ) var ( stdout = new ( bytes . Buffer ) args = [ ] string { fmt . Sprintf ( " " , tmp ) , fname , } ) cmd := exec . Command ( pdf . cmd , args ... ) cmd . Stdout = stdout cmd . Stderr = stdout err = cmd . Run ( ) if err != nil { return fmt . Errorf ( " \n \n " , stdout . Bytes ( ) , err , ) } oname := fname [ : len ( fname ) - len ( " " ) ] + " " o , err := os . Create ( oname ) if err != nil { return fmt . Errorf ( " " , err ) } defer o . Close ( ) f , err := os . Open ( path . Join ( tmp , path . Base ( oname ) ) ) if err != nil { return fmt . Errorf ( " " , err ) } defer f . Close ( ) _ , err = io . Copy ( o , f ) if err != nil { return fmt . Errorf ( " " , err ) } err = o . Close ( ) if err != nil { return fmt . Errorf ( " " , err ) } return nil }
CompileLatex compiles the provided .tex document.
CompileLatex compiles the provided . tex document .