mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-28 22:19:59 +02:00
Fix errors reported by Go Vet
This commit is contained in:
@@ -111,7 +111,7 @@ func BytesToHTML(b []byte) template.HTML {
|
||||
return template.HTML(string(b))
|
||||
}
|
||||
|
||||
func GetHtmlRenderer(defaultFlags int, ctx RenderingContext) blackfriday.Renderer {
|
||||
func GetHtmlRenderer(defaultFlags int, ctx *RenderingContext) blackfriday.Renderer {
|
||||
renderParameters := blackfriday.HtmlRendererParameters{
|
||||
FootnoteAnchorPrefix: viper.GetString("FootnoteAnchorPrefix"),
|
||||
FootnoteReturnLinkContents: viper.GetString("FootnoteReturnLinkContents"),
|
||||
@@ -141,7 +141,7 @@ func GetHtmlRenderer(defaultFlags int, ctx RenderingContext) blackfriday.Rendere
|
||||
return blackfriday.HtmlRendererWithParameters(htmlFlags, "", "", renderParameters)
|
||||
}
|
||||
|
||||
func GetMarkdownExtensions(ctx RenderingContext) int {
|
||||
func GetMarkdownExtensions(ctx *RenderingContext) int {
|
||||
flags := 0 | blackfriday.EXTENSION_NO_INTRA_EMPHASIS |
|
||||
blackfriday.EXTENSION_TABLES | blackfriday.EXTENSION_FENCED_CODE |
|
||||
blackfriday.EXTENSION_AUTOLINK | blackfriday.EXTENSION_STRIKETHROUGH |
|
||||
@@ -155,12 +155,12 @@ func GetMarkdownExtensions(ctx RenderingContext) int {
|
||||
return flags
|
||||
}
|
||||
|
||||
func MarkdownRender(ctx RenderingContext) []byte {
|
||||
func MarkdownRender(ctx *RenderingContext) []byte {
|
||||
return blackfriday.Markdown(ctx.Content, GetHtmlRenderer(0, ctx),
|
||||
GetMarkdownExtensions(ctx))
|
||||
}
|
||||
|
||||
func MarkdownRenderWithTOC(ctx RenderingContext) []byte {
|
||||
func MarkdownRenderWithTOC(ctx *RenderingContext) []byte {
|
||||
return blackfriday.Markdown(ctx.Content,
|
||||
GetHtmlRenderer(blackfriday.HTML_TOC, ctx),
|
||||
GetMarkdownExtensions(ctx))
|
||||
@@ -219,7 +219,7 @@ func (c *RenderingContext) getConfig() *Blackfriday {
|
||||
return c.Config
|
||||
}
|
||||
|
||||
func RenderBytesWithTOC(ctx RenderingContext) []byte {
|
||||
func RenderBytesWithTOC(ctx *RenderingContext) []byte {
|
||||
switch ctx.PageFmt {
|
||||
default:
|
||||
return MarkdownRenderWithTOC(ctx)
|
||||
@@ -230,7 +230,7 @@ func RenderBytesWithTOC(ctx RenderingContext) []byte {
|
||||
}
|
||||
}
|
||||
|
||||
func RenderBytes(ctx RenderingContext) []byte {
|
||||
func RenderBytes(ctx *RenderingContext) []byte {
|
||||
switch ctx.PageFmt {
|
||||
default:
|
||||
return MarkdownRender(ctx)
|
||||
|
@@ -204,7 +204,7 @@ func TestDoArithmetic(t *testing.T) {
|
||||
result, err := DoArithmetic(this.a, this.b, this.op)
|
||||
if b, ok := this.expect.(bool); ok && !b {
|
||||
if err == nil {
|
||||
t.Errorf("[%d] doArithmetic didn't return an expected error")
|
||||
t.Errorf("[%d] doArithmetic didn't return an expected error", i)
|
||||
}
|
||||
} else {
|
||||
if err != nil {
|
||||
|
@@ -107,7 +107,7 @@ func TestMakePathRelative(t *testing.T) {
|
||||
_, error := MakePathRelative("a/b/c.ss", "/a/c", "/d/c", "/e/f")
|
||||
|
||||
if error == nil {
|
||||
t.Errorf("Test #%d failed. Expected error")
|
||||
t.Errorf("Test failed, expected error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,7 +497,7 @@ func TestFileAndExt(t *testing.T) {
|
||||
t.Errorf("Test %d failed. Expected filename %q got %q.", i, d.expectedFile, file)
|
||||
}
|
||||
if d.expectedExt != ext {
|
||||
t.Errorf("Test %d failed. Expected extension $q got %q.", i, d.expectedExt, ext)
|
||||
t.Errorf("Test %d failed. Expected extension %q got %q.", i, d.expectedExt, ext)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -564,7 +564,7 @@ func TestFindCWD(t *testing.T) {
|
||||
t.Errorf("Test %d failed. Expected %q but got %q", i, d.expectedDir, dir)
|
||||
}
|
||||
if d.expectedErr != err {
|
||||
t.Error("Test %d failed. Expected %q but got %q", i, d.expectedErr, err)
|
||||
t.Errorf("Test %d failed. Expected %q but got %q", i, d.expectedErr, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -639,7 +639,7 @@ func TestWriteToDisk(t *testing.T) {
|
||||
}
|
||||
contents, e := ioutil.ReadFile(d.filename)
|
||||
if e != nil {
|
||||
t.Error("Test %d failed. Could not read file %s. Reason: %s\n", i, d.filename, e)
|
||||
t.Errorf("Test %d failed. Could not read file %s. Reason: %s\n", i, d.filename, e)
|
||||
}
|
||||
if randomString != string(contents) {
|
||||
t.Errorf("Test %d failed. Expected contents %q but got %q", i, randomString, string(contents))
|
||||
|
Reference in New Issue
Block a user