1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54


/// print a markdown template, with other arguments taking `$0` to `$9` places in the template.
///
/// Example:
///
/// ```
/// use lazy_static::lazy_static;
/// use minimad::mad_inline;
/// use termimad::*;
///
/// let skin = MadSkin::default();
/// mad_print_inline!(
/// 	&skin,
/// 	"**$0 formula:** *$1*", // the markdown template, interpreted once
/// 	"Disk",  // fills $0
/// 	"2*π*r", // fills $1. Note that the stars don't mess the markdown
/// );
/// ```
#[macro_export]
macro_rules! mad_print_inline {
    ($skin: expr, $md: literal $(, $value: expr )* $(,)? ) => {
        $skin.print_composite(mad_inline!($md $(, $value)*));
    };
}

/// write a markdown template, with other arguments taking `$0` to `$9` places in the template.
///
/// Example:
///
/// ```
/// use lazy_static::lazy_static;
/// use minimad::mad_inline;
/// use termimad::*;
///
/// let skin = MadSkin::default();
/// mad_write_inline!(
/// 	&mut std::io::stdout(),
/// 	&skin,
/// 	"**$0 formula:** *$1*", // the markdown template, interpreted once
/// 	"Disk",  // fills $0
/// 	"2*π*r", // fills $1. Note that the stars don't mess the markdown
/// ).unwrap();
/// ```
#[macro_export]
macro_rules! mad_write_inline {
    ($w: expr, $skin: expr, $md: literal $(, $value: expr )* $(,)? ) => {{
        use std::io::Write;
        $skin.write_composite($w, mad_inline!($md $(, $value)*))
    }};
}