summaryrefslogtreecommitdiffstats
path: root/helpers/content.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-08-07 14:03:03 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-09-06 18:32:17 +0300
commit2079a23dd89734cea39e523faf46e44201151279 (patch)
tree5b5163a12cf874863eea889685d65a3c5b56515c /helpers/content.go
parent596e0e98e4483d2a0a709412a338ceddb6538757 (diff)
Make it possible to configure Blackfroday per language
See #2309
Diffstat (limited to 'helpers/content.go')
-rw-r--r--helpers/content.go27
1 files changed, 16 insertions, 11 deletions
diff --git a/helpers/content.go b/helpers/content.go
index b9281acf4..427d960a1 100644
--- a/helpers/content.go
+++ b/helpers/content.go
@@ -59,7 +59,7 @@ type Blackfriday struct {
}
// NewBlackfriday creates a new Blackfriday filled with site config or some sane defaults.
-func NewBlackfriday() *Blackfriday {
+func NewBlackfriday(c ConfigProvider) *Blackfriday {
combinedParam := map[string]interface{}{
"smartypants": true,
"angledQuotes": false,
@@ -72,7 +72,7 @@ func NewBlackfriday() *Blackfriday {
"sourceRelativeLinksProjectFolder": "/docs/content",
}
- siteParam := viper.GetStringMap("blackfriday")
+ siteParam := c.GetStringMap("blackfriday")
if siteParam != nil {
siteConfig := cast.ToStringMap(siteParam)
@@ -341,20 +341,25 @@ func ExtractTOC(content []byte) (newcontent []byte, toc []byte) {
// RenderingContext holds contextual information, like content and configuration,
// for a given content rendering.
type RenderingContext struct {
- Content []byte
- PageFmt string
- DocumentID string
- Config *Blackfriday
- RenderTOC bool
- FileResolver FileResolverFunc
- LinkResolver LinkResolverFunc
- configInit sync.Once
+ Content []byte
+ PageFmt string
+ DocumentID string
+ Config *Blackfriday
+ RenderTOC bool
+ FileResolver FileResolverFunc
+ LinkResolver LinkResolverFunc
+ ConfigProvider ConfigProvider
+ configInit sync.Once
+}
+
+func newViperProvidedRenderingContext() *RenderingContext {
+ return &RenderingContext{ConfigProvider: viper.GetViper()}
}
func (c *RenderingContext) getConfig() *Blackfriday {
c.configInit.Do(func() {
if c.Config == nil {
- c.Config = NewBlackfriday()
+ c.Config = NewBlackfriday(c.ConfigProvider)
}
})
return c.Config