Skip to content
This repository has been archived by the owner on Jun 9, 2018. It is now read-only.

Commit

Permalink
fix reference link with embedded bracket
Browse files Browse the repository at this point in the history
  • Loading branch information
fperrad committed Mar 24, 2009
1 parent 04293ed commit 6ebcba4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
22 changes: 10 additions & 12 deletions src/Compiler.pir
Expand Up @@ -345,32 +345,30 @@ Return generated HTML for all of its children.

.sub 'html' :method :multi(_,['Markdown';'RefLink'])
.param pmc node
.local string content, image, key
content = self.'html_children'(node)
key = node.'key'()
$P0 = get_hll_global [ 'Markdown';'HTML';'Compiler' ], '%ref'
$S2 = node.'key'()
$S0 = downcase $S2
$S0 = downcase key
$P1 = $P0[$S0]
.local string url, title
if null $P1 goto L1
.local string url, title
$S0 = $P1[0]
url = escape_xml($S0)
$S0 = $P1[1]
title = escape_xml($S0)
goto L2
L1:
printerr "unknown reference "
printerr $S2
printerr "\n"
url = 'no link'
title = ''
$S0 = key
$S0 .= content
goto L5
L2:
.local string content, image
content = self.'html_children'(node)
image = node.'image'()
if image goto L3
if content goto L4
$I0 = length $S2
$I0 = length key
$I0 -= 2
content = substr $S2, 1, $I0
content = substr key, 1, $I0
L4:
$S0 = _link(url, title, content)
goto L5
Expand Down
13 changes: 12 additions & 1 deletion t/32-reflink.t
Expand Up @@ -15,7 +15,7 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../lib", "$FindBin::Bin";

use Parrot::Test tests => 3;
use Parrot::Test tests => 4;
use Test::More;

language_output_is( 'markdown', <<'CODE', <<'OUT', 'reference link double' );
Expand Down Expand Up @@ -54,6 +54,17 @@ to the link named "[shortcut]" on the next paragraph.</p>

OUT

language_output_is( 'markdown', <<'CODE', <<'OUT', 'pathologic label reference link' );
With [embedded [brackets]] [b].
[b]: /url/
CODE
<p>With <a href="/url/">embedded [brackets]</a>.</p>

OUT


# Local Variables:
# mode: cperl
Expand Down

0 comments on commit 6ebcba4

Please sign in to comment.