Michael-F-Bryan / latex-rs

An ergonomic library for programatically generating LaTeX documents and reports.
MIT License
54 stars 16 forks source link

Pull the rendering out into a generic visitor trait #3

Closed Michael-F-Bryan closed 7 years ago

Michael-F-Bryan commented 7 years ago

The current system where each node renders itself using the Renderable trait isn't very extensible. In an ideal world, you'd have a generic Visitor trait which lets you walk the entire document tree, using default impls to make your life easier.

The Renderable trait now just turns into some Printer object which will visit each node, printing them to a Writer. This allows you to do more complex things like a preprocessing pass to ensure you pull in all the packages you need (e.g. walk the tree then if you see a Table node you'll make sure to include booktabs in the preamble) and other manipulations before printing to the final document.