]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/markdown/nodes/ListNode.java
Markdown to HTML generator has now genration options
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / markdown / nodes / ListNode.java
1 package org.simantics.scl.compiler.markdown.nodes;
2
3 import org.simantics.scl.compiler.markdown.html.HtmlGenerationContext;
4
5 public class ListNode extends Node {
6     public char bulletChar;
7     public boolean tight;
8     public int start;
9     
10     public ListNode(char bulletChar) {
11         this.bulletChar = bulletChar;
12     }
13
14     public ListNode(char bulletChar, int start) {
15         this.bulletChar = bulletChar;
16         this.start = start;
17     }
18
19     @Override
20     public boolean canContain(Node node) {
21         return node instanceof ItemNode;
22     }
23
24     public boolean isCompatible(char bulletChar) {
25         return bulletChar == this.bulletChar;
26     }
27     
28     @Override
29     public void toHtml(HtmlGenerationContext context, StringBuilder b) {
30         if(bulletChar == '+' || bulletChar == '-' || bulletChar == '*') {
31             b.append("<ul>\n");
32             for(Node child = firstChild; child != null; child = child.next)
33                 ((ItemNode)child).toHtml(context, b, tight);
34             b.append("</ul>\n");
35         }
36         else {
37             if(start == 1)
38                 b.append("<ol>\n");
39             else
40                 b.append("<ol start=\"").append(start).append("\">\n");
41             for(Node child = firstChild; child != null; child = child.next)
42                 ((ItemNode)child).toHtml(context, b, tight);
43             b.append("</ol>\n");
44         }
45     }
46 }