[from now] 2014/08/21 22:47:11

diff --git a/src/main/groovy/gaiden/markdown/GaidenToHtmlSerializer.groovy b/src/main/groovy/gaiden/markdown/GaidenToHtmlSerializer.groovy
index 4a3861e..743044a 100644
--- a/src/main/groovy/gaiden/markdown/GaidenToHtmlSerializer.groovy
+++ b/src/main/groovy/gaiden/markdown/GaidenToHtmlSerializer.groovy
@@ -108,11 +108,18 @@ void visit(RefLinkNode node) {
     @Override
     void visit(SuperNode node) {
         if (node instanceof MarkdownInsideHtmlBlockNode) {
-            println "*" * 10
+            printMarkdownInsideHtmlBlock(node)
+            return
         }
         super.visit(node)
     }

+    private void printMarkdownInsideHtmlBlock(MarkdownInsideHtmlBlockNode node) {
+        printer.print(node.startTag)
+        visitChildren(node)
+        printer.print('</').print(node.tagName).print('>')
+    }
+
     @Override
     protected void printLink(LinkRenderer.Rendering rendering) {
         printLink(rendering, null)
diff --git a/src/main/groovy/org/pegdown/GaidenParser.java b/src/main/groovy/org/pegdown/GaidenParser.java
index 9296d17..370eea9 100644
--- a/src/main/groovy/org/pegdown/GaidenParser.java
+++ b/src/main/groovy/org/pegdown/GaidenParser.java
@@ -199,12 +199,36 @@ public Rule Block() {
     }

     public Rule MarkdownInsideHtmlBlock() {
+        return NodeSequence(
+            MarkdownInsideHtmlBlockInTags(),
+            OneOrMore(BlankLine())
+        );
+    }
+
+    public Rule MarkdownInsideHtmlBlockInTags() {
         StringVar tagName = new StringVar();
         return Sequence(
+            Test(MarkdownInsideHtmlBlockOpen(tagName)), // get the type of tag if there is one
+            MarkdownInsideHtmlTagBlock(tagName) // specifically match that type of tag
+        );
+    }
+
+    @Cached
+    public Rule MarkdownInsideHtmlTagBlock(StringVar tagName) {
+        Var<String> startTag = new Var<>();
+        Var<String> inside = new Var<>();
+        return Sequence(
             MarkdownInsideHtmlBlockOpen(tagName),
-            push(new MarkdownInsideHtmlBlockNode(tagName.get(), match())),
-            ZeroOrMore(TestNot(HtmlBlockClose(tagName)), Block()),
-            HtmlBlockClose(tagName)
+            startTag.set(match()),
+            ZeroOrMore(
+                FirstOf(
+                    HtmlTagBlock(tagName),
+                    Sequence(TestNot(HtmlBlockClose(tagName)), ANY)
+                )
+            ),
+            inside.set(match()),
+            HtmlBlockClose(tagName),
+            push(new MarkdownInsideHtmlBlockNode(tagName.get(), startTag.get(), withIndicesShifted(parseInternal((inside.get() + "\n").toCharArray()), (Integer) peek()).getChildren()))
         );
     }

@@ -219,9 +243,7 @@ public Rule MarkdownAttribute(Var<Boolean> hasMarkdownAttr) {
             Spn1(),
             '=',
             Spn1(),
-            FirstOf("\"", "'"),
-            FirstOf("1", "span", "block"),
-            FirstOf("\"", "'"),
+            FirstOf("1", "\"1\"", "'1'", "\"span\"", "'span'", "\"block\"", "'block'"),
             Spn1(),
             hasMarkdownAttr.set(true)
         );
diff --git a/src/main/groovy/org/pegdown/ast/MarkdownInsideHtmlBlockNode.java b/src/main/groovy/org/pegdown/ast/MarkdownInsideHtmlBlockNode.java
index 4519adc..c7a057b 100644
--- a/src/main/groovy/org/pegdown/ast/MarkdownInsideHtmlBlockNode.java
+++ b/src/main/groovy/org/pegdown/ast/MarkdownInsideHtmlBlockNode.java
@@ -1,10 +1,13 @@
 package org.pegdown.ast;

+import java.util.List;
+
 public class MarkdownInsideHtmlBlockNode extends SuperNode {
     private String tagName;
     private String startTag;

-    public MarkdownInsideHtmlBlockNode(String tagName, String startTag) {
+    public MarkdownInsideHtmlBlockNode(String tagName, String startTag, List<Node> children) {
+        super(children);
         System.out.println("xxxxxxxx");
         System.out.println(tagName);
         System.out.println(startTag);
@@ -19,4 +22,9 @@ public String getTagName() {
     public String getStartTag() {
         return startTag;
     }
+
+    public boolean check() {
+        System.out.println("yyyyy");
+        return true;
+    }
 }
diff --git a/src/test/resources/test-project/build/inside-html-blocks.html b/src/test/resources/test-project/build/inside-html-blocks.html
index a9ff32e..451d593 100644
--- a/src/test/resources/test-project/build/inside-html-blocks.html
+++ b/src/test/resources/test-project/build/inside-html-blocks.html
@@ -46,9 +46,15 @@
         <div class="content-nav">
         </div>
         <div class="main-content">
-          <h1 id="markdown-inside-html-blocks">Markdown Inside HTML Blocks</h1>
+          <h1 id="markdown-inside-code-blocks">Markdown inside code blocks</h1>
           <div markdown="1">
-            This is *true* markdown text.
+            <p>foo</p>
+          </div>
+          <div markdown='1'>
+            <p>foo</p>
+          </div>
+          <div markdown=1>
+            foo
           </div>
         </div>
         <div class="footer footer-toc-visible">
diff --git a/src/test/resources/test-project/inside-html-blocks.md b/src/test/resources/test-project/inside-html-blocks.md
index a0a252c..9b51146 100644
--- a/src/test/resources/test-project/inside-html-blocks.md
+++ b/src/test/resources/test-project/inside-html-blocks.md
@@ -1,5 +1,25 @@
-# Markdown Inside HTML Blocks
+# Markdown inside code blocks

 <div markdown="1">
-This is *true* markdown text.
+foo
 </div>
+
+<div markdown='1'>
+foo
+</div>
+
+<div markdown=1>
+foo
+</div>
+
+<table>
+<tr><td markdown="1">test _emphasis_ (span)</td></tr>
+</table>
+
+<table>
+<tr><td markdown="span">test _emphasis_ (span)</td></tr>
+</table>
+
+<table>
+<tr><td markdown="block">test _emphasis_ (block)</td></tr>
+</table>
[from now] 2014/08/22 00:44:41

diff --git a/src/main/groovy/org/pegdown/GaidenParser.java b/src/main/groovy/org/pegdown/GaidenParser.java
index 370eea9..8c103d1 100644
--- a/src/main/groovy/org/pegdown/GaidenParser.java
+++ b/src/main/groovy/org/pegdown/GaidenParser.java
@@ -228,7 +228,7 @@ public Rule MarkdownInsideHtmlTagBlock(StringVar tagName) {
             ),
             inside.set(match()),
             HtmlBlockClose(tagName),
-            push(new MarkdownInsideHtmlBlockNode(tagName.get(), startTag.get(), withIndicesShifted(parseInternal((inside.get() + "\n").toCharArray()), (Integer) peek()).getChildren()))
+            push(new MarkdownInsideHtmlBlockNode(tagName.get(), startTag.get(), withIndicesShifted(parseInternal((inside.get()).toCharArray()), (Integer) peek()).getChildren()))
         );
     }

diff --git a/src/test/resources/test-project/inside-html-blocks.md b/src/test/resources/test-project/inside-html-blocks.md
index 9b51146..3a62536 100644
--- a/src/test/resources/test-project/inside-html-blocks.md
+++ b/src/test/resources/test-project/inside-html-blocks.md
@@ -12,6 +12,10 @@ foo
 foo
 </div>

+<div markdown=1>
+* this is _not_ a list item
+</div>
+
 <table>
 <tr><td markdown="1">test _emphasis_ (span)</td></tr>
 </table>