7 releases

Uses old Rust 2015

0.3.2 Jul 17, 2018
0.3.1 Jan 25, 2018
0.3.0 Dec 31, 2017
0.2.4 Dec 27, 2017

#1362 in Text processing

Download history 14/week @ 2023-11-02 15/week @ 2023-11-09 22/week @ 2023-11-16 21/week @ 2023-11-23 29/week @ 2023-11-30 18/week @ 2023-12-07 18/week @ 2023-12-14 24/week @ 2023-12-21 16/week @ 2023-12-28 11/week @ 2024-01-04 14/week @ 2024-01-11 17/week @ 2024-01-18 21/week @ 2024-01-25 19/week @ 2024-02-01 30/week @ 2024-02-08 86/week @ 2024-02-15

164 downloads per month
Used in 2 crates

MIT license

12KB
284 lines

blockcounter

Version info Build Status Build status

Count blocks in a text.

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!("=============");
    }
}

lib.rs:

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!("=============");
}
}

No runtime deps