+fn get_heading_wrapper(heading_stack: &mut Vec<u8>, line_type: &LineType) -> String {
+ let mut string = String::new();
+ let current_heading: u8 = match line_type {
+ LineType::Heading1 => 1,
+ LineType::Heading2 => 2,
+ LineType::Heading3 => 3,
+ _ => 255
+ };
+
+ if current_heading < 255 {
+ while let Some(open_heading) = heading_stack.pop() {
+ // You just encountered a more important heading.
+ // Put it back. Desist.
+ if open_heading < current_heading {
+ heading_stack.push(open_heading);
+ break;
+ }
+
+ string.push_str("</div>");
+
+ if open_heading == current_heading {
+ break;
+ }
+ }
+ heading_stack.push(current_heading);
+ string.push_str(&format!("<div class=\"h{}\">", current_heading));
+ }
+
+ return string;
+}
+
+fn close_heading_wrapper(heading_stack: &mut Vec<u8>) -> String {
+ let mut string = String::new();
+ while let Some(_open_heading) = heading_stack.pop() {
+ string.push_str("</div>");
+ }
+ return string;
+}
+