diff --git a/helpers/content_renderer_test.go b/helpers/content_renderer_test.go index 09ddf8e60..2110637cb 100644 --- a/helpers/content_renderer_test.go +++ b/helpers/content_renderer_test.go @@ -16,6 +16,7 @@ package helpers import ( "bytes" "github.com/spf13/viper" + "regexp" "testing" ) @@ -50,9 +51,11 @@ func TestCodeFence(t *testing.T) { enabled bool input, expected string } + + // Pygments 2.0 and 2.1 have slightly different outputs so only do partial matching data := []test{ - {true, "", "
<html></html>\n
<html></html>
\n"},
+ {true, "", `(?s)^.*?
.*?
\n$`},
}
viper.Reset()
@@ -65,12 +68,21 @@ func TestCodeFence(t *testing.T) {
viper.Set("PygmentsCodeFences", d.enabled)
result := render(d.input)
- if result != d.expected {
+
+ expectedRe, err := regexp.Compile(d.expected)
+
+ if err != nil {
+ t.Fatalf("Invalid regexp", err)
+ }
+ matched := expectedRe.MatchString(result)
+
+ if !matched {
t.Errorf("Test %d failed. BlackFriday enabled:%t, Expected:\n%q got:\n%q", i, d.enabled, d.expected, result)
}
result = renderWithMmark(d.input)
- if result != d.expected {
+ matched = expectedRe.MatchString(result)
+ if !matched {
t.Errorf("Test %d failed. Mmark enabled:%t, Expected:\n%q got:\n%q", i, d.enabled, d.expected, result)
}
}
diff --git a/hugolib/shortcode_test.go b/hugolib/shortcode_test.go
index 07af6b3a6..5d2763016 100644
--- a/hugolib/shortcode_test.go
+++ b/hugolib/shortcode_test.go
@@ -52,7 +52,7 @@ func CheckShortCodeMatchAndError(t *testing.T, input, expected string, template
}
if output != expected {
- t.Fatalf("Shortcode render didn't match. got %q but expected %q", output, expected)
+ t.Fatalf("Shortcode render didn't match. got \n%q but expected \n%q", output, expected)
}
}
@@ -258,13 +258,28 @@ func TestHighlight(t *testing.T) {
viper.Set("PygmentsStyle", "bw")
viper.Set("PygmentsUseClasses", false)
- tem := tpl.New()
+ templ := tpl.New()
code := `
{{< highlight java >}}
void do();
{{< /highlight >}}`
- CheckShortCodeMatch(t, code, "\nvoid do();\n
.*?void do().*?