diff --git a/.gitignore b/.gitignore
index 204f240..25ee960 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,5 +17,7 @@ src/gen_*.pir
t/*.text
t/*.html
+t/*.parse
+t/*.past
t/*.zip
t/MarkdownTest_1.0
diff --git a/src/Compiler.pir b/src/Compiler.pir
index f6ffe87..6bcd7f5 100644
--- a/src/Compiler.pir
+++ b/src/Compiler.pir
@@ -106,12 +106,14 @@ Return generated HTML for all of its children.
.sub 'html_children' :method
.param pmc node
+ .param string fsep :optional
+ .param int has_fsep :opt_flag
.param string ssep :optional
.param int has_ssep :opt_flag
.param string esep :optional
.param int has_esep :opt_flag
- .param string lsep :optional
- .param int has_lsep :opt_flag
+ .local int first
+ first = 1
.local pmc code, iter
code = new 'CodeString'
iter = node.'iterator'()
@@ -122,20 +124,21 @@ Return generated HTML for all of its children.
$P0 = self.'html'(cpast)
$I0 = elements $P0
unless $I0 goto iter_loop
- unless has_ssep goto L1
- code .= ssep
+ unless first goto L1
+ first = 0
+ unless has_fsep goto L2
+ code .= fsep
+ goto L2
L1:
+ unless has_ssep goto L2
+ code .= ssep
+ L2:
code .= $P0
- unless iter goto iter_end
- unless has_esep goto L2
+ unless has_esep goto L3
code .= esep
- L2:
+ L3:
goto iter_loop
iter_end:
- unless $I0 goto L3
- unless has_lsep goto L3
- code .= lsep
- L3:
.return (code)
.end
@@ -156,7 +159,7 @@ Return generated HTML for all of its children.
.sub 'html' :method :multi(_, ['Markdown'; 'Document'])
.param pmc node
- .tailcall self.'html_children'(node, '', "\n\n", "\n\n")
+ .tailcall self.'html_children'(node, '', "\n", "\n")
.end
@@ -236,7 +239,7 @@ Return generated HTML for all of its children.
.param pmc node
$S0 = "
\n"
$S0 .= " "
- $S1 = self.'html_children'(node, '', "\n\n", "\n")
+ $S1 = self.'html_children'(node, '', "\n", "\n")
$S0 .= $S1
$S0 .= "
"
.local pmc code
@@ -289,7 +292,7 @@ Return generated HTML for all of its children.
$S1 = self.'html_children'(node)
goto L2
L1:
- $S1 = self.'html_children'(node, "", "
\n\n", "")
+ $S1 = self.'html_children'(node, "", "\n\n
", "
")
L2:
$S0 .= $S1
$S0 .= "\n"
diff --git a/t/00-sanity.t b/t/00-sanity.t
index b08554e..d7ed14a 100644
--- a/t/00-sanity.t
+++ b/t/00-sanity.t
@@ -32,7 +32,6 @@ CODE
Title
some text.
-
OUT
# Local Variables:
diff --git a/t/10-heading.t b/t/10-heading.t
index 8c32417..c8c09b4 100644
--- a/t/10-heading.t
+++ b/t/10-heading.t
@@ -25,7 +25,6 @@ First-level heading
CODE
First-level heading
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'SetextHeading2' );
@@ -35,7 +34,6 @@ Second-level heading
CODE
Second-level heading
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'AtxHeading 1' );
@@ -44,7 +42,6 @@ language_output_is( 'markdown', <<'CODE', <<'OUT', 'AtxHeading 1' );
CODE
First-level heading
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'AtxHeading 4' );
@@ -53,7 +50,6 @@ language_output_is( 'markdown', <<'CODE', <<'OUT', 'AtxHeading 4' );
CODE
Fourth-level heading
-
OUT
# Local Variables:
diff --git a/t/11-hrule.t b/t/11-hrule.t
index c0736e2..a3fb16c 100644
--- a/t/11-hrule.t
+++ b/t/11-hrule.t
@@ -24,7 +24,6 @@ language_output_is( 'markdown', <<'CODE', <<'OUT', 'rule *' );
CODE
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'rule -' );
@@ -33,7 +32,6 @@ language_output_is( 'markdown', <<'CODE', <<'OUT', 'rule -' );
CODE
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'rule _' );
@@ -42,7 +40,6 @@ language_output_is( 'markdown', <<'CODE', <<'OUT', 'rule _' );
CODE
-
OUT
# Local Variables:
diff --git a/t/12-blockquote.t b/t/12-blockquote.t
index a7b7379..f4d4e5a 100644
--- a/t/12-blockquote.t
+++ b/t/12-blockquote.t
@@ -26,7 +26,6 @@ CODE
This text will be enclosed in an HTML blockquote element.
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'BlockQuote 2' );
@@ -39,7 +38,6 @@ CODE
Use the > character in front of a line, just like in email.
Use it if you're quoting a person, a song or whatever.
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'BlockQuote 3' );
@@ -60,7 +58,6 @@ part of the blockquote, even without the > character in front.
To end the blockquote, just put a blank line before the following paragraph.
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'BlockQuote 4' );
@@ -75,7 +72,6 @@ CODE
Use it if you're quoting a person, a song or whatever.
-
OUT
# Local Variables:
diff --git a/t/13-para.t b/t/13-para.t
index 8be20bb..0624a02 100644
--- a/t/13-para.t
+++ b/t/13-para.t
@@ -28,7 +28,6 @@ CODE
This is a paragraph. It has two sentences.
This is another paragraph. It also has two sentences.
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'Para multi-line' );
@@ -39,7 +38,6 @@ It has two sentences.
CODE
This is a paragraph.
It has two sentences.
-
OUT
diff --git a/t/14-list.t b/t/14-list.t
index 0c45321..bb3a3e9 100644
--- a/t/14-list.t
+++ b/t/14-list.t
@@ -28,7 +28,6 @@ CODE
An item in a bulleted (unordered) list
Another item in a bulleted list
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'ordered tight' );
@@ -41,7 +40,6 @@ CODE
An item in a enumeradted (ordered) list
Another item in a enumeradted list
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'unordered loose' );
@@ -55,7 +53,6 @@ CODE
Bird
Magic
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'with continuation' );
@@ -70,7 +67,6 @@ CODE
With continuation.
Another item in the list.
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'with multi-para' );
@@ -88,7 +84,6 @@ CODE
Para 2.
Another item in the list.
-
OUT
diff --git a/t/15-codeblock.t b/t/15-codeblock.t
index ec4c950..4c2a451 100644
--- a/t/15-codeblock.t
+++ b/t/15-codeblock.t
@@ -29,7 +29,6 @@ CODE
This is a code block.
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'CodeBlock 2' );
@@ -47,7 +46,6 @@ CODE
bell
end tell
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'CodeBlock HTML' );
@@ -65,7 +63,6 @@ CODE
© 2004 Foo Corporation
</div>
-
OUT
# Local Variables:
diff --git a/t/20-emphasis.t b/t/20-emphasis.t
index 449a38e..9d1be03 100644
--- a/t/20-emphasis.t
+++ b/t/20-emphasis.t
@@ -24,7 +24,6 @@ language_output_is( 'markdown', <<'CODE', <<'OUT', 'emphasis star' );
CODE
emphasis (e.g., italics)
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'strong star' );
@@ -33,7 +32,6 @@ language_output_is( 'markdown', <<'CODE', <<'OUT', 'strong star' );
CODE
strong emphasis (e.g., boldface)
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'emphasis UI' );
@@ -42,7 +40,6 @@ _emphasis_ (e.g., italics)
CODE
emphasis (e.g., italics)
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'strong UI' );
@@ -51,7 +48,6 @@ __strong emphasis__ (e.g., boldface)
CODE
strong emphasis (e.g., boldface)
-
OUT
diff --git a/t/21-code.t b/t/21-code.t
index 640a4d8..199b377 100644
--- a/t/21-code.t
+++ b/t/21-code.t
@@ -24,7 +24,6 @@ language_output_is( 'markdown', <<'CODE', <<'OUT', 'code' );
CODE
code
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'printf' );
@@ -33,7 +32,6 @@ Use the `printf()` function.
CODE
Use the printf()
function.
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'literal backtick' );
@@ -42,7 +40,6 @@ language_output_is( 'markdown', <<'CODE', <<'OUT', 'literal backtick' );
CODE
There is a literal backtick (`) here.
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'with space' );
@@ -55,7 +52,6 @@ CODE
A single backtick in a code span: `
A backtick-delimited string in a code span: `foo`
-
OUT
language_output_is( 'markdown', <<'CODE', <<'OUT', 'HTML tag' );
@@ -64,7 +60,6 @@ Please don't use any `