@@ -18,11 +18,11 @@ use std::collections::HashMap;
1818use std:: borrow:: Cow ;
1919use string_cache:: QualName ;
2020
21- use tendril:: { ByteTendril , StrTendril , ReadExt } ;
21+ use tendril:: { StrTendril , TendrilSink } ;
2222
23- use html5ever:: { parse_to, one_input} ;
2423use html5ever:: tokenizer:: Attribute ;
2524use html5ever:: tree_builder:: { TreeSink , QuirksMode , NodeOrText , AppendNode , AppendText } ;
25+ use html5ever:: parse_document;
2626
2727struct Sink {
2828 next_id : usize ,
@@ -39,6 +39,8 @@ impl Sink {
3939
4040impl TreeSink for Sink {
4141 type Handle = usize ;
42+ type Output = Self ;
43+ fn finish ( self ) -> Self { self }
4244
4345 fn parse_error ( & mut self , msg : Cow < ' static , str > ) {
4446 println ! ( "Parse error: {}" , msg) ;
@@ -143,9 +145,9 @@ fn main() {
143145 next_id : 1 ,
144146 names : HashMap :: new ( ) ,
145147 } ;
146-
147- let mut input = ByteTendril :: new ( ) ;
148- io :: stdin ( ) . read_to_tendril ( & mut input ) . unwrap ( ) ;
149- let input = input . try_reinterpret ( ) . unwrap ( ) ;
150- parse_to ( sink , one_input ( input ) , Default :: default ( ) ) ;
148+ let stdin = io :: stdin ( ) ;
149+ parse_document ( sink , Default :: default ( ) )
150+ . from_utf8 ( )
151+ . read_from ( & mut stdin . lock ( ) )
152+ . unwrap ( ) ;
151153}
0 commit comments