// Path: src/main/java/com/aestasit/markdown/visitors/BaseVisitor.java
// public abstract class BaseVisitor implements Visitor {
// 
//   protected int                 level = 0;
//   protected final static Logger LOG   = LoggerFactory.getLogger(BaseVisitor.class);
// 
//   protected void visitChildren(final Node node) {
//     level++;
//     for (final Node child : node.getChildren()) {
//       if (child instanceof RootNode) {
//         visitChildren(child);
//       } else {
//         child.accept(this);
//       }
//     }
//     level--;
//   }
// 
//   protected void unknownNode(final Node node) {
//     LOG.error(">>> UNKNOWN NODE: " + node);
//   }
// 
//   protected void logNode(Node node) {
//     LOG.debug(StringUtils.repeat(" ", level) + node.toString());
//   }
// 
// }
// 
// Path: src/main/java/com/aestasit/markdown/slidery/ToHtmlSlides.java
// protected enum SlideComponent {
//   NONE, CONTENT, NOTES
// }


import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.parboiled.common.StringUtils;
import org.pegdown.LinkRenderer;
import org.pegdown.Printer;
import org.pegdown.ast.AbbreviationNode;
import org.pegdown.ast.AutoLinkNode;
import org.pegdown.ast.BlockQuoteNode;
import org.pegdown.ast.BulletListNode;
import org.pegdown.ast.CodeNode;
import org.pegdown.ast.DefinitionListNode;
import org.pegdown.ast.DefinitionNode;
import org.pegdown.ast.DefinitionTermNode;
import org.pegdown.ast.EmphNode;
import org.pegdown.ast.ExpImageNode;
import org.pegdown.ast.ExpLinkNode;
import org.pegdown.ast.HeaderNode;
import org.pegdown.ast.HtmlBlockNode;
import org.pegdown.ast.InlineHtmlNode;
import org.pegdown.ast.ListItemNode;
import org.pegdown.ast.MailLinkNode;
import org.pegdown.ast.Node;
import org.pegdown.ast.OrderedListNode;
import org.pegdown.ast.ParaNode;
import org.pegdown.ast.QuotedNode;
import org.pegdown.ast.RefImageNode;
import org.pegdown.ast.RefLinkNode;
import org.pegdown.ast.ReferenceNode;
import org.pegdown.ast.RootNode;
import org.pegdown.ast.SimpleNode;
import org.pegdown.ast.SpecialTextNode;
import org.pegdown.ast.StrongNode;
import org.pegdown.ast.SuperNode;
import org.pegdown.ast.TableBodyNode;
import org.pegdown.ast.TableCellNode;
import org.pegdown.ast.TableColumnNode;
import org.pegdown.ast.TableHeaderNode;
import org.pegdown.ast.TableNode;
import org.pegdown.ast.TableRowNode;
import org.pegdown.ast.TextNode;
import org.pegdown.ast.VerbatimNode;
import org.pegdown.ast.Visitor;
import org.pegdown.ast.WikiLinkNode;
import com.aestasit.markdown.visitors.BaseVisitor;
import com.google.common.base.Preconditions;
import static com.aestasit.markdown.slidery.ToHtmlSlides.SlideComponent.*;
      endSlide();
    }
    printer.indent(-2).println().print("</body>");

  }

  public void visit(HeaderNode node) {
    if (node.getLevel() == 1) {
      endSlide();
      startSlide();
      printer.println();
      String headerText = printChildrenToString(node);
      if (!"-".equals(headerText.trim())) {
        printTag(node, "header");
      }
      startSlideContent();
    } else {
      printer.println();
      printTag(node, "h" + node.getLevel());
    }
  }

  private void startSlide() {
    if (!inFirstSlide) {
      printer.println().print("<section>").indent(+2);
    }
    inFirstSlide = false;
    currentSlideComponent = NONE;
  }

// Path: src/main/java/com/aestasit/markdown/visitors/BaseVisitor.java
// public abstract class BaseVisitor implements Visitor {
// 
//   protected int                 level = 0;
//   protected final static Logger LOG   = LoggerFactory.getLogger(BaseVisitor.class);
// 
//   protected void visitChildren(final Node node) {
//     level++;
//     for (final Node child : node.getChildren()) {
//       if (child instanceof RootNode) {
//         visitChildren(child);
//       } else {
//         child.accept(this);
//       }
//     }
//     level--;
//   }
// 
//   protected void unknownNode(final Node node) {
//     LOG.error(">>> UNKNOWN NODE: " + node);
//   }
// 
//   protected void logNode(Node node) {
//     LOG.debug(StringUtils.repeat(" ", level) + node.toString());
//   }
// 
// }
// 
// Path: src/main/java/com/aestasit/markdown/slidery/ToHtmlSlides.java
// protected enum SlideComponent {
//   NONE, CONTENT, NOTES
// }


// Path: src/main/java/com/aestasit/markdown/slidery/ToHtmlSlides.java
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.parboiled.common.StringUtils;
import org.pegdown.LinkRenderer;
import org.pegdown.Printer;
import org.pegdown.ast.AbbreviationNode;
import org.pegdown.ast.AutoLinkNode;
import org.pegdown.ast.BlockQuoteNode;
import org.pegdown.ast.BulletListNode;
import org.pegdown.ast.CodeNode;
import org.pegdown.ast.DefinitionListNode;
import org.pegdown.ast.DefinitionNode;
import org.pegdown.ast.DefinitionTermNode;
import org.pegdown.ast.EmphNode;
import org.pegdown.ast.ExpImageNode;
import org.pegdown.ast.ExpLinkNode;
import org.pegdown.ast.HeaderNode;
import org.pegdown.ast.HtmlBlockNode;
import org.pegdown.ast.InlineHtmlNode;
import org.pegdown.ast.ListItemNode;
import org.pegdown.ast.MailLinkNode;
import org.pegdown.ast.Node;
import org.pegdown.ast.OrderedListNode;
import org.pegdown.ast.ParaNode;
import org.pegdown.ast.QuotedNode;
import org.pegdown.ast.RefImageNode;
import org.pegdown.ast.RefLinkNode;
import org.pegdown.ast.ReferenceNode;
import org.pegdown.ast.RootNode;
import org.pegdown.ast.SimpleNode;
import org.pegdown.ast.SpecialTextNode;
import org.pegdown.ast.StrongNode;
import org.pegdown.ast.SuperNode;
import org.pegdown.ast.TableBodyNode;
import org.pegdown.ast.TableCellNode;
import org.pegdown.ast.TableColumnNode;
import org.pegdown.ast.TableHeaderNode;
import org.pegdown.ast.TableNode;
import org.pegdown.ast.TableRowNode;
import org.pegdown.ast.TextNode;
import org.pegdown.ast.VerbatimNode;
import org.pegdown.ast.Visitor;
import org.pegdown.ast.WikiLinkNode;
import com.aestasit.markdown.visitors.BaseVisitor;
import com.google.common.base.Preconditions;
import static com.aestasit.markdown.slidery.ToHtmlSlides.SlideComponent.*;

      endSlide();
    }
    printer.indent(-2).println().print("</body>");

  }

  public void visit(HeaderNode node) {
    if (node.getLevel() == 1) {
      endSlide();
      startSlide();
      printer.println();
      String headerText = printChildrenToString(node);
      if (!"-".equals(headerText.trim())) {
        printTag(node, "header");
      }
      startSlideContent();
    } else {
      printer.println();
      printTag(node, "h" + node.getLevel());
    }
  }

  private void startSlide() {
    if (!inFirstSlide) {
      printer.println().print("<section>").indent(+2);
    }
    inFirstSlide = false;
    currentSlideComponent = NONE;
  }

  private void startSlideContent() {