viper.SetDefault("DisablePathToLower", false)
viper.SetDefault("HasCJKLanguage", false)
viper.SetDefault("EnableEmoji", false)
+ viper.SetDefault("PygmentsCodeFencesGuessSyntax", false)
}
// InitializeConfig initializes a config file with sensible default configuration flags.
preserveTaxonomyNames: false
# filesystem path to write files to
publishdir: "public"
+ # enables syntax guessing for code fences without specified language
+ pygmentsCodeFencesGuessSyntax: false
# color-codes for highlighting derived from this style
pygmentsStyle: "monokai"
# true: use pygments-css or false: color-codes directly
}
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))
}
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 {