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 |
#1562 in Text processing
Used in 2 crates
12KB
284 lines
blockcounter
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!("=============");
}
}