diff options
Diffstat (limited to 'helpers/pygments.go')
-rw-r--r-- | helpers/pygments.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/helpers/pygments.go b/helpers/pygments.go index 3f0f90b7a..ecbdf99d0 100644 --- a/helpers/pygments.go +++ b/helpers/pygments.go @@ -94,7 +94,14 @@ func Highlight(code, lang, optsStr string) string { var out bytes.Buffer var stderr bytes.Buffer - cmd := exec.Command(pygmentsBin, "-l"+lang, "-fhtml", "-O", options) + var langOpt string + if lang == "" { + langOpt = "-g" // Try guessing the language + } else { + langOpt = "-l"+lang + } + + cmd := exec.Command(pygmentsBin, langOpt, "-fhtml", "-O", options) cmd.Stdin = strings.NewReader(code) cmd.Stdout = &out cmd.Stderr = &stderr |