summaryrefslogtreecommitdiffstats
path: root/helpers/pygments.go
diff options
context:
space:
mode:
authorRobert Basic <robertbasic.com@gmail.com>2016-04-10 10:11:00 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-04-10 20:55:57 +0200
commit37fb2d43e5d3ecfd1f16324556d85e202fadcc73 (patch)
tree6cd24afb7e1a6158f41576e391b062f892bb6f5d /helpers/pygments.go
parentc0cf1a7e37efd4b0ba8fcbec2b53632303861303 (diff)
helpers: Ignore cache for Pygments when flag set
When the --ignoreCache flag is set to true, do not write and read the Pygments results to/from the cache directory. Fixes #2066 Closes #2068
Diffstat (limited to 'helpers/pygments.go')
-rw-r--r--helpers/pygments.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/helpers/pygments.go b/helpers/pygments.go
index 637f61b19..38266b267 100644
--- a/helpers/pygments.go
+++ b/helpers/pygments.go
@@ -62,10 +62,11 @@ func Highlight(code, lang, optsStr string) string {
fs := hugofs.Os()
+ ignoreCache := viper.GetBool("IgnoreCache")
cacheDir := viper.GetString("CacheDir")
var cachefile string
- if cacheDir != "" {
+ if !ignoreCache && cacheDir != "" {
cachefile = filepath.Join(cacheDir, fmt.Sprintf("pygments-%x", hash.Sum(nil)))
exists, err := Exists(cachefile, fs)
@@ -120,7 +121,7 @@ func Highlight(code, lang, optsStr string) string {
str = strings.Replace(str, "</pre>", "</code></pre>", 1)
}
- if cachefile != "" {
+ if !ignoreCache && cachefile != "" {
// Write cache file
if err := WriteToDisk(cachefile, strings.NewReader(str), fs); err != nil {
jww.ERROR.Print(stderr.String())