Crate blockcounter [] [src]

A crate to count blocks in plain text.

Consider a block a set of lines separated by a given number of empty lines.

Example

extern crate blockcounter;
use blockcounter::{count_blocks, Blocks, clean};

fn main() {
    let text = "0\n1\n\n2\n\n\n3\n\n".to_string();
    println!("{}", text);
    println!("===========");
    println!("text has {} blocks.", count_blocks(2, text.as_bytes()));
    println!("======================");
    println!("");
    
    for block in Blocks::new(2, text.as_bytes()) {
        print!("{}", clean(&block));
        println!("=============");
    }
}

Structs

Blocks

Functions

blank_lines [
Deprecated
]
clean

Removes blank lines at the beginnig and at the end of a String.

clean_all_blank

Removes all blank lines of a String.

count_blocks

Given a tolerance input, returns the number of blocks is a stream.

Type Definitions

Block [
Deprecated
]