diff --git a/format/formatcore/base.go b/format/formatcore/base.go
index fea1066..3872101 100644
--- a/format/formatcore/base.go
+++ b/format/formatcore/base.go
@@ -48,7 +48,7 @@ func GFMCodeBlock(language, code string) string {
// Anchor produces an anchor for the provided link.
func Anchor(anchor string) string {
return fmt.Sprintf(
- "",
+ "",
html.EscapeString(anchor),
)
}
diff --git a/format/formatcore/base_test.go b/format/formatcore/base_test.go
index a00fdf9..d929fee 100644
--- a/format/formatcore/base_test.go
+++ b/format/formatcore/base_test.go
@@ -99,3 +99,25 @@ func TestEscape(t *testing.T) {
})
}
}
+
+func TestAnchor(t *testing.T) {
+ tests := []struct {
+ in, out string
+ }{
+ {
+ in: "SimpleAnchor",
+ out: ``,
+ },
+ {
+ in: "Anchor With Spaces",
+ out: ``,
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.in, func(t *testing.T) {
+ is := is.New(t)
+ is.Equal(Anchor(test.in), test.out) // Wrong output for Anchor()
+ })
+ }
+}