4 releases

0.2.2 Jul 25, 2024
0.2.1 Dec 23, 2021
0.2.0 Dec 23, 2021
0.1.0 May 28, 2018

#32 in Text processing

Download history 44457/week @ 2024-07-23 45209/week @ 2024-07-30 41003/week @ 2024-08-06 40727/week @ 2024-08-13 42622/week @ 2024-08-20 42261/week @ 2024-08-27 38487/week @ 2024-09-03 45044/week @ 2024-09-10 47095/week @ 2024-09-17 49273/week @ 2024-09-24 50620/week @ 2024-10-01 49527/week @ 2024-10-08 54091/week @ 2024-10-15 46957/week @ 2024-10-22 44600/week @ 2024-10-29 45062/week @ 2024-11-05

199,874 downloads per month
Used in 337 crates (15 directly)

MIT/Apache

25KB
260 lines

roff-rs

Documentation License crates.io

Roff generation library.

Examples

use roff::{bold, italic, roman, Roff};

fn main() {
    let page = Roff::new()
        .control("TH", ["CORRUPT", "1"])
        .control("SH", ["NAME"])
        .text([roman("corrupt - modify files by randomly changing bits")])
        .control("SH", ["SYNOPSIS"])
        .text([bold("corrupt"), roman(" ["), bold("-n"), roman(" "), italic("BITS"), roman("] ["),
               bold("--bits"), roman(" "), italic("BITS"), roman("] "), italic("FILE"), roman("..."),
        ])
        .control("SH", ["DESCRIPTION"])
        .text([bold("corrupt"), roman(" modifies files by toggling a randomly chosen bit.")])
        .control("SH", ["OPTIONS"])
        .control("TP", [])
        .text([bold("-n"), roman(", "), bold("--bits"), roman("="), italic("BITS")])
        .text([roman("Set the number of bits to modify. Default is one bit.")]);
        .render();
    print!("{}", page);

Which outputs:

.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.TH CORRUPT 1
.SH NAME
corrupt \- modify files by randomly changing bits
.SH SYNOPSIS
\fBcorrupt\fR [\fB\-n\fR \fIBITS\fR] [\fB\-\-bits\fR \fIBITS\fR] \fIFILE\fR...
.SH DESCRIPTION
\fBcorrupt\fR modifies files by toggling a randomly chosen bit.
.SH OPTIONS
.TP
\fB\-n\fR, \fB\-\-bits\fR=\fIBITS\fR
Set the number of bits to modify. Default is one bit.

Which will be shown by the man(1) command as:

CORRUPT(1)                 General Commands Manual                CORRUPT(1)

NAME
       corrupt - modify files by randomly changing bits

SYNOPSIS
       corrupt [-n BITS] [--bits BITS] FILE...

DESCRIPTION
       corrupt modifies files by toggling a randomly chosen bit.

OPTIONS
       -n, --bits=BITS
              Set the number of bits to modify. Default is one bit.

                                                                  CORRUPT(1)

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

No runtime deps