Skip to content

Commit a9bd76b

Browse files
committed
rustdoc: Implement more rules for generating internal pandoc links
1 parent e306111 commit a9bd76b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/rustdoc/markdown_index_pass.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,14 @@ fn pandoc_header_id(header: str) -> str {
8080
let header = maybe_use_section_id(header);
8181
ret header;
8282

83-
fn remove_formatting(s: str) -> str { s }
84-
fn remove_punctuation(s: str) -> str {
83+
fn remove_formatting(s: str) -> str {
8584
str::replace(s, "`", "")
8685
}
86+
fn remove_punctuation(s: str) -> str {
87+
let s = str::replace(s, "<", "");
88+
let s = str::replace(s, ">", "");
89+
ret s;
90+
}
8791
fn replace_with_hyphens(s: str) -> str {
8892
str::replace(s, " ", "-")
8993
}
@@ -92,6 +96,11 @@ fn pandoc_header_id(header: str) -> str {
9296
fn maybe_use_section_id(s: str) -> str { s }
9397
}
9498

99+
#[test]
100+
fn should_remove_brackets_from_headers() {
101+
assert pandoc_header_id("impl foo of bar<A>") == "impl-foo-of-bara";
102+
}
103+
95104
#[test]
96105
fn should_index_mod_contents() {
97106
let doc = test::mk_doc(

0 commit comments

Comments
 (0)