mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
Add pygmentsstyle and pygmentsuseclasses options
Fixes #204 Conflicts: commands/hugo.go
This commit is contained in:
@@ -15,10 +15,12 @@ package helpers
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
jww "github.com/spf13/jwalterweatherman"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func Highlight(code string, lexer string) string {
|
||||
@@ -32,8 +34,15 @@ func Highlight(code string, lexer string) string {
|
||||
|
||||
var out bytes.Buffer
|
||||
var stderr bytes.Buffer
|
||||
style := viper.GetString("PygmentsStyle")
|
||||
|
||||
cmd := exec.Command(pygmentsBin, "-l"+lexer, "-fhtml", "-O style=monokai,noclasses=true,encoding=utf-8")
|
||||
noclasses := "true"
|
||||
if viper.GetBool("PygmentsUseClasses") {
|
||||
noclasses = "false"
|
||||
}
|
||||
|
||||
cmd := exec.Command(pygmentsBin, "-l"+lexer, "-fhtml", "-O",
|
||||
fmt.Sprintf("style=%s,noclasses=%s,encoding=utf8", style, noclasses))
|
||||
cmd.Stdin = strings.NewReader(code)
|
||||
cmd.Stdout = &out
|
||||
cmd.Stderr = &stderr
|
||||
|
Reference in New Issue
Block a user