rustdoc: Filter some characters that aren't valid pandoc header ids

This commit is contained in:
Brian Anderson 2012-07-09 14:59:24 -07:00
parent cfd3d2e1be
commit 2d1ca984eb

@ -119,6 +119,8 @@ fn pandoc_header_id(header: str) -> str {
let s = str::replace(s, "@", "");
let s = str::replace(s, "~", "");
let s = str::replace(s, "/", "");
let s = str::replace(s, ":", "");
let s = str::replace(s, "&", "");
ret s;
}
fn replace_with_hyphens(s: str) -> str {
@ -133,6 +135,10 @@ fn pandoc_header_id(header: str) -> str {
fn should_remove_punctuation_from_headers() {
assert pandoc_header_id("impl foo of bar<A>") == "impl-foo-of-bara";
assert pandoc_header_id("fn@(~[~A])") == "fna";
assert pandoc_header_id("impl of num::num for int")
== "impl-of-numnum-for-int";
assert pandoc_header_id("impl of num::num for int/&")
== "impl-of-numnum-for-int";
}
#[test]