Document and clean SourceRelativeLinksEval code

This commit is contained in:
Sven Dowideit
2016-03-15 16:00:36 +10:00
committed by Bjørn Erik Pedersen
parent 819271cb78
commit 1648e327c0
6 changed files with 80 additions and 80 deletions

View File

@@ -43,29 +43,31 @@ var SummaryDivider = []byte("<!--more-->")
// Blackfriday holds configuration values for Blackfriday rendering.
type Blackfriday struct {
Smartypants bool
AngledQuotes bool
Fractions bool
HrefTargetBlank bool
SmartDashes bool
LatexDashes bool
PlainIDAnchors bool
SourceRelativeLinksEval bool
Extensions []string
ExtensionsMask []string
Smartypants bool
AngledQuotes bool
Fractions bool
HrefTargetBlank bool
SmartDashes bool
LatexDashes bool
PlainIDAnchors bool
SourceRelativeLinksEval bool
SourceRelativeLinksProjectFolder string
Extensions []string
ExtensionsMask []string
}
// NewBlackfriday creates a new Blackfriday filled with site config or some sane defaults.
func NewBlackfriday() *Blackfriday {
combinedParam := map[string]interface{}{
"smartypants": true,
"angledQuotes": false,
"fractions": true,
"hrefTargetBlank": false,
"smartDashes": true,
"latexDashes": true,
"plainIDAnchors": false,
"sourceRelativeLinks": false,
"smartypants": true,
"angledQuotes": false,
"fractions": true,
"hrefTargetBlank": false,
"smartDashes": true,
"latexDashes": true,
"plainIDAnchors": false,
"sourceRelativeLinks": false,
"sourceRelativeLinksProjectFolder": "/docs/content",
}
siteParam := viper.GetStringMap("blackfriday")

View File

@@ -49,6 +49,7 @@ func (renderer *HugoHTMLRenderer) Link(out *bytes.Buffer, link []byte, title []b
// Use the blackfriday built in Link handler
renderer.Renderer.Link(out, link, title, content)
} else {
// set by SourceRelativeLinksEval
newLink, err := renderer.LinkResolver(string(link))
if err != nil {
newLink = string(link)
@@ -62,6 +63,7 @@ func (renderer *HugoHTMLRenderer) Image(out *bytes.Buffer, link []byte, title []
// Use the blackfriday built in Image handler
renderer.Renderer.Image(out, link, title, alt)
} else {
// set by SourceRelativeLinksEval
newLink, err := renderer.FileResolver(string(link))
if err != nil {
newLink = string(link)