bokuweb/docx-rs

Macros for commonly created objects

Opened this issue · 0 comments

Is your feature request related to a problem? Please describe.

It is quite a pain to create things like paragraphs or table cells. For example if you need to create a bunch of paragraphs you have to do
Paragraph::new().add_run(Run::new().add_text("Text")); over and over again

Describe the solution you'd like

It would be great if there were macros for that. For example, here's my macro for creating a paragraph:

#[macro_export]
macro_rules! paragraph {
    ($text:expr) => {
        paragraph!($text, AlignmentType::Center)
    };
    ($text:expr,$align:expr) => {
        Paragraph::new()
            .add_run(Run::new().add_text($text))
            .align($align)
    };
}

With this macro i can just do paragraph!("Text"); which is just so much nicer