From 2d1ca984eb04cc51b643dc83303b0afaa659a5a1 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 9 Jul 2012 14:59:24 -0700 Subject: [PATCH] rustdoc: Filter some characters that aren't valid pandoc header ids --- src/rustdoc/markdown_index_pass.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/rustdoc/markdown_index_pass.rs b/src/rustdoc/markdown_index_pass.rs index 8a68ff8cadb..264af1df256 100644 --- a/src/rustdoc/markdown_index_pass.rs +++ b/src/rustdoc/markdown_index_pass.rs @@ -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") == "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]