diff options
author | LK4D4 <lk4d4math@gmail.com> | 2014-05-07 20:38:14 +0400 |
---|---|---|
committer | spf13 <steve.francia@gmail.com> | 2014-05-10 07:20:11 +0400 |
commit | 2194cc77de3bcfc0107d8e8284781f9f7b31c5c2 (patch) | |
tree | 5d9d1146a40a9f0d56f2fd862e43916d9ae3d018 /helpers | |
parent | 5df0cf7ecac3240c57fd2d3b3cf3f4eb9c966dc4 (diff) |
Add pygmentsstyle and pygmentsuseclasses options
Fixes #204
Conflicts:
commands/hugo.go
Diffstat (limited to 'helpers')
-rw-r--r-- | helpers/pygments.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/helpers/pygments.go b/helpers/pygments.go index 46eb879e5..2ff500da3 100644 --- a/helpers/pygments.go +++ b/helpers/pygments.go @@ -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 |