package org.simantics.scl.compiler.markdown.nodes; import org.simantics.scl.compiler.markdown.html.HtmlGenerationContext; public class ItemNode extends Node { public int indentation; public ItemNode(int indentation) { this.indentation = indentation; } @Override public boolean canContain(Node node) { return true; } public void toHtml(HtmlGenerationContext context, StringBuilder b) { toHtml(context, b, true); } public void toHtml(HtmlGenerationContext context, StringBuilder b, boolean tight) { if(firstChild == null) { b.append("
  • \n"); return; } else if(tight) { b.append("
  • "); // This code assumes that there are no consecutive paragraphs boolean noNewline = true; for(Node child = firstChild; child != null; child = child.next) { if(child instanceof ParagraphNode) { for(Node n=child.firstChild;n!=null;n=n.next) n.toHtml(context, b); noNewline = true; } else { if(noNewline) { b.append('\n'); noNewline = false; } child.toHtml(context, b); } } b.append("
  • \n"); } else { b.append("
  • \n"); super.toHtml(context, b); b.append("
  • \n"); } } }