File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,11 +49,19 @@ pub fn generate_without_disambiguation(text: &str) -> String {
4949 // Rust's to_lowercase handles the special cases as in
5050 // <https://www.unicode.org/Public/3.2-Update/SpecialCasing-3.2.0.txt>,
5151 // but GitHub's algorithm does not.
52- let text = text
53- . replace ( 'Σ' , "σ" ) // github does not emit GREEK SMALL LETTER FINAL SIGMA, rust does
54- . replace ( '\u{0130}' , "i" ) // github emits "i" for but rust emits "i\u{0307}"
55- . to_lowercase ( ) ;
56- REGEX_TO_REMOVE . replace_all ( & text, "" ) . replace ( ' ' , "-" )
52+ REGEX_TO_REMOVE
53+ . split ( & text)
54+ . flat_map ( str:: chars)
55+ . map ( |c| {
56+ match c {
57+ ' ' => '-' ,
58+ '\u{0130}' => 'i' , // U+0130 LATIN CAPITAL LETTER I WITH DOT ABOVE
59+ 'Σ' => 'σ' , // U+03A3 GREEK CAPITAL LETTER SIGMA
60+ c => c,
61+ }
62+ } )
63+ . collect :: < String > ( )
64+ . to_lowercase ( )
5765}
5866
5967/// A stateful type for generating fragment identifiers in the style
You can’t perform that action at this time.
0 commit comments