Commits

shemnon committed b6869ce

support numbered node

Comments (0)

Files changed (1)

markdown-node/src/main/java/org/bitbucket/shemnon/mdnode/MarkdownVisitor.java

     Map<String, ReferenceNode> references = new HashMap<>();
     Pane currentCollector;
 
+    LinkedList<Integer> listCount = new LinkedList<>();
+
     void pushNode(Pane n) {
         nodeStack.push(n);
         currentCollector = n;
     @Override
     public void visit(BulletListNode node) {
         startListBox(MarkdownToNodeGenerator.STYLE_CLASS_UNORDERED_LIST);
+        listCount.push(null);
         visitChildren(node);
+        listCount.pop();
         stopListBox();
     }
 
     @Override
     public void visit(OrderedListNode node) {
         startListBox(MarkdownToNodeGenerator.STYLE_CLASS_ORDERED_LIST);
+        listCount.push(1);
         visitChildren(node);
+        listCount.pop();
         stopListBox();
     }
 
     @Override
     public void visit(ListItemNode node) {
-        startListRow("\u2022");
+        String bullet = "\u2022";
+        if (listCount.peek() != null) {
+            int i = listCount.pop();
+            bullet = Integer.toString(i) + ". ";
+            listCount.push(++i);
+        }
+        startListRow(bullet);
         visitChildren(node);
         stopListRow();
     }