summaryrefslogtreecommitdiffstats
path: root/markup/blackfriday/convert_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'markup/blackfriday/convert_test.go')
-rw-r--r--markup/blackfriday/convert_test.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/markup/blackfriday/convert_test.go b/markup/blackfriday/convert_test.go
index b4d66dec6..d2d8d927e 100644
--- a/markup/blackfriday/convert_test.go
+++ b/markup/blackfriday/convert_test.go
@@ -179,3 +179,45 @@ This is a footnote.[^1] And then some.
c.Assert(s, qt.Contains, "This is a footnote.<sup class=\"footnote-ref\" id=\"fnref:testid:1\"><a href=\"#fn:testid:1\">1</a></sup>")
c.Assert(s, qt.Contains, "<a class=\"footnote-return\" href=\"#fnref:testid:1\"><sup>[return]</sup></a>")
}
+
+// Tests borrowed from https://github.com/russross/blackfriday/blob/a925a152c144ea7de0f451eaf2f7db9e52fa005a/block_test.go#L1817
+func TestSanitizedAnchorName(t *testing.T) {
+ tests := []struct {
+ text string
+ want string
+ }{
+ {
+ text: "This is a header",
+ want: "this-is-a-header",
+ },
+ {
+ text: "This is also a header",
+ want: "this-is-also-a-header",
+ },
+ {
+ text: "main.go",
+ want: "main-go",
+ },
+ {
+ text: "Article 123",
+ want: "article-123",
+ },
+ {
+ text: "<- Let's try this, shall we?",
+ want: "let-s-try-this-shall-we",
+ },
+ {
+ text: " ",
+ want: "",
+ },
+ {
+ text: "Hello, 世界",
+ want: "hello-世界",
+ },
+ }
+ for _, test := range tests {
+ if got := SanitizedAnchorName(test.text); got != test.want {
+ t.Errorf("SanitizedAnchorName(%q):\ngot %q\nwant %q", test.text, got, test.want)
+ }
+ }
+}