Update to the new template
[from now] 2014/08/05 18:00:14

diff --git a/src/main/groovy/gaiden/markdown/GaidenMarkdownProcessor.groovy b/src/main/groovy/gaiden/markdown/GaidenMarkdownProcessor.groovy
index 39ef3c0..6a76edf 100644
--- a/src/main/groovy/gaiden/markdown/GaidenMarkdownProcessor.groovy
+++ b/src/main/groovy/gaiden/markdown/GaidenMarkdownProcessor.groovy
@@ -25,6 +25,45 @@ import groovy.transform.CompileStatic
 import org.pegdown.Extensions
 import org.pegdown.ParsingTimeoutException
 import org.pegdown.PegDownProcessor
+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.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.StrikeNode
+import org.pegdown.ast.StrongEmphSuperNode
+import org.pegdown.ast.SuperNode
+import org.pegdown.ast.TableBodyNode
+import org.pegdown.ast.TableCaptionNode
+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 org.springframework.beans.factory.annotation.Autowired
 import org.springframework.stereotype.Component

diff --git a/src/main/groovy/gaiden/markdown/GaidenToHtmlSerializer.groovy b/src/main/groovy/gaiden/markdown/GaidenToHtmlSerializer.groovy
index f4749cb..3d0b41c 100644
--- a/src/main/groovy/gaiden/markdown/GaidenToHtmlSerializer.groovy
+++ b/src/main/groovy/gaiden/markdown/GaidenToHtmlSerializer.groovy
@@ -20,6 +20,8 @@ import groovy.transform.CompileStatic
 import org.pegdown.LinkRenderer
 import org.pegdown.Printer
 import org.pegdown.ToHtmlSerializer
+import org.pegdown.ast.HeaderNode
+import org.pegdown.ast.Node

 /**
  * A Serializer for rendering nodes to HTML.
@@ -32,6 +34,8 @@ class GaidenToHtmlSerializer extends ToHtmlSerializer {

     private ImageRenderer imageRenderer

+    private Map headers = []
+
     GaidenToHtmlSerializer(LinkRenderer linkRenderer, ImageRenderer imageRenderer) {
         super(linkRenderer)
         this.imageRenderer = imageRenderer
@@ -43,6 +47,15 @@ class GaidenToHtmlSerializer extends ToHtmlSerializer {
     }

     @Override
+    void visit(HeaderNode node) {
+        println "*" * 10
+        println node.level
+        println new HeaderTextSerializer(node).text
+
+        super.visit(node)
+    }
+
+    @Override
     protected void printImageTag(LinkRenderer.Rendering rendering) {
         def image = imageRenderer.render(rendering.href, rendering.text)
         printer.print("<img");
@@ -58,4 +71,21 @@ class GaidenToHtmlSerializer extends ToHtmlSerializer {
             printer.print(' ').print(it.key).print('=').print('"').print(it.value).print('"');
         }
     }
+
+    static class HeaderTextSerializer extends ToHtmlSerializer {
+
+        private HeaderNode headerNode
+
+        HeaderTextSerializer(HeaderNode headerNode) {
+            super(new LinkRenderer())
+            this.headerNode = headerNode
+        }
+
+        String getText() {
+            headerNode.children.each { Node node ->
+                node.accept(this)
+            }
+            printer.getString()
+        }
+    }
 }