@@ -529,6 +529,7 @@ macro_rules! shorthand (
529
529
( $me: ident : create_tag $kind: ident $c: expr ) => ( $me. create_tag( $kind, $c) ; ) ;
530
530
( $me: ident : push_tag $c: expr ) => ( $me. current_tag_name. push( $c) ; ) ;
531
531
( $me: ident : discard_tag ) => ( $me. discard_tag( ) ; ) ;
532
+ ( $me: ident : discard_char ) => ( $me. discard_char( ) ; ) ;
532
533
( $me: ident : push_temp $c: expr ) => ( $me. temp_buf. push( $c) ; ) ;
533
534
( $me: ident : emit_temp ) => ( $me. emit_temp_buf( ) ; ) ;
534
535
( $me: ident : clear_temp ) => ( $me. clear_temp_buf( ) ; ) ;
@@ -613,6 +614,10 @@ macro_rules! get_char ( ($me:expr) => (
613
614
unwrap_or_return!( $me. get_char( ) , false )
614
615
) ) ;
615
616
617
+ macro_rules! peek ( ( $me: expr) => (
618
+ unwrap_or_return!( $me. peek( ) , false )
619
+ ) ) ;
620
+
616
621
macro_rules! pop_except_from ( ( $me: expr, $set: expr) => (
617
622
unwrap_or_return!( $me. pop_except_from( $set) , false )
618
623
) ) ;
@@ -912,18 +917,16 @@ impl<Sink: TokenSink> Tokenizer<Sink> {
912
917
} } ,
913
918
914
919
//§ before-attribute-value-state
915
- states:: BeforeAttributeValue => loop { match get_char ! ( self ) {
916
- '\t' | '\n' | '\x0C' | ' ' => ( ) ,
917
- '"' => go ! ( self : to AttributeValue DoubleQuoted ) ,
918
- '&' => go ! ( self : reconsume AttributeValue Unquoted ) ,
919
- '\'' => go ! ( self : to AttributeValue SingleQuoted ) ,
920
- '\0' => go ! ( self : error; push_value '\u{fffd}' ; to AttributeValue Unquoted ) ,
921
- '>' => go ! ( self : error; emit_tag Data ) ,
922
- c => {
923
- go_match ! ( self : c,
924
- '<' , '=' , '`' => error) ;
925
- go ! ( self : push_value c; to AttributeValue Unquoted ) ;
926
- }
920
+ // Use peek so we can handle the first attr character along with the rest,
921
+ // hopefully in the same zero-copy buffer.
922
+ states:: BeforeAttributeValue => loop { match peek ! ( self ) {
923
+ '\t' | '\n' | '\r' | '\x0C' | ' ' => go ! ( self : discard_char) ,
924
+ '"' => go ! ( self : discard_char; to AttributeValue DoubleQuoted ) ,
925
+ '&' => go ! ( self : to AttributeValue Unquoted ) ,
926
+ '\'' => go ! ( self : discard_char; to AttributeValue SingleQuoted ) ,
927
+ '\0' => go ! ( self : discard_char; error; push_value '\u{fffd}' ; to AttributeValue Unquoted ) ,
928
+ '>' => go ! ( self : discard_char; error; emit_tag Data ) ,
929
+ _ => go ! ( self : to AttributeValue Unquoted ) ,
927
930
} } ,
928
931
929
932
//§ attribute-value-(double-quoted)-state
0 commit comments