pub fn scan(document: &str) -> Result<Vec<Block>, Error> {
    let mut blocks = vec![];

    let document = kuchiki::parse_html().one(document);

    let mut text_nodes = document.descendants().text_nodes();

    loop {
        if let Some(text_node) = text_nodes.next() {
            // This filters for text block separating tags only
            let tag = match text_block_tag(&text_node) {
                Ok(t) => t,
                Err(_) => { continue; },
            };

            if tag == BlockTag::A {
                concat_or_push_anchor(text_node, &mut text_nodes, &mut blocks)?;
            } else {
                push_block(tag, text_node, &mut blocks);
            }
        } else {
            // reach the end of text_nodes
            break;
        }
    }

    Ok(blocks)
}
/// Produces text block with features (in this case, just word count)
Produces text block with features (in this case, just word count)
Produces text block with features ( in this case just word count )
pub fn scan(document: &str) -> Result<Vec<Block>, Error> {
    let mut blocks = vec![];
    let document = kuchiki::parse_html().one(document);
    let mut text_nodes = document.descendants().text_nodes();
    loop {
        if let Some(text_node) = text_nodes.next() {
            // This filters for text block separating tags only
            let tag = match text_block_tag(&text_node) {
                Ok(t) => t,
                Err(_) => { continue; },
            };
            if tag == BlockTag::A {
                concat_or_push_anchor(text_node, &mut text_nodes, &mut blocks)?;
            } else {
                push_block(tag, text_node, &mut blocks);
            }
        } else {
            // reach the end of text_nodes
            break;
        }
    }
    Ok(blocks)
}
pub fn scan ( document : & str ) -> Result < Vec < Block > , Error > { let mut blocks = vec ! [ ] ; let document = kuchiki :: parse_html ( ) . one ( document ) ; let mut text_nodes = document . descendants ( ) . text_nodes ( ) ; loop { if let Some ( text_node ) = text_nodes . next ( ) { // This filters for text block separating tags only let tag = match text_block_tag ( & text_node ) { Ok ( t ) => t , Err ( _ ) => { continue ; } , } ; if tag == BlockTag :: A { concat_or_push_anchor ( text_node , & mut text_nodes , & mut blocks ) ? ; } else { push_block ( tag , text_node , & mut blocks ) ; } } else { // reach the end of text_nodes break ; } } Ok ( blocks ) }
Produces text block with features (in this case, just word count)
Produces text block with features ( in this case just word count )
document
&str
document
&str