@@ -143,12 +143,16 @@ fn pandoc_header_id(header: &str) -> ~str {
143
143
let s = str:: replace( s, ~": ", ~"") ;
144
144
let s = str:: replace( s, ~"& ", ~" ") ;
145
145
let s = str:: replace( s, ~"^", ~"") ;
146
+ let s = str:: replace( s, ~", ", ~" ") ;
147
+ let s = str:: replace( s, ~"' ", ~"") ;
148
+ let s = str:: replace( s, ~"+", ~"") ;
146
149
return s;
147
150
}
148
151
fn replace_with_hyphens( s: & str) -> ~str {
149
152
// Collapse sequences of whitespace to a single dash
150
153
// XXX: Hacky implementation here that only covers
151
154
// one or two spaces.
155
+ let s = str:: trim( s) ;
152
156
let s = str:: replace( s, ~" ", ~" -") ;
153
157
let s = str:: replace( s, ~" ", ~" -") ;
154
158
return s;
@@ -170,6 +174,17 @@ fn should_remove_punctuation_from_headers() {
170
174
== ~" impl -of-numnum-for -int");
171
175
fail_unless!(pandoc_header_id(~" impl for & condvar")
172
176
== ~" impl -for -condvar");
177
+ fail_unless!(pandoc_header_id(~" impl of Select <T , U > for ( Left , Right ) ")
178
+ == ~" impl -of-selectt-u-for -left-right");
179
+ fail_unless!(pandoc_header_id(~" impl of Condition <' self , T , U >")
180
+ == ~" impl -of-conditionself-t-u");
181
+ fail_unless!(pandoc_header_id(~" impl of Condition <T : Copy + Clone >")
182
+ == ~" impl -of-conditiont-copy-clone");
183
+ }
184
+
185
+ #[test]
186
+ fn should_trim_whitespace_after_removing_punctuation() {
187
+ fail_unless!(pandoc_header_id(" impl foo for ( ) ") == ~" impl -foo-for ");
173
188
}
174
189
175
190
#[test]
0 commit comments