Merge pull request #16 from minikomi/master

Use which to find pygmentize
This commit is contained in:
Mark McGranaghan 2012-10-11 21:55:18 -07:00
commit cdc7265c57

View File

@ -70,13 +70,12 @@ 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"
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(pygmentizeBin, arg, src)
writeErr := ioutil.WriteFile(cachePath, renderBytes, 0600)
check(writeErr)
return string(renderBytes)