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