linurgy 0.1.2

Manipulate the output of multiple newlines. Replace/Insert/Append newlines with any string. Input and output from stdio/files/buffers.
Documentation

linurgy

Crates.io Documentation Build Status

Rust library to manipulate multiple newlines. Works with stdin and stdout, files, and buffers. No dependencies.

Linurgy provides an interface for manipulating multiple newlines in text. Interaction with this library happens through LinurgyBuilder.

Examples

Read stdin and for each empty line, append an extra line to stdout.

use linurgy::LinurgyBuilder;

LinurgyBuilder::new()
    .set_newline_trigger(1)
    .set_new_text(String::from("\n"))
    .run();

Read from one buffer, remove all empty lines, and output to another buffer.

use linurgy::{LinurgyBuilder, Input, Output, EditType};

let input = String::from("Remove\n\nEvery\n\nEmpty\n\nLine\n");
let mut output = String::new();

LinurgyBuilder::new()
    .set_input(Input::Buffer(&input))
    .set_output(Output::Buffer(&mut output))
    .set_newline_trigger(1)
    .set_edit_type(EditType::Replace)
    .set_new_text(String::from(""))
    .run();

assert_eq!("Remove\nEvery\nEmpty\nLine\n", &output);