@@ -24,9 +24,9 @@ pub(super) fn check_text_fragments(
2424
2525 // The algorithm to find a range in a document likely requires a full implementation of a browser.
2626 // See https://wicg.github.io/scroll-to-text-fragment/#finding-ranges-in-a-document
27- // Here, we try to approximate it by extracting all visible text, then normalizing whitespace .
27+ // Here, we try to approximate it by extracting visible text.
2828 // This ensures that `Hell<i>o</i> <strong>world</strong>` is matched.
29- let document = normalize_whitespace ( & extract_visible_text ( content) ) ;
29+ let document = extract_visible_text ( content) ;
3030 directives
3131 . iter ( )
3232 . all ( |directive| directive. matches ( & document) )
@@ -70,11 +70,6 @@ impl TextDirective {
7070 }
7171}
7272
73- /// Collapse consecutive whitespace characters into a single space.
74- fn normalize_whitespace ( input : & str ) -> String {
75- input. split_whitespace ( ) . collect :: < Vec < _ > > ( ) . join ( " " )
76- }
77-
7873/// Extract visible text from the given HTML content.
7974///
8075/// This method is a good enough heuristic using html5gum. All `CallbackEvent::String` is considered visible text,
@@ -151,7 +146,7 @@ mod tests {
151146
152147 #[ test]
153148 fn extracts_visible_text_without_style_or_attributes ( ) {
154- let text = normalize_whitespace ( & extract_visible_text ( INDEX_HTML ) ) ;
149+ let text = extract_visible_text ( INDEX_HTML ) ;
155150
156151 assert ! ( text. contains( "Sed porta nisl sit amet quam ornare rutrum." ) ) ;
157152 assert ! ( text. contains( "Proin vulputate mi id sem pulvinar euismod." ) ) ;
0 commit comments