summaryrefslogtreecommitdiffstats
path: root/helpers/content_renderer.go
diff options
context:
space:
mode:
authorPhilipp Oppermann <dev@phil-opp.com>2016-03-31 13:14:57 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-04-04 22:19:36 +0200
commit43b5dfabb5fb36bb4574289912c66a46ef20ffce (patch)
tree958045d387b8822621024b8649b071058c8f657c /helpers/content_renderer.go
parent0698f294c6d335031951f1cb528c90f2a120eebb (diff)
Disable syntax guessing for PygmentsCodeFences by default
This disables highlighting for fenced code blocks without explicitly specified language. It also introduces a new `PygmentsCodeFencesGuessSyntax` config option (defaulting to false). To enable syntax guessing again, add the following to your config file: `PygmentsCodeFencesGuessSyntax = true` This is a breaking change.
Diffstat (limited to 'helpers/content_renderer.go')
-rw-r--r--helpers/content_renderer.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/helpers/content_renderer.go b/helpers/content_renderer.go
index 427bfc390..aedf0e1d0 100644
--- a/helpers/content_renderer.go
+++ b/helpers/content_renderer.go
@@ -35,7 +35,7 @@ type HugoHTMLRenderer struct {
}
func (renderer *HugoHTMLRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string) {
- if viper.GetBool("PygmentsCodeFences") {
+ if viper.GetBool("PygmentsCodeFences") && (lang != "" || viper.GetBool("PygmentsCodeFencesGuessSyntax")) {
opts := viper.GetString("PygmentsOptions")
str := html.UnescapeString(string(text))
out.WriteString(Highlight(str, lang, opts))
@@ -78,7 +78,7 @@ type HugoMmarkHTMLRenderer struct {
}
func (renderer *HugoMmarkHTMLRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string, caption []byte, subfigure bool, callouts bool) {
- if viper.GetBool("PygmentsCodeFences") {
+ if viper.GetBool("PygmentsCodeFences") && (lang != "" || viper.GetBool("PygmentsCodeFencesGuessSyntax")) {
str := html.UnescapeString(string(text))
out.WriteString(Highlight(str, lang, ""))
} else {