public function parseFragment(HTML5_Inputstream_Interface $input) {
        $events = new HTML5_Parser_DOMTreeBuilder(true, $this->options);
        $scanner = new HTML5_Parser_Scanner($input);
        $parser = new HTML5_Parser_Tokenizer($scanner, $events);

        $parser->parse();
        $this->errors = $events->getErrors();

        return $events->fragment();
    }