Changeset 244

Show
Ignore:
Timestamp:
04/14/07 08:22:07 (1 year ago)
Author:
ingy
Message:
 r4323@skinny-2:  ingy | 2007-04-14 23:17:21 +0800
 osdc talk
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/core/Spork/lib/Spork/Config.pm

    r208 r244  
    66 
    77const class_id => 'config'; 
     8 
     9sub parse_yaml_file { 
     10    my $file = shift; 
     11#     $self->parse_yaml(io($file)->utf8->all); 
     12    $self->parse_yaml(io($file)->all); 
     13} 
    814 
    915sub default_configs { 
  • trunk/src/core/Spork/lib/Spork/Emitter/HTML.pm

    r223 r244  
    2828    '+hilite' => qq{<span class="hilite">}, 
    2929    '-hilite' => "</span>", 
     30    '+color' => qq{<pre>}, 
     31    '-color' => "</pre>", 
    3032); 
    3133 
     
    3638        if (ref $node) { 
    3739            my ($key, $value) = @$node; 
    38             $self->{output} .= $tags{"+$key"}; 
    39             $self->{parent} = $key; 
    40             $self->emit($value); 
    41             $self->{output} .= $tags{"-$key"}; 
     40            $self->{output} .= $tags{"+$key"} || ''; 
     41            my $func = "handle_$key"; 
     42            if ($self->can($func)) { 
     43                $self->$func($value); 
     44            } 
     45            else { 
     46                $self->emit($value); 
     47            } 
     48            $self->{output} .= $tags{"-$key"} || ''; 
    4249            next; 
    4350        } 
    4451        my $text = $node; 
    45         unless ($self->{parent} eq 'pre') { 
    46             $text =~ s/^(  +)/"&nbsp;" x length($1)/gem; 
    47             $text =~ s/\n/<br \/>\n/g; 
    48         } 
     52        $text =~ s/^(  +)/"&nbsp;" x length($1)/gem; 
     53        $text =~ s/\n/<br \/>\n/g; 
    4954        $self->{output} .= $text; 
    5055    } 
     
    5257} 
    5358 
     59sub handle_pre { 
     60    my $self = shift; 
     61    my $node = shift; 
     62    my $text = $node->[0]; 
     63    $text =~ s/</&lt;/g; 
     64    $self->{output} .= $text; 
     65} 
     66 
     67sub handle_color { 
     68    require Spork::Hilite; 
     69    my $self = shift; 
     70    my $node = shift; 
     71    my $text = $node->[0]; 
     72 
     73    my $hilite = Spork::Hilite::Wafl->new; 
     74    $hilite->text($text); 
     75    my $html = $hilite->to_html; 
     76     
     77    $self->{output} .= $html; 
     78} 
     79 
    54801; 
  • trunk/src/core/Spork/lib/Spork/Parser.pm

    r243 r244  
    1111sub create_grammar { 
    1212    my $all_phrases = [qw(b i tt hilite)]; 
    13     my $all_blocks = [qw(indent center h2 ul pre p)]; 
     13    my $all_blocks = [qw(color indent center h2 ul pre p)]; 
    1414    return { 
    1515        top => { 
    1616            blocks => $all_blocks, 
    1717        }, 
     18        color => { 
     19            match => qr/^\.hilite\n(.*?\n)(?:\.hilite\n|\z)\n?/s, 
     20        }, 
    1821        center => { 
    1922            blocks => $all_blocks, 
    20             match => qr/^\.center\n(.*?\n)(?:.center\n|\z)\n?/s, 
     23            match => qr/^\.center\n(.*?\n)(?:\.center\n|\z)\n?/s, 
    2124        }, 
    2225        indent => { 
     
    2629        }, 
    2730        pre => { 
    28             match => qr/^(( +.*\S.*\n)+)(?m:^ *\n)*/, 
     31            match => qr/^(( +.*\n)+)(?m:^ *\n)*/, 
    2932            filter => sub { while (not /^\S/m) { s/^ //gm } }, 
    3033        }, 
  • trunk/src/core/Spork/lib/Spork/Slides.pm

    r203 r244  
    5959    my $translate = ''; 
    6060    my $image_line; 
    61     while ($content =~ s/^# ?(.*\n)//m) { 
    62         $translate .= $1; 
     61    unless ($self->config->{no_translate}) { 
     62        while ($content =~ s/^# ?(.*\n)//m) { 
     63            $translate .= $1; 
     64        } 
    6365    } 
    6466    while ($content =~ s/^\.image:(.*\n)//m) {