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 &copy; 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 `` tags. CODE

    Please don't use any <blink> tags.

    - OUT language_output_is( 'markdown', <<'CODE', <<'OUT', 'HTML entity' ); @@ -73,7 +68,6 @@ language_output_is( 'markdown', <<'CODE', <<'OUT', 'HTML entity' ); CODE

    &#8212; is the decimal-encoded equivalent of &mdash;.

    - OUT # Local Variables: diff --git a/t/22-escape.t b/t/22-escape.t index cee55b8..4caea53 100644 --- a/t/22-escape.t +++ b/t/22-escape.t @@ -24,7 +24,6 @@ language_output_is( 'markdown', <<'CODE', <<'OUT', 'asterisk' ); CODE

    *literal astericks*

    - OUT language_output_is( 'markdown', <<'CODE', <<'OUT', 'dot' ); @@ -33,7 +32,6 @@ language_output_is( 'markdown', <<'CODE', <<'OUT', 'dot' ); CODE

    1986. What a great season.

    - OUT language_output_is( 'markdown', <<'CODE', <<'OUT', 'symbol (not escaped)' ); @@ -42,7 +40,6 @@ Hello, World! CODE

    Hello, World!

    - OUT # Local Variables: diff --git a/t/23-entity.t b/t/23-entity.t index 91746f5..63f41c0 100644 --- a/t/23-entity.t +++ b/t/23-entity.t @@ -24,7 +24,6 @@ language_output_is( 'markdown', <<'CODE', <<'OUT', 'CharEntity' ); CODE

    4 < 5

    - OUT language_output_is( 'markdown', <<'CODE', <<'OUT', 'HexEntity' ); @@ -33,11 +32,9 @@ language_output_is( 'markdown', <<'CODE', <<'OUT', 'HexEntity' ); CODE

    20 €.

    - OUT - # Local Variables: # mode: cperl # cperl-indent-level: 4 diff --git a/t/24-smart.t b/t/24-smart.t index fceec0f..381cf0a 100644 --- a/t/24-smart.t +++ b/t/24-smart.t @@ -24,7 +24,6 @@ use Test::More; # #CODE #

    smart ’

    -# #OUT language_output_is( 'markdown', <<'CODE', <<'OUT', 'ellipsis' ); @@ -37,7 +36,6 @@ CODE

    smart …

    smart …

    - OUT #language_output_is( 'markdown', <<'CODE', <<'OUT', 'endash' ); @@ -46,7 +44,6 @@ OUT # #CODE #

    smart –

    -# #OUT language_output_is( 'markdown', <<'CODE', <<'OUT', 'emdash' ); @@ -59,7 +56,6 @@ CODE

    smart —

    smart —

    - OUT diff --git a/t/30-autolink.t b/t/30-autolink.t index caee4e5..279f973 100644 --- a/t/30-autolink.t +++ b/t/30-autolink.t @@ -24,7 +24,6 @@ language_output_is( 'markdown', <<'CODE', <<'OUT', 'autolink url' ); CODE

    http://someurl

    - OUT language_output_is( 'markdown', <<'CODE', <<'OUT', 'autolink email' ); @@ -33,7 +32,6 @@ language_output_is( 'markdown', <<'CODE', <<'OUT', 'autolink email' ); CODE

    somebbob@example.com

    - OUT diff --git a/t/31-link.t b/t/31-link.t index 5d8607a..d781280 100644 --- a/t/31-link.t +++ b/t/31-link.t @@ -24,7 +24,6 @@ This is an [example link](http://example.com/). CODE

    This is an example link.

    - OUT language_output_is( 'markdown', <<'CODE', <<'OUT', 'inline link with title' ); @@ -33,7 +32,6 @@ This is an [example link](http://example.com/ "With a Title"). CODE

    This is an example link.

    - OUT diff --git a/t/32-reflink.t b/t/32-reflink.t index 9b5b730..dd3d9f4 100644 --- a/t/32-reflink.t +++ b/t/32-reflink.t @@ -27,7 +27,6 @@ You can also put the [link URL][1] below the current paragraph like [this][2]. CODE

    You can also put the link URL below the current paragraph like this.

    - OUT language_output_is( 'markdown', <<'CODE', <<'OUT', 'reference link simple' ); @@ -38,7 +37,6 @@ Or you can use a [shortcut][] reference, which links the text "shortcut" CODE

    Or you can use a shortcut reference, which links the text "shortcut"

    - OUT language_output_is( 'markdown', <<'CODE', <<'OUT', 'reference link simple' ); @@ -51,7 +49,6 @@ to the link named "[shortcut]" on the next paragraph. CODE

    Or you can use a shortcut reference, which links the text "shortcut" to the link named "[shortcut]" on the next paragraph.

    - OUT language_output_is( 'markdown', <<'CODE', <<'OUT', 'pathologic label reference link' ); @@ -62,7 +59,6 @@ With [embedded [brackets]] [b]. CODE

    With embedded [brackets].

    - OUT diff --git a/t/33-image.t b/t/33-image.t index 5ac4432..fc8b501 100644 --- a/t/33-image.t +++ b/t/33-image.t @@ -24,7 +24,6 @@ language_output_is( 'markdown', <<'CODE', <<'OUT', 'image' ); CODE

    alternate text

    - OUT language_output_is( 'markdown', <<'CODE', <<'OUT', 'image with title' ); @@ -33,7 +32,6 @@ language_output_is( 'markdown', <<'CODE', <<'OUT', 'image with title' ); CODE

    tiny arrow

    - OUT language_output_is( 'markdown', <<'CODE', <<'OUT', 'reference image' ); @@ -44,7 +42,6 @@ language_output_is( 'markdown', <<'CODE', <<'OUT', 'reference image' ); CODE

    alt text

    - OUT diff --git a/t/MarkdownTest.t b/t/MarkdownTest.t index b94ce73..134dca8 100644 --- a/t/MarkdownTest.t +++ b/t/MarkdownTest.t @@ -40,7 +40,7 @@ foreach my $test_file (@test_files) { my $test_name = basename($test_file, '.text'); my $code = Parrot::Test::slurp_file( $test_file ) . "\n"; - my $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, "$test_name.html" )) . "\n"; + my $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, "$test_name.html" )) ; language_output_is( 'markdown', $code, $out, $test_name ); }