Changeset 204
- Timestamp:
- 04/04/07 19:01:14 (1 year ago)
- Files:
-
- trunk/src/core/Spork/lib/Spork/Parser.pm (modified) (3 diffs)
- trunk/test/spork-parser.t (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/core/Spork/lib/Spork/Parser.pm
r203 r204 21 21 my $all_phrases = [qw(b i tt hilite)]; 22 22 my $all_blocks = [qw(indent center h2 ul pre p)]; 23 $self->{grammar} = +{ 23 $self->{grammar} = 24 { 24 25 top => $all_blocks, 25 26 center => $all_blocks, … … 54 55 sub match_center { 55 56 my $self = shift; 56 $self->{input} =~ /^\.center\n(.*?\n)(?:.center\n|\z) /s57 $self->{input} =~ /^\.center\n(.*?\n)(?:.center\n|\z)\n?/s 57 58 or return; 58 59 return $self->matched_block; … … 75 76 sub match_h2 { 76 77 my $self = shift; 77 $self->{input} =~ /^(={2})\s+(.*?)\s*\n+/ 78 or return; 79 my $match = $self->matched_block($2); 80 $match->{level} = length($1); 81 return $match; 78 $self->{input} =~ /^={2}\s+(.*?)\s*\n+/ 79 or return; 80 $self->matched_block; 82 81 } 83 82 trunk/test/spork-parser.t
r203 r204 1 1 #!/usr/bin/perl 2 use strict;2 use Test::Base tests => 1; 3 3 use lib 'lib'; 4 4 use Spork::Parser; … … 6 6 use XXX; 7 7 8 my $text = do {local $/; <DATA>}; 9 my $ast = Spork::Parser->new->parse($text); 10 my $html = Spork::Emitter::HTML->new->emit($ast); 11 print $html; 8 run_is spork => 'html'; 12 9 13 __END__ 10 sub format { 11 my $text = shift; 12 my $ast = Spork::Parser->new->parse($text); 13 return Spork::Emitter::HTML->new->emit($ast); 14 } 15 16 __DATA__ 17 === Parse Spork Slide 18 --- spork format 14 19 == This is a test 15 20 16 21 .center 17 22 * foo 18 ** 12323 ** `123` 19 24 * *hello* 20 25 .center … … 24 29 xxx 25 30 xxx 26 yyy27 yyy31 > yyy 32 > yyy 28 33 xxx 29 34 … … 31 36 ... 32 37 } 38 --- html 39 <h2>This is a test</h2> 40 <div class="center-outer"><div class="center-inner"> 41 <ul> 42 <li>foo</li> 43 <ul> 44 <li><tt>123</tt></li> 45 </ul> 46 <li><b>hello</b></li> 47 </ul> 48 </div></div> 49 <p>Cool <b>stuff</b> is <i>here</i>.</p> 50 <p>xxx<br /> 51 xxx</p> 52 <blockquote> 53 <p>yyy<br /> 54 yyy</p> 55 </blockquote> 56 <p>xxx</p> 57 <pre> 58 sub foo { 59 ... 60 } 61 </pre>
