pub struct Roff { /* private fields */ }Expand description
A ROFF document, consisting of lines.
Lines are either control lines (requests that are built in, or invocations of macros), or text lines.
§Example
let doc = Roff::new()
.control("TH", ["FOO", "1"])
.control("SH", ["NAME"])
.text([roman("foo - do a foo thing")])
.render();
assert!(doc.ends_with(".TH FOO 1\n.SH NAME\nfoo \\- do a foo thing\n"));Implementations§
Source§impl Roff
impl Roff
Sourcepub fn control<'a>(
&mut self,
name: impl Into<String>,
args: impl IntoIterator<Item = &'a str>,
) -> &mut Self
pub fn control<'a>( &mut self, name: impl Into<String>, args: impl IntoIterator<Item = &'a str>, ) -> &mut Self
Append a control line.
The line consist of the name of a built-in command or macro, and some number of arguments. Arguments that contain spaces will be enclosed with double quotation marks.
Sourcepub fn text(&mut self, inlines: impl Into<Vec<Inline>>) -> &mut Self
pub fn text(&mut self, inlines: impl Into<Vec<Inline>>) -> &mut Self
Append a text line.
The line will be rendered in a way that ensures it can’t be
interpreted as a control line. The caller does not need to
ensure, for example, that the line doesn’t start with a
period (“.”) or an apostrophe (“'”).
Sourcepub fn render(&self) -> String
pub fn render(&self) -> String
Render as ROFF source text that can be fed to a ROFF implementation.
Sourcepub fn to_roff(&self) -> String
pub fn to_roff(&self) -> String
Render without handling apostrophes specially.
You probably want render or
to_writer instead of this method.
Without special handling, apostrophes get typeset as right single quotes, including in words like “don’t”. In most situations, such as in manual pages, that’s unwanted. The other methods handle apostrophes specially to prevent it, but for completeness, and for testing, this method is provided to avoid it.
Trait Implementations§
Source§impl<R: Into<Roff>> Extend<R> for Roff
impl<R: Into<Roff>> Extend<R> for Roff
Source§fn extend<T: IntoIterator<Item = R>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = R>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)