prepass: consider only ascii whitespace
This commit is contained in:
		
					parent
					
						
							
								72a3378831
							
						
					
				
			
			
				commit
				
					
						eaa21fd393
					
				
			
		
					 1 changed files with 19 additions and 4 deletions
				
			
		
							
								
								
									
										23
									
								
								src/lib.rs
									
										
									
									
									
								
							
							
						
						
									
										23
									
								
								src/lib.rs
									
										
									
									
									
								
							| 
						 | 
					@ -629,13 +629,25 @@ impl<'s> PrePass<'s> {
 | 
				
			||||||
                    let url = if !next_is_inline(&mut blocks) {
 | 
					                    let url = if !next_is_inline(&mut blocks) {
 | 
				
			||||||
                        "".into()
 | 
					                        "".into()
 | 
				
			||||||
                    } else {
 | 
					                    } else {
 | 
				
			||||||
                        let start = blocks.next().unwrap().span.of(src).trim();
 | 
					                        let start = blocks
 | 
				
			||||||
 | 
					                            .next()
 | 
				
			||||||
 | 
					                            .unwrap()
 | 
				
			||||||
 | 
					                            .span
 | 
				
			||||||
 | 
					                            .of(src)
 | 
				
			||||||
 | 
					                            .trim_matches(|c: char| c.is_ascii_whitespace());
 | 
				
			||||||
                        if !next_is_inline(&mut blocks) {
 | 
					                        if !next_is_inline(&mut blocks) {
 | 
				
			||||||
                            start.into()
 | 
					                            start.into()
 | 
				
			||||||
                        } else {
 | 
					                        } else {
 | 
				
			||||||
                            let mut url = start.to_string();
 | 
					                            let mut url = start.to_string();
 | 
				
			||||||
                            while next_is_inline(&mut blocks) {
 | 
					                            while next_is_inline(&mut blocks) {
 | 
				
			||||||
                                url.push_str(blocks.next().unwrap().span.of(src).trim());
 | 
					                                url.push_str(
 | 
				
			||||||
 | 
					                                    blocks
 | 
				
			||||||
 | 
					                                        .next()
 | 
				
			||||||
 | 
					                                        .unwrap()
 | 
				
			||||||
 | 
					                                        .span
 | 
				
			||||||
 | 
					                                        .of(src)
 | 
				
			||||||
 | 
					                                        .trim_matches(|c: char| c.is_ascii_whitespace()),
 | 
				
			||||||
 | 
					                                );
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                            url.into()
 | 
					                            url.into()
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
| 
						 | 
					@ -677,8 +689,11 @@ impl<'s> PrePass<'s> {
 | 
				
			||||||
                                text.push_str(ev.span.of(src));
 | 
					                                text.push_str(ev.span.of(src));
 | 
				
			||||||
                                let mut chars = ev.span.of(src).chars().peekable();
 | 
					                                let mut chars = ev.span.of(src).chars().peekable();
 | 
				
			||||||
                                while let Some(c) = chars.next() {
 | 
					                                while let Some(c) = chars.next() {
 | 
				
			||||||
                                    if c.is_whitespace() {
 | 
					                                    if c.is_ascii_whitespace() {
 | 
				
			||||||
                                        while chars.peek().map_or(false, |c| c.is_whitespace()) {
 | 
					                                        while chars
 | 
				
			||||||
 | 
					                                            .peek()
 | 
				
			||||||
 | 
					                                            .map_or(false, |c| c.is_ascii_whitespace())
 | 
				
			||||||
 | 
					                                        {
 | 
				
			||||||
                                            chars.next();
 | 
					                                            chars.next();
 | 
				
			||||||
                                        }
 | 
					                                        }
 | 
				
			||||||
                                        if !last_whitespace {
 | 
					                                        if !last_whitespace {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue