mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
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.
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
0698f294c6
commit
43b5dfabb5
@@ -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 {
|
||||
|
Reference in New Issue
Block a user