use super::marky::Marky;

pub fn marky_to_html (marky: Marky) -> String {
  let mut html = String::new();

  for line in marky.content.lines() {
    if line.starts_with("####") {
      html.push_str("<h4>");
      html.push_str(&line.to_owned());
      html.push_str("</h4>");

    } else if line.starts_with("###") {
      html.push_str("<h3>");
      html.push_str(&line.to_owned());
      html.push_str("</h3>");

    } else if line.starts_with("##") {
      html.push_str("<h2>");
      html.push_str(&line.to_owned());
      html.push_str("</h2>");

    } else if line.starts_with("#") {
      html.push_str("<h1>");
      html.push_str(&line.to_owned());
      html.push_str("</h1>");

    } else if line.starts_with("*") || line.starts_with("-") {
      html.push_str("<h1>");
      html.push_str(&line.to_owned());
      html.push_str("</h1>");

    } else {
      html.push_str("<p>");
      html.push_str(&line.to_owned());
      html.push_str("</p>");
    }
  }

  return html;
}