From d45b55bdd405ae019c065bc6fa0888c25f7952c9 Mon Sep 17 00:00:00 2001 From: Anthony Fok Date: Mon, 21 Mar 2016 15:16:39 +0800 Subject: [PATCH] helpers: Rename getMmarkHtmlRenderer to getMmarkHTMLRenderer To be consistent with the changes made in commit 67df33f, see #959. --- helpers/content.go | 8 +++----- helpers/content_renderer_test.go | 5 +++-- helpers/content_test.go | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/helpers/content.go b/helpers/content.go index d67514db2..60f885f14 100644 --- a/helpers/content.go +++ b/helpers/content.go @@ -249,8 +249,8 @@ func markdownRenderWithTOC(ctx *RenderingContext) []byte { getMarkdownExtensions(ctx)) } -// getMmarkHtmlRenderer returns markdown html renderer. -func getMmarkHtmlRenderer(defaultFlags int, ctx *RenderingContext) mmark.Renderer { +// getMmarkHTMLRenderer creates a new mmark HTML Renderer with the given configuration. +func getMmarkHTMLRenderer(defaultFlags int, ctx *RenderingContext) mmark.Renderer { renderParameters := mmark.HtmlRendererParameters{ FootnoteAnchorPrefix: viper.GetString("FootnoteAnchorPrefix"), FootnoteReturnLinkContents: viper.GetString("FootnoteReturnLinkContents"), @@ -271,7 +271,6 @@ func getMmarkHtmlRenderer(defaultFlags int, ctx *RenderingContext) mmark.Rendere } } -// getMmarkExtensions returns markdown extensions. func getMmarkExtensions(ctx *RenderingContext) int { flags := 0 flags |= mmark.EXTENSION_TABLES @@ -296,9 +295,8 @@ func getMmarkExtensions(ctx *RenderingContext) int { return flags } -// mmarkRender renders markdowns. func mmarkRender(ctx *RenderingContext) []byte { - return mmark.Parse(ctx.Content, getMmarkHtmlRenderer(0, ctx), + return mmark.Parse(ctx.Content, getMmarkHTMLRenderer(0, ctx), getMmarkExtensions(ctx)).Bytes() } diff --git a/helpers/content_renderer_test.go b/helpers/content_renderer_test.go index f224b33e4..8c8e58604 100644 --- a/helpers/content_renderer_test.go +++ b/helpers/content_renderer_test.go @@ -15,9 +15,10 @@ package helpers import ( "bytes" - "github.com/spf13/viper" "regexp" "testing" + + "github.com/spf13/viper" ) // Renders a codeblock using Blackfriday @@ -33,7 +34,7 @@ func render(input string) string { // Renders a codeblock using Mmark func renderWithMmark(input string) string { ctx := &RenderingContext{} - render := getMmarkHtmlRenderer(0, ctx) + render := getMmarkHTMLRenderer(0, ctx) buf := &bytes.Buffer{} render.BlockCode(buf, []byte(input), "html", []byte(""), false, false) diff --git a/helpers/content_test.go b/helpers/content_test.go index d16f1d660..a89b4992e 100644 --- a/helpers/content_test.go +++ b/helpers/content_test.go @@ -194,12 +194,12 @@ func TestGetHTMLRendererAnchors(t *testing.T) { } } -func TestGetMmarkHtmlRenderer(t *testing.T) { +func TestGetMmarkHTMLRenderer(t *testing.T) { ctx := &RenderingContext{} ctx.DocumentID = "testid" ctx.Config = ctx.getConfig() ctx.Config.PlainIDAnchors = false - actualRenderer := getMmarkHtmlRenderer(0, ctx) + actualRenderer := getMmarkHTMLRenderer(0, ctx) headerBuffer := &bytes.Buffer{} footnoteBuffer := &bytes.Buffer{}