linurgy
Rust library to manipulate multiple newlines.
Create a new String with your edited text, or use buffers to pipe input and output into the
Editor. This library has no additional dependencies.
Using linurgy
Build a reusable Editor with one of the convenient factory functions. Use the edit method to
create a new String.
use factory;
// appends an underscore "_" every 2 newlines "\n\n" => "\n\n_"
let editor = appender;
let output = editor.edit;
assert_eq!;
Manipulate stdin into stdout by using the edit_buffered method. This also works on files,
Cursors, or anything else that implements
BufRead.
use factory;
use ;
// doubles every newline "\n" => "\n\n"
let editor = appender;
// create a buffer over stdin
let mut input = new;
// pipe input into editor and output to stdout
editor.edit_buffered?;
Work with LF \n or CRLF \r\n line-endings. There are factory functions for CRLF inputs.
use factory;
// inserts a "*" before 2 newlines "\r\n\r\n" => "*\r\n\r\n"
let editor = inserter_crlf;
let output = editor.edit;
// notice there is only an asterisk before the double newline
assert_eq!;
Contributing
Thank you very much for considering to contribute to this project!
We welcome any form of contribution:
- New issues (feature requests, bug reports, questions, ideas, ...)
- Pull requests (documentation improvements, code improvements, new features, ...)
Note: Before you take the time to open a pull request, please open an issue first.
See CONTRIBUTING.md for details.
License
Linurgy is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT for details.