mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-11 20:03:58 +02:00
Move blackfriday site-wide config loading to NewBlackFriday()
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
fde47c5eb9
commit
5838420aa1
@@ -24,7 +24,9 @@ import (
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/miekg/mmark"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/russross/blackfriday"
|
||||
"github.com/spf13/cast"
|
||||
bp "github.com/spf13/hugo/bufferpool"
|
||||
jww "github.com/spf13/jwalterweatherman"
|
||||
"github.com/spf13/viper"
|
||||
@@ -52,17 +54,33 @@ type Blackfriday struct {
|
||||
ExtensionsMask []string
|
||||
}
|
||||
|
||||
// NewBlackfriday creates a new Blackfriday with some sane defaults.
|
||||
// NewBlackfriday creates a new Blackfriday filled with site config or some sane defaults
|
||||
func NewBlackfriday() *Blackfriday {
|
||||
return &Blackfriday{
|
||||
Smartypants: true,
|
||||
AngledQuotes: false,
|
||||
Fractions: true,
|
||||
HrefTargetBlank: false,
|
||||
SmartDashes: true,
|
||||
LatexDashes: true,
|
||||
PlainIDAnchors: false,
|
||||
combinedParam := map[string]interface{}{
|
||||
"smartypants": true,
|
||||
"angledQuotes": false,
|
||||
"fractions": true,
|
||||
"hrefTargetBlank": false,
|
||||
"smartDashes": true,
|
||||
"latexDashes": true,
|
||||
"plainIDAnchors": false,
|
||||
}
|
||||
|
||||
siteParam := viper.GetStringMap("blackfriday")
|
||||
if siteParam != nil {
|
||||
siteConfig := cast.ToStringMap(siteParam)
|
||||
|
||||
for key, value := range siteConfig {
|
||||
combinedParam[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
combinedConfig := &Blackfriday{}
|
||||
if err := mapstructure.Decode(combinedParam, combinedConfig); err != nil {
|
||||
jww.FATAL.Printf("Failed to get site rendering config\n%s", err.Error())
|
||||
}
|
||||
|
||||
return combinedConfig
|
||||
}
|
||||
|
||||
var blackfridayExtensionMap = map[string]int{
|
||||
|
Reference in New Issue
Block a user