diff --git a/inline_test.go b/inline_test.go index d7944d5..c875ae0 100644 --- a/inline_test.go +++ b/inline_test.go @@ -14,29 +14,33 @@ package blackfriday import ( + "regexp" "testing" + + "strings" ) -func runMarkdownInline(input string, extensions, htmlFlags int) string { +func runMarkdownInline(input string, extensions, htmlFlags int, params HtmlRendererParameters) string { extensions |= EXTENSION_AUTOLINK extensions |= EXTENSION_STRIKETHROUGH htmlFlags |= HTML_USE_XHTML - renderer := HtmlRenderer(htmlFlags, "", "") + renderer := HtmlRendererWithParameters(htmlFlags, "", "", params) return string(Markdown([]byte(input), renderer, extensions)) } func doTestsInline(t *testing.T, tests []string) { - doTestsInlineParam(t, tests, 0, 0) + doTestsInlineParam(t, tests, 0, 0, HtmlRendererParameters{}) } func doSafeTestsInline(t *testing.T, tests []string) { - doTestsInlineParam(t, tests, 0, HTML_SAFELINK) + doTestsInlineParam(t, tests, 0, HTML_SAFELINK, HtmlRendererParameters{}) } -func doTestsInlineParam(t *testing.T, tests []string, extensions, htmlFlags int) { +func doTestsInlineParam(t *testing.T, tests []string, extensions, htmlFlags int, + params HtmlRendererParameters) { // catch and report panics var candidate string /* @@ -51,7 +55,7 @@ func doTestsInlineParam(t *testing.T, tests []string, extensions, htmlFlags int) input := tests[i] candidate = input expected := tests[i+1] - actual := runMarkdownInline(candidate, extensions, htmlFlags) + actual := runMarkdownInline(candidate, extensions, htmlFlags, params) if actual != expected { t.Errorf("\nInput [%#v]\nExpected[%#v]\nActual [%#v]", candidate, expected, actual) @@ -62,7 +66,7 @@ func doTestsInlineParam(t *testing.T, tests []string, extensions, htmlFlags int) for start := 0; start < len(input); start++ { for end := start + 1; end <= len(input); end++ { candidate = input[start:end] - _ = runMarkdownInline(candidate, extensions, htmlFlags) + _ = runMarkdownInline(candidate, extensions, htmlFlags, params) } } } @@ -391,13 +395,14 @@ func TestNofollowLink(t *testing.T) { "[foo](http://bar.com/foo/)\n", "
\n", } - doTestsInlineParam(t, tests, 0, HTML_SAFELINK|HTML_NOFOLLOW_LINKS|HTML_SANITIZE_OUTPUT) + doTestsInlineParam(t, tests, 0, HTML_SAFELINK|HTML_NOFOLLOW_LINKS|HTML_SANITIZE_OUTPUT, + HtmlRendererParameters{}) // HTML_SANITIZE_OUTPUT won't allow relative links, so test that separately: tests = []string{ "[foo](/bar/)\n", "\n", } - doTestsInlineParam(t, tests, 0, HTML_SAFELINK|HTML_NOFOLLOW_LINKS) + doTestsInlineParam(t, tests, 0, HTML_SAFELINK|HTML_NOFOLLOW_LINKS, HtmlRendererParameters{}) } func TestHrefTargetBlank(t *testing.T) { @@ -409,7 +414,7 @@ func TestHrefTargetBlank(t *testing.T) { "[foo](http://example.com)\n", "\n", } - doTestsInlineParam(t, tests, 0, HTML_SAFELINK|HTML_HREF_TARGET_BLANK) + doTestsInlineParam(t, tests, 0, HTML_SAFELINK|HTML_HREF_TARGET_BLANK, HtmlRendererParameters{}) } func TestSafeInlineLink(t *testing.T) { @@ -595,7 +600,7 @@ func TestAutoLink(t *testing.T) { doTestsInline(t, tests) } -var footenoteTests = []string{ +var footnoteTests = []string{ "testing footnotes.[^a]\n\n[^a]: This is the note\n", `testing footnotes.1