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
/// The adapter that allows rendering markdown inside a `maud` macro.
///
/// # Examples
///
#[cfg_attr(feature = "nightly", doc = " ```")]
#[cfg_attr(not(feature = "nightly"), doc = " ```ignore")]
/// # #![feature(plugin)]
/// # #![plugin(maud_macros)]
/// # extern crate maud;
/// # extern crate maud_pulldown_cmark;
/// # use maud_pulldown_cmark::Markdown;
/// # fn main() {
/// let markdown = "
///  1. A list
///  2. With some
///  3. Values
/// ";
///
/// let mut buffer = String::new();
///
/// html!(buffer, {
///   div {
///     $(Markdown::FromString(markdown))
///   }
/// }).unwrap();
///
/// println!("{}", buffer);
/// # }
/// ```

pub enum Markdown<'a> {
  /// To allow rendering from a string.
  FromString(&'a str),
}

#[cfg(test)]
mod tests {
  #[test]
  pub fn test() {
    use maud::Render;
    use super::Markdown;

    let markdown = "
 1. A list
 2. With some
 3. Values
    ";

    let mut buffer = String::new();
    Markdown::FromString(markdown).render(&mut buffer).unwrap();
    assert_eq!(buffer, "<ol>\n<li>A list</li>\n<li>With some</li>\n<li>Values</li>\n</ol>\n");
  }
}