Closed wwood closed 2 years ago
I'm trying to figure out if this works within the new API which is fundamentally different than the old one. It isn't intended for dealing with nesting but is meant to be a lower level sequence of roff directives. For example, our rendering of font selections is specialized for newlines.
btw I've not seen \f[C]
yet in the docs I've found. Where can I read more on []
with \f
?
Isn't it just something along these lines:
impl fmt::Display for Inline {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}",
match self {
Bold(s) =>format!("\fB{}\fR", s),
...
})
}
}
Maybe I'm confused.
Sorry can't remember where I got the monospace code from. Possibly it is just a hack to make it look like monospace in HTML when converting roff -> markdown -> HTML, since all man page text is monospace I think. Maybe a suggestion of mine best ignored. Here's a concrete example of how I use it: https://github.com/wwood/CoverM/blob/main/release.sh#L39
Thanks.
See https://github.com/rust-cli/roff-rs/blob/master/src/lib.rs#L271 for where we specialize the behavior
Right, but making use of that would require a Line struct to be generated, just for the purposes of rendering. I suppose I was thinking that Line's render() could call the Inline's Display method.
Seems you disagree, so OK. No problem. I will workaround.
Hi,
I find this crate helpful, because I can use roff to generate a man page, and also convert the roff to a prettyish HTML for online help. Thanks.
In the 0.1 version of this crate, I was able to do things like this:
However, in the current version, that fails because
bold
now returns an Inline, and Inline doesn't implementDisplay
. Would it be possible to impl that? Otherwise I'm stuck doing hacks like this:Also, come to think of it, maybe would be worth implementing monospace_roff in this crate? My impl is
Thanks in advance, ben