diff --git a/main.go b/main.go index 2ab4680..1631f4a 100644 --- a/main.go +++ b/main.go @@ -10,12 +10,12 @@ import ( "os" "os/exec" "strings" - "syscall" "github.com/alecthomas/chroma" "github.com/alecthomas/chroma/formatters/html" "github.com/alecthomas/chroma/lexers" "github.com/alecthomas/chroma/styles" + "golang.org/x/sys/unix" ) // dataPipedIn returns true if the user piped data via stdin. @@ -132,7 +132,6 @@ func main() { } } checkError(bs.Err(), "reading markdown file") - _ = needCSS f, err := ioutil.TempFile("", "chroma-markdown-") checkError(err, "creating temporary file") w := bufio.NewWriter(f) @@ -149,6 +148,9 @@ func main() { cmark, lookErr = exec.LookPath("markdown") checkError(lookErr, "finding markdown binary") } - execErr := syscall.Exec(cmark, []string{cmark, f.Name()}, []string{}) + execErr := unix.Exec(cmark, []string{cmark, f.Name()}, []string{}) checkError(execErr, "executing markdown binary") + if err := f.Close(); err != nil { + checkError(err, "closing file") + } }