From 123179b8f31c1e45fc61490bf7df510cb3fa2876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vytautas=20=C5=A0altenis?= Date: Tue, 5 Apr 2016 13:45:00 +0300 Subject: [PATCH] Make Markdown the most general API call Get rid of MarkdownOptions. --- markdown.go | 16 ++++------------ test_helpers.go | 2 +- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/markdown.go b/markdown.go index 97c2211..ae7968c 100644 --- a/markdown.go +++ b/markdown.go @@ -349,7 +349,7 @@ func MarkdownBasic(input []byte) []byte { renderer := HTMLRenderer(htmlFlags, CommonExtensions, "", "") // set up the parser - return MarkdownOptions(input, renderer, Options{Extensions: 0}) + return Markdown(input, renderer, Options{Extensions: 0}) } // Call Markdown with most useful extensions enabled @@ -374,7 +374,7 @@ func MarkdownBasic(input []byte) []byte { func MarkdownCommon(input []byte) []byte { // set up the HTML renderer renderer := HTMLRenderer(CommonHtmlFlags, CommonExtensions, "", "") - return MarkdownOptions(input, renderer, DefaultOptions) + return Markdown(input, renderer, DefaultOptions) } // Markdown is the main rendering function. @@ -384,19 +384,11 @@ func MarkdownCommon(input []byte) []byte { // // To use the supplied Html or LaTeX renderers, see HtmlRenderer and // LatexRenderer, respectively. -func Markdown(input []byte, renderer Renderer, extensions Extensions) []byte { - return MarkdownOptions(input, renderer, Options{ - Extensions: extensions}) -} - -// MarkdownOptions is just like Markdown but takes additional options through -// the Options struct. -func MarkdownOptions(input []byte, renderer Renderer, opts Options) []byte { - // no point in parsing if we can't render +func Markdown(input []byte, renderer Renderer, options Options) []byte { if renderer == nil { return nil } - return renderer.Render(Parse(input, opts)) + return renderer.Render(Parse(input, options)) } func Parse(input []byte, opts Options) *Node { diff --git a/test_helpers.go b/test_helpers.go index b5187b4..1675120 100644 --- a/test_helpers.go +++ b/test_helpers.go @@ -45,7 +45,7 @@ func execRecoverableTestSuite(t *testing.T, tests []string, params TestParams, s func runMarkdown(input string, params TestParams) string { renderer := HTMLRendererWithParameters(params.HTMLFlags, params.Options.Extensions, "", "", params.HTMLRendererParameters) - return string(MarkdownOptions([]byte(input), renderer, params.Options)) + return string(Markdown([]byte(input), renderer, params.Options)) } func doTestsBlock(t *testing.T, tests []string, extensions Extensions) {