Include autolink text in Markdown heading anchors

This commit is contained in:
2026-10-08 01:31:18 +00:00
parent 1eb1cc6491
commit 95599e96f6
4 changed files with 21 additions and 5 deletions

View File

@@ -61,7 +61,10 @@ func TestParseMarkdownHeadingAnchors(t *testing.T) {
"# Foo\n" +
"# Foo-1\n" +
"# Foo\n" +
"# Foo-1\n")
"# Foo-1\n" +
"# <https://example.invalid>\n" +
"# <maintainer@example.invalid>\n" +
"# Contact <maintainer@example.invalid> Today\n")
document := parseMarkdown(source)
for _, anchor := range []string{
"café--東京-code-here-bold",
@@ -71,13 +74,16 @@ func TestParseMarkdownHeadingAnchors(t *testing.T) {
"foo-1-1",
"foo-2",
"foo-1-2",
"httpsexampleinvalid",
"maintainerexampleinvalid",
"contact-maintainerexampleinvalid-today",
} {
if _, ok := document.anchors[anchor]; !ok {
t.Errorf("missing anchor %q in %#v", anchor, document.anchors)
}
}
if len(document.anchors) != 7 {
t.Fatalf("found %d anchors, want 7: %#v", len(document.anchors), document.anchors)
if len(document.anchors) != 10 {
t.Fatalf("found %d anchors, want 10: %#v", len(document.anchors), document.anchors)
}
}