summaryrefslogtreecommitdiffstats
path: root/hugolib/shortcode_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-03-13 22:06:51 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-03-13 22:06:51 +0100
commit542e220cc41cb55fa17f38573bab9df5a59344c2 (patch)
tree15d1774a878c512af845e6d509ff821db1956b91 /hugolib/shortcode_test.go
parent988962e8b530363278d8946729b661f03c5ee081 (diff)
Make tests green on both Pygments 2.0.2 and 2.1.3
See #1969
Diffstat (limited to 'hugolib/shortcode_test.go')
-rw-r--r--hugolib/shortcode_test.go21
1 files changed, 18 insertions, 3 deletions
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, "\n<div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\"><span style=\"font-weight: bold\">void</span> do();\n</pre></div>\n", tem)
+
+ p, _ := pageFromString(SIMPLE_PAGE, "simple.md")
+ output, err := HandleShortcodes(code, p, templ)
+
+ if err != nil {
+ t.Fatal("Handle shortcode error", err)
+ }
+ matched, err := regexp.MatchString("(?s)^\n<div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\">.*?void</span> do().*?</pre></div>\n$", output)
+
+ if err != nil {
+ t.Fatal("Regexp error", err)
+ }
+
+ if !matched {
+ t.Error("Hightlight mismatch, got\n", output)
+ }
}
const testScPlaceholderRegexp = "{#{#HUGOSHORTCODE-\\d+#}#}"