[−][src]Macro shoebill::compose
Macro for allowing more pleasant composition items that implement Doclike
using
more familiar operators.
The infix operators (which are all left-associtive, but allow for grouping w/ parentheses)
//`a <> b` : Concat(a, b) //`a <n> b` : Concat(a, Concat(newline, b)) //`a <s> b` : Concat(a, Concat(" ", b)) (concat with a space) //`a <h> b` : Concat(a, Concat(" ", b)) (concat with Hardline) //`n @ ds` : prefix ds with a newline //`g @ ds` : make ds a group //`<any u32> @ ds` : nest ds by whatever the amount specified by the integer literal.
There are some issues I need to come back to
that aren't bugs, but certain things like "x" (n @ (<s> "y"))
don't work like
one might expect them to.
use shoebill::{ compose, Printer, Doclike }; let mut store = Printer::new(); let d = compose!(&mut store ; "this" <s> "is" <s> "text"); assert_eq!(format!("{}", d.render(80, &mut store)), format!("this is text"));