Previously if no language was specified, then illegal args would be passed to pygments, for example `pygments -l -fhtml`, which would result in pygments printing an error.
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