use crate::helpers::re;
use regex::Captures;
fn index_of_capture(value: &str) -> usize {
match value.chars().nth(0).unwrap() {
'*' => 1,
'_' => 2,
_ => panic!("Marcus: ParseError: Emphasis match doesn't start with \"*\" or \"_\".")
}
}
fn capture_or_html(text: &str, capture: &str, html: String) -> String {
if text.len() < 1 { capture.to_string() } else { html }
}
pub fn default(html: &mut String) {
re::parse(html, re::from(re::EMPHASIS_BOLD_ITALIC), | capture: Captures | {
let text: &str = capture[index_of_capture(&capture[0])].trim();
capture_or_html(&text, &capture[0], format!("<b><i>{}</i></b>", text))
});
re::parse(html, re::from(re::EMPHASIS_BOLD), | capture: Captures | {
let text: &str = capture[index_of_capture(&capture[0])].trim();
capture_or_html(&text, &capture[0], format!("<b>{}</b>", text))
});
re::parse(html, re::from(re::EMPHASIS_ITALIC), | capture: Captures | {
let text: &str = capture[index_of_capture(&capture[0])].trim();
capture_or_html(&text, &capture[0], format!("<i>{}</i>", text))
});
}