pandoc.go 436 B

123456789101112131415161718192021
  1. package pandoc
  2. import (
  3. "fmt"
  4. "os/exec"
  5. )
  6. func Convert(from, to string, options ...string) error {
  7. pandoc_args := []string{"-o", to, "--data-dir", "."}
  8. pandoc_args = append(pandoc_args, options...)
  9. pandoc_args = append(pandoc_args, from)
  10. out, err := exec.Command("pandoc", pandoc_args...).CombinedOutput()
  11. if string(out) != "" {
  12. return fmt.Errorf("pandoc: %s", string(out))
  13. }
  14. if err != nil {
  15. return err
  16. }
  17. return nil
  18. }