diff options
author | Robert Basic <robertbasic.com@gmail.com> | 2016-04-10 11:11:00 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-04-10 21:55:57 +0300 |
commit | 37fb2d43e5d3ecfd1f16324556d85e202fadcc73 (patch) | |
tree | 6cd24afb7e1a6158f41576e391b062f892bb6f5d /helpers/pygments.go | |
parent | c0cf1a7e37efd4b0ba8fcbec2b53632303861303 (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.go | 5 |
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()) |