From 0eddaf3c2cd51badae914f5b70d687d5d3b81e9b Mon Sep 17 00:00:00 2001 From: Adam Moore Date: Fri, 12 Oct 2012 11:48:49 +0900 Subject: [PATCH] Don't assume pygmentize path (I use pythonbrew!). --- tools/generate.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/generate.go b/tools/generate.go index 19c5358..3258bb2 100644 --- a/tools/generate.go +++ b/tools/generate.go @@ -70,13 +70,18 @@ func mustReadFile(path string) string { func cachedPygmentize(lex string, src string) string { ensureDir(cacheDir) arg := []string{"-l", lex, "-f", "html"} - bin := "/usr/local/bin/pygmentize" + + bin, err := exec.Command("which", "pygmentize").Output() + if err != nil { + fmt.Println("Please install Pygments and ensure pygmentize is in your path first.") + os.Exit(1) + } cachePath := cacheDir + "/pygmentize-" + strings.Join(arg, "-") + "-" + sha1Sum(src) cacheBytes, cacheErr := ioutil.ReadFile(cachePath) if cacheErr == nil { return string(cacheBytes) } - renderBytes := pipe(bin, arg, src) + renderBytes := pipe(string(bin), arg, src) writeErr := ioutil.WriteFile(cachePath, renderBytes, 0600) check(writeErr) return string(renderBytes)