Merge pull request #16 from minikomi/master
Use which to find pygmentize
This commit is contained in:
commit
cdc7265c57
@ -70,13 +70,12 @@ func mustReadFile(path string) string {
|
|||||||
func cachedPygmentize(lex string, src string) string {
|
func cachedPygmentize(lex string, src string) string {
|
||||||
ensureDir(cacheDir)
|
ensureDir(cacheDir)
|
||||||
arg := []string{"-l", lex, "-f", "html"}
|
arg := []string{"-l", lex, "-f", "html"}
|
||||||
bin := "/usr/local/bin/pygmentize"
|
|
||||||
cachePath := cacheDir + "/pygmentize-" + strings.Join(arg, "-") + "-" + sha1Sum(src)
|
cachePath := cacheDir + "/pygmentize-" + strings.Join(arg, "-") + "-" + sha1Sum(src)
|
||||||
cacheBytes, cacheErr := ioutil.ReadFile(cachePath)
|
cacheBytes, cacheErr := ioutil.ReadFile(cachePath)
|
||||||
if cacheErr == nil {
|
if cacheErr == nil {
|
||||||
return string(cacheBytes)
|
return string(cacheBytes)
|
||||||
}
|
}
|
||||||
renderBytes := pipe(bin, arg, src)
|
renderBytes := pipe(pygmentizeBin, arg, src)
|
||||||
writeErr := ioutil.WriteFile(cachePath, renderBytes, 0600)
|
writeErr := ioutil.WriteFile(cachePath, renderBytes, 0600)
|
||||||
check(writeErr)
|
check(writeErr)
|
||||||
return string(renderBytes)
|
return string(renderBytes)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user