package pandoc

import (
	"fmt"
	"os/exec"
)

func Convert(from, to string, options ...string) error {
	pandoc_args := []string{"-o", to, "--data-dir", "."}
	pandoc_args = append(pandoc_args, options...)
	pandoc_args = append(pandoc_args, from)

	out, err := exec.Command("pandoc", pandoc_args...).CombinedOutput()
	if string(out) != "" {
		return fmt.Errorf("pandoc: %s", string(out))
	}
	if err != nil {
		return err
	}
	return nil
}
