Changeset 332

Show
Ignore:
Timestamp:
11/09/06 12:13:20 (2 years ago)
Author:
miya
Message:

Text::Trac: Fix list handling(Ul.pm and Ol.pm).
Refactor inline node parsers wholly.
Add supports for TracLinks and WikiMacros.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • library/perl/trunk/Text-Trac

    • Property svn:ignore set to
      META.yml
      Makefile
      Makefile.old
      blib
      pm_to_blib
      *.bak
  • library/perl/trunk/Text-Trac/Changes

    r323 r332  
    11Revision history for Text-Trac 
    22 
     30.06    Wed Nov 9 
     4        Fix list handling(Ul.pm and Ol.pm). 
     5        Refactor inline node parsers wholly. 
     6        Add supports for TracLinks and WikiMacros. 
     7        
    380.05    Fri Oct 27 
    49        Using Test::Base instead of Test::More in 01-text-trac.t. 
  • library/perl/trunk/Text-Trac/MANIFEST

    r331 r332  
    11Changes 
    2 MANIFEST 
    3 META.yml # Will be created by "make dist" 
    4 Makefile.PL 
    5 README 
     2inc/Module/AutoInstall.pm 
     3inc/Module/Install.pm 
     4inc/Module/Install/AutoInstall.pm 
     5inc/Module/Install/Base.pm 
     6inc/Module/Install/Can.pm 
     7inc/Module/Install/Fetch.pm 
     8inc/Module/Install/Include.pm 
     9inc/Module/Install/Makefile.pm 
     10inc/Module/Install/Metadata.pm 
     11inc/Module/Install/Win32.pm 
     12inc/Module/Install/WriteAll.pm 
    613lib/Text/Trac.pm 
    7 lib/Text/Trac/AutoLinkHttp.pm 
    814lib/Text/Trac/BlockNode.pm 
    915lib/Text/Trac/Blockquote.pm 
    10 lib/Text/Trac/BoldItalic.pm 
    11 lib/Text/Trac/Bold.pm 
    12 lib/Text/Trac/Br.pm 
    1316lib/Text/Trac/Context.pm 
    1417lib/Text/Trac/Dl.pm 
     
    1619lib/Text/Trac/Hr.pm 
    1720lib/Text/Trac/InlineNode.pm 
    18 lib/Text/Trac/Italic.pm 
    19 lib/Text/Trac/Monospace.pm 
     21lib/Text/Trac/LinkResolver.pm 
     22lib/Text/Trac/LinkResolver/Attachment.pm 
     23lib/Text/Trac/LinkResolver/Changeset.pm 
     24lib/Text/Trac/LinkResolver/Log.pm 
     25lib/Text/Trac/LinkResolver/Milestone.pm 
     26lib/Text/Trac/LinkResolver/Report.pm 
     27lib/Text/Trac/LinkResolver/Source.pm 
     28lib/Text/Trac/LinkResolver/Ticket.pm 
     29lib/Text/Trac/LinkResolver/Wiki.pm 
     30lib/Text/Trac/Macro.pm 
     31lib/Text/Trac/Macro/HelloWorld.pm 
     32lib/Text/Trac/Macro/Timestamp.pm 
    2033lib/Text/Trac/Node.pm 
    2134lib/Text/Trac/Ol.pm 
    2235lib/Text/Trac/P.pm 
    2336lib/Text/Trac/Pre.pm 
    24 lib/Text/Trac/Strike.pm 
    25 lib/Text/Trac/Sub.pm 
    26 lib/Text/Trac/Sup.pm 
    2737lib/Text/Trac/Table.pm 
    2838lib/Text/Trac/Text.pm 
    2939lib/Text/Trac/Ul.pm 
    30 lib/Text/Trac/Underline.pm 
    31 lib/Text/Trac/Macro.pm 
    32 lib/Text/Trac/Macro/Timestamp.pm 
    33 lib/Text/Trac/Macro/HelloWorld.pm 
    34 lib/Text/Trac/TracLinks.pm 
     40Makefile.PL 
     41MANIFEST                        This list of files 
     42META.yml 
     43README 
    3544t/00-load.t 
    3645t/01-text-trac.t 
    3746t/02-macros.t 
    3847t/03-trac-links.t 
     48t/04-list.t 
     49t/05-disable_links.t 
     50t/06-enable_links.t 
     51t/07-custom_url.t 
     52t/08-regression.t 
    3953t/boilerplate.t 
    4054t/pod-coverage.t 
    4155t/pod.t 
     56t/TestTextTrac.pm 
  • library/perl/trunk/Text-Trac/Makefile.PL

    r323 r332  
    1 use strict; 
    2 use warnings; 
    3 use ExtUtils::MakeMaker; 
     1use inc::Module::Install; 
    42 
    5 WriteMakefile( 
    6     NAME                => 'Text::Trac', 
    7     AUTHOR              => 'Gosuke Miyashita <gosukenator@gmail.com>', 
    8     VERSION_FROM        => 'lib/Text/Trac.pm', 
    9     ABSTRACT_FROM       => 'lib/Text/Trac.pm', 
    10     PL_FILES            => {}, 
    11     PREREQ_PM => { 
    12         'Test::Base'               => 0, 
    13         'UNIVERSAL::require'       => 0, 
    14         'Class::Accessor::Fast'    => 0, 
    15         'Class::Data::Inheritable' => 0, 
    16     }, 
    17     dist                => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, 
    18     clean               => { FILES => 'Text-Trac-*' }, 
    19 ); 
     3name('Text-Trac'); 
     4all_from('lib/Text/Trac.pm'); 
     5 
     6requires('Test::Base'); 
     7requires('UNIVERSAL::require'); 
     8requires('Class::Accessor::Fast'); 
     9requires('Class::Data::Inheritable'); 
     10requires('Tie::IxHash'); 
     11requires('List::MoreUtils'); 
     12 
     13no_index( package => 'TestMacro' ); 
     14 
     15auto_include; 
     16auto_install; 
     17 
     18WriteAll; 
  • library/perl/trunk/Text-Trac/lib/Text/Trac.pm

    r328 r332  
    66use Text::Trac::BlockNode; 
    77 
    8 our $VERSION = '0.05'; 
     8our $VERSION = '0.06'; 
    99 
    1010my %Defaults = ( 
     
    2828    my $self = shift; 
    2929    my $text = shift or return; 
     30 
     31    $self->{trac_url} = '/' unless defined $self->{trac_url}; 
     32    for ( keys %$self ) { 
     33        if ( $_ =~ /^trac.+url$/ ) { 
     34            $self->{$_} .= '/' if $self->{$_} !~ m!/$!; 
     35        } 
     36    } 
     37 
    3038    my $c = Text::Trac::Context->new({ 
    31         text              => $text, 
    32         permalink         => $self->{permalink}, 
    33         min_heading_level => $self->{min_heading_level}, 
    34         trac_url          => $self->{trac_url}, 
     39        %$self, 
     40        text => $text, 
    3541    }); 
    3642 
     
    5662=head1 VERSION 
    5763 
    58 Version 0.05 
     64Version 0.06 
    5965 
    6066=head1 SYNOPSIS 
     
    6268    use Text::Trac; 
    6369 
    64     my $parser = Text::Trac->new(); 
     70    my $parser = Text::Trac->new( 
     71        trac_url      => 'http://trac.mizzy.org/public/', 
     72        disable_links => [ qw( changeset ticket ) ], 
     73    ); 
    6574 
    6675    $parser->parse($text); 
     
    7786 
    7887Constructs Text::Trac object. 
     88 
     89Available arguments are: 
     90 
     91=over 
     92 
     93=item trac_url 
     94 
     95Base URL for TracLinks.Default is /. You can specify each type of URL individually. 
     96Available URLs are: 
     97 
     98=over 
     99 
     100=item trac_attachment_url 
     101 
     102=item trac_changeset_url 
     103 
     104=item trac_log_url 
     105 
     106=item trac_milestone_url 
     107 
     108=item trac_report_url 
     109 
     110=item trac_source_url 
     111 
     112=item trac_ticket_url 
     113 
     114=item trac_wiki_url 
     115 
     116=back 
     117 
     118=item disable_links 
     119 
     120Specify TracLink types you want to disable. 
     121All types are enables if you don't specify this option. 
     122 
     123    my $parser = Text::Trac->new( 
     124        disable_links => [ qw( changeset ticket ) ], 
     125    ); 
     126 
     127=item enable_links 
     128 
     129Specify TracLink types you want to enable.Other types are disabled. 
     130You cannot use both disable_links and enable_links at once. 
     131 
     132    my $parser = Text::Trac->new( 
     133        enable_links => [ qw( changeset ticket ) ], 
     134    ); 
     135 
     136 
     137=back 
    79138 
    80139=head2 parse 
  • library/perl/trunk/Text-Trac/lib/Text/Trac/BlockNode.pm

    r330 r332  
    44use base qw( Class::Accessor::Fast Class::Data::Inheritable ); 
    55use UNIVERSAL::require; 
     6use Text::Trac::InlineNode; 
    67 
    78__PACKAGE__->mk_classdata( 
    89    block_nodes    => [ qw( heading hr p ul ol blockquote pre table dl ) ] 
    910); 
    10 __PACKAGE__->mk_classdata( 
    11     inline_nodes   => [ qw( bold_italic bold italic underline monospace strike sup sub br 
    12                             auto_link_http macro trac_links ) ] 
    13 ); 
     11 
     12#__PACKAGE__->mk_classdata( 
     13#    inline_nodes   => [ qw( bold_italic bold italic underline monospace strike sup sub br 
     14#                            auto_link_http macro trac_links ) ] 
     15#); 
    1416__PACKAGE__->mk_classdata( 
    1517    block_parsers  => [] 
    1618); 
    17 __PACKAGE__->mk_classdata( 
    18     inline_parsers => [] 
    19 ); 
    20 __PACKAGE__->mk_accessors( qw( context pattern) ); 
     19 
     20#__PACKAGE__->mk_classdata( 
     21#    inline_parsers => [] 
     22#); 
     23 
     24__PACKAGE__->mk_accessors( qw( context pattern inline_parser ) ); 
    2125 
    2226sub new { 
    2327    my ( $class, $params ) = @_; 
    24     my $self = { %$params }; 
     28    my $self = { 
     29        %$params, 
     30    }; 
    2531    bless $self, $class; 
    2632    $self->init; 
     33    $self->inline_parser( Text::Trac::InlineNode->new($self->context)); 
    2734    return $self; 
    2835} 
     
    3845 
    3946    $self->block_parsers( $self->_get_parsers('block') ); 
    40     $self->inline_parsers( $self->_get_parsers('inline') ); 
     47    #$self->inline_parsers( $self->_get_parsers('inline') ); 
    4148 
    4249    while ( defined ( my $l = $c->shiftline ) ) { 
     
    4653        } 
    4754    } 
     55} 
     56 
     57sub replace { 
     58    my ( $self, $l ) = @_; 
     59    return $self->inline_parser->parse($l); 
    4860} 
    4961 
  • library/perl/trunk/Text-Trac/lib/Text/Trac/Context.pm

    r328 r332  
    66 
    77my %Defaults = ( 
    8         text        => '', 
    9         html        => '', 
    10         htmllines   => [], 
    11         ul          => {}, 
    12         ol          => {}, 
    13         shift_count => 0, 
    14         in_block_of => [], 
     8        text          => '', 
     9        html          => '', 
     10        htmllines     => [], 
     11        ul            => {}, 
     12        ol            => {}, 
     13        shift_count   => 0, 
     14        in_block_of   => [], 
     15        disable_links => [], 
     16        enable_links  => [], 
    1517); 
    1618 
  • library/perl/trunk/Text-Trac/lib/Text/Trac/Heading.pm

    r324 r332  
    1818    $l = qq(<h$level id="$id">$2</h$level>); 
    1919 
    20     my $parsers = $self->_get_matched_parsers('inline', $l); 
    21     for ( @{$parsers} ){ 
    22         $l = $_->parse($l); 
    23     } 
     20    $l = $self->replace($l); 
    2421    $c->htmllines($l); 
    2522} 
  • library/perl/trunk/Text-Trac/lib/Text/Trac/InlineNode.pm

    r176 r332  
    22 
    33use strict; 
    4  
    5 use base qw( Class::Accessor::Fast ); 
    6 __PACKAGE__->mk_accessors( qw( context pattern) ); 
     4use Tie::IxHash; 
     5use Text::Trac::Macro; 
     6use UNIVERSAL::require; 
     7use Text::Trac::LinkResolver; 
     8 
     9tie my %token_table, 'Tie::IxHash'; 
     10 
     11#my $handler = $token_table{'!?\\[\\d+\\]|(?:\\b|!)r\\d+\\b(?!:\\d)'}; 
     12#$handler->format_link('test'); 
     13 
     14my $link_scheme         = '[\w.+-]+'; 
     15my $quoted_string       = q{'[^']+'|"[^"]+"}; 
     16my $shref_target_first  = '[\w/?!#@]'; 
     17my $shref_target_middle = '(?:\|(?=[^|\s])|[^|<>\s])'; 
     18my $shref_target_last   = '[a-zA-Z0-9/=]'; 
     19my $shref = "!?$link_scheme: 
     20             (?: 
     21                $quoted_string 
     22                |$shref_target_first(?:$shref_target_middle*$shref_target_last)? 
     23              ) 
     24            "; 
     25 
     26my $macro = '\[\[[\w/+-]+(?:\(.*\))?\]\]'; 
     27 
     28my $lhref_relative_target = '[/.][^\s[\]]*'; 
     29my $lhref = "!?\\[ 
     30               (?: 
     31                $link_scheme: 
     32                (?:$quoted_string|[^\\[\\]\\s]*) 
     33                |(?:$lhref_relative_target|[^\\[\\]\\s]) 
     34               ) 
     35               (?: 
     36                \\s+ 
     37                $quoted_string 
     38                |[^\\]]+ 
     39               )? 
     40             \\] 
     41             "; 
     42 
     43my $img_re = qr/\.(gif|jpg|jpeg|png)(\?.*)?$/i; 
     44 
     45 
     46my $rules = join '|', ( map { "($_)" } ( keys %token_table ) ); 
     47$rules = qr/$rules/x; 
     48 
     49map { $_ =~ s/^\!\?// } ( values %token_table ); 
     50map { $_ =~ s/^\\// } ( values %token_table ); 
    751 
    852sub new { 
    9     my ( $class, $params ) = @_; 
    10     my $self = { %$params }; 
     53    my ( $class, $c ) = @_; 
     54 
     55    # external link resolvers 
     56    my %external_handler; 
     57    for ( @Text::Trac::LinkResolver::handlers ) { 
     58        my $class = 'Text::Trac::LinkResolver::' . ucfirst($_); 
     59        $class->require; 
     60        my $handler = $class->new($c); 
     61        $token_table{ $handler->{pattern} } = $handler if defined $handler->{pattern}; 
     62        $external_handler{$_} = $handler; 
     63    } 
     64 
     65    %token_table = ( 
     66        q{'''''}    => 'bolditalic', 
     67        q{'''}      => 'bold', 
     68        q{''}       => 'italic', 
     69        '!?__'      => 'underline', 
     70        '!?~~'      => 'strike', 
     71        '!?,,'      => 'subscript', 
     72        '!?\^'      => 'superscript', 
     73        '`|{{{|}}}' => 'inline', 
     74        $macro      => 'macro', 
     75        %token_table, 
     76        $lhref      => 'lhref', 
     77        $shref      => 'shref', 
     78    ); 
     79 
     80    my $rules = join '|', ( map { "($_)" } ( keys %token_table ) ); 
     81    $rules = qr/$rules/x; 
     82 
     83    map { $_ =~ s/^\!\?// } ( values %token_table ); 
     84    map { $_ =~ s/^\\// } ( values %token_table ); 
     85 
     86    my $self = { 
     87        context          => $c, 
     88        open_tags        => [], 
     89        rules            => $rules, 
     90        external_handler => \%external_handler, 
     91    }; 
    1192    bless $self, $class; 
    12     $self->init; 
    1393    return $self; 
    1494} 
    1595 
     96sub parse { 
     97    my ( $self, $l ) = @_; 
     98    $l =~ s/$self->{rules}/$self->_replace($&, $`, $')/xmseg; 
     99    return $l; 
     100} 
     101 
     102sub _replace { 
     103    my ( $self, $match, $pre_match, $post_match ) = @_; 
     104    if ( $match =~ s/^!// ) { 
     105        return $match; 
     106    } 
     107    else { 
     108      TOKEN: 
     109        for my $token ( keys %token_table ) { 
     110            if ( $match =~ /$token/x ) { 
     111                my $formatter = $token_table{$token}; 
     112                if ( ref $formatter ) { 
     113                    for ( qw/ log source attachment http / ) { 
     114                        next TOKEN if $match =~ /^\[?$_/; 
     115                    } 
     116                    return $formatter->format_link($match); 
     117                } 
     118                else { 
     119                    my $method = "_${formatter}_formatter"; 
     120                    return $self->$method($match, $pre_match, $post_match); 
     121                } 
     122            } 
     123        } 
     124    } 
     125} 
     126 
     127sub _simple_tag_handler { 
     128    my ( $self, $open_tag, $close_tag ) = @_; 
     129 
     130    if ( $self->_is_open($open_tag) ) { 
     131        $self->_close_tag($open_tag); 
     132        return $close_tag; 
     133    } 
     134    else { 
     135        $self->_open_tag($open_tag); 
     136        return $open_tag; 
     137    } 
     138} 
     139 
     140sub _is_open { 
     141    my ( $self, $tag ) = @_; 
     142    return grep { $tag eq $_ } @{ $self->{open_tags} }; 
     143} 
     144 
     145sub _open_tag { 
     146    my ( $self, $tag ) = @_; 
     147    push @{ $self->{open_tags} }, $tag; 
     148} 
     149 
     150sub _close_tag { 
     151    my ( $self, $tag ) = @_; 
     152 
     153    my $index = 0; 
     154    for ( @{ $self->{open_tags} } ) { 
     155        last if $tag eq $_; 
     156        $index++; 
     157    } 
     158    splice @{ $self->{open_tags} }, $index; 
     159} 
     160 
     161sub _bolditalic_formatter { 
     162    my $self = shift; 
     163 
     164    my $is_open = $self->_is_open('<i>'); 
     165 
     166    my $tmp; 
     167    if ( $is_open ) { 
     168        $tmp .= '</i>'; 
     169        $self->_close_tag('<i>'); 
     170    } 
     171 
     172    $tmp .= $self->_bold_formatter; 
     173 
     174    unless ( $is_open ) { 
     175        $tmp .= '<i>'; 
     176        $self->_open_tag('<i>'); 
     177    } 
     178 
     179    return $tmp; 
     180} 
     181 
     182sub _bold_formatter { 
     183    my $self = shift; 
     184    return $self->_simple_tag_handler('<strong>', '</strong>'); 
     185} 
     186 
     187sub _italic_formatter { 
     188    my $self = shift; 
     189    return $self->_simple_tag_handler('<i>', '</i>'); 
     190} 
     191 
     192sub _underline_formatter { 
     193    my ( $self, $match, $pre_match, $post_match ) = @_; 
     194    return $self->_simple_tag_handler('<span class="underline">', '</span>') 
     195} 
     196 
     197sub _strike_formatter { 
     198    my ( $self, $match, $pre_match, $post_match ) = @_; 
     199    return $self->_simple_tag_handler('<del>', '</del>') 
     200} 
     201 
     202sub _superscript_formatter { 
     203    my ( $self, $match, $pre_match, $post_match ) = @_; 
     204    return $self->_simple_tag_handler('<sup>', '</sup>') 
     205} 
     206 
     207sub _subscript_formatter { 
     208    my ( $self, $match, $pre_match, $post_match ) = @_; 
     209    return $self->_simple_tag_handler('<sub>', '</sub>') 
     210} 
     211 
     212sub _inline_formatter { 
     213    my ( $self, $match, $pre_match, $post_match ) = @_; 
     214    return $self->_simple_tag_handler('<tt>', '</tt>') 
     215} 
     216 
     217sub _shref_formatter { 
     218    my ( $self, $match ) = @_; 
     219 
     220    my ( $ns, $target ) = ( $match =~ m/($link_scheme): 
     221                                        ( 
     222                                          $quoted_string 
     223                                         |$shref_target_first 
     224                                          (?: 
     225                                              $shref_target_middle* 
     226                                              $shref_target_last 
     227                                          )? 
     228                                         ) 
     229                                       /x ); 
     230   return $self->_make_link($ns, $target, $match, $match); 
     231} 
     232 
     233sub _lhref_formatter { 
     234    my ( $self, $match ) = @_; 
     235 
     236    my ( $ns, $target, $label ) = 
     237        ( $match =~ m/\[ 
     238                      ($link_scheme): 
     239                      ( 
     240                          (?:$quoted_string|[^\]\s]*) 
     241                         |(?:$lhref_relative_target|[^\]\s]) 
     242                      ) 
     243                      (?: 
     244                          \s+ 
     245                          ($quoted_string|[^\]]+) 
     246                      )? 
     247                      \] 
     248                     /x ); 
     249    if ( !$label ) { # e.g. `[http://target]` or `[wiki:target]` 
     250        if ( $target ) { 
     251            if ( $target =~ m!^//! ) { 
     252                $label = $ns . ':' . $target; 
     253            } 
     254            else { 
     255                $label = $target; 
     256            } 
     257        } 
     258        else { # e.g. `[search:]` 
     259            $label = $ns; 
     260        } 
     261    } 
     262    return $self->_make_link($ns, $target, $match, $label); 
     263} 
     264 
     265sub _make_link { 
     266    my ( $self, $ns, $target, $match, $label ) = @_; 
     267    if ( $target =~ m!^//! or $target eq 'mailto' ) { 
     268        return $self->_make_ext_link($ns . ':' . $target, $label); 
     269    } 
     270    else { 
     271        my $handler = $self->{external_handler}->{$ns}; 
     272        return $handler ? $handler->format_link($match, $target, $label) : $match; 
     273    } 
     274} 
     275 
     276sub _make_ext_link { 
     277    my ( $self, $url, $text, $title ) = @_; 
     278 
     279    my $title_attr = $title ? qq{title="$title"} : ''; 
     280 
     281    $title ||= $text; 
     282    if ( $url =~ $img_re ) { 
     283        return qq{<img src="$url" alt="$title" />}; 
     284    } 
     285 
     286    my $local = $self->{context}->{local} || ''; 
     287    if ( $url !~ /^$local/ or !$local ) { 
     288        return qq{<a class="ext-link" href="$url"$title_attr><span class="icon"></span>$text</a>}; 
     289    } 
     290} 
     291 
     292sub _macro_formatter { 
     293    my ( $self, $match ) = @_; 
     294 
     295    my ( $name, $args ) = ( $match =~ m!\[\[ ([\w/+-]+) (?:\( (.*) \))? \]\]!x ); 
     296 
     297    if ( $name =~ /br/i ) { 
     298        return '<br />'; 
     299    } 
     300    else { 
     301        return Text::Trac::Macro->new->parse($name, $args, $match); 
     302    } 
     303} 
     304 
     305package Text::Trac::InlineNode::Initializer; 
     306 
     307 
     308 
    163091; 
  • library/perl/trunk/Text-Trac/lib/Text/Trac/Macro.pm

    r329 r332  
    11package Text::Trac::Macro; 
    22use strict; 
    3 use base qw(Text::Trac::InlineNode); 
     3use base qw(Text::Trac::InlineNode Class::Accessor::Fast); 
    44use UNIVERSAL::require; 
    55use Text::ParseWords qw(quotewords); 
    66 
    7 sub init { 
    8     my $self = shift; 
    9     $self->pattern(qr/\[\[(\w+) (?:\((.+?)\))? \]\]/x); 
     7__PACKAGE__->mk_accessors( 'pattern' ); 
     8 
     9sub new { 
     10    my $class = shift; 
     11    my $self = {}; 
     12    bless $self, $class; 
    1013    return $self; 
    1114} 
    1215 
    1316sub parse { 
    14     my ( $self, $l ) = @_; 
     17    my ( $self, $name, $args, $match ) = @_; 
    1518    my $c = $self->{context}; 
    16     my $pattern = $self->pattern; 
    17     $l =~ $pattern or return $l; 
    1819 
    19     my $macro = $1; 
    20     my @args  = quotewords( ',\s*', 0, $2 ) if $2; 
     20    my @args  = quotewords( ',\s*', 0, $args ) if $args; 
    2121    map { s/^\s+|\s+$//g } @args; 
    2222 
    23     foreach my $class ("Text::Trac::Macro::$macro", $macro) { 
     23    foreach my $class ("Text::Trac::Macro::$name", $name) { 
    2424        if ( $class->require ) { 
    25             my $result = $class->process( $c, @args ) || ''; 
    26             $l =~ s{$pattern}{$result}xmsg; 
     25            $match = $class->process( $c, @args ) || ''; 
    2726            last; 
    2827        } 
    2928    } 
    3029 
    31     return $l
     30    return $match
    3231} 
    3332 
  • library/perl/trunk/Text-Trac/lib/Text/Trac/Ol.pm

    r324 r332  
    1818 
    1919    my $space = length($1); 
    20     my $level = $c->ol->{level}
     20    my $level = $c->ol->{level} || 0
    2121    $c->ol->{space} ||= 0; 
    2222 
     
    3939 
    4040    if ( $space > $c->ol->{space} ){ 
    41         $l = $start_tag . $l; 
    42         $level++; 
     41       for ( 1 .. ( $space + 1 ) / 2 - $level ) { 
     42           $l = $start_tag . $l; 
     43           $level++; 
     44       } 
    4345    } 
    4446    elsif ( $space < $c->ol->{space} ){ 
    45         $l = '</ol>' . $l; 
    46         $level--; 
     47        for ( 1 .. ( $c->ol->{space} - $space ) / 2 ) { 
     48            $l = '</ol>' . $l; 
     49            $level--; 
     50        } 
    4751    } 
    4852 
     
    6266 
    6367    # parse inline nodes 
    64     my $parsers = $self->_get_matched_parsers('inline', $l); 
    65     for ( @{$parsers} ){ 
    66         $l = $_->parse($l); 
    67     } 
    68  
     68    $l = $self->replace($l); 
    6969    $c->htmllines($l); 
    7070 
  • library/perl/trunk/Text-Trac/lib/Text/Trac/P.pm

    r324 r332  
    3333 
    3434        # parse inline nodes 
    35         $parsers = $self->_get_matched_parsers('inline', $l); 
    36         for ( @{$parsers} ){ 
    37             $l = $_->parse($l); 
    38         } 
     35        #$parsers = $self->_get_matched_parsers('inline', $l); 
     36        #for ( @{$parsers} ){ 
     37        #    $l = $_->parse($l); 
     38        #} 
     39        $l = $self->replace($l); 
    3940        $c->htmllines($l); 
    4041    } 
  • library/perl/trunk/Text-Trac/lib/Text/Trac/Table.pm

    r324 r332  
    2525 
    2626        # parse inline nodes 
    27         my $inline_parsers = $self->_get_matched_parsers('inline', $l) if $l; 
    28         for my $parser ( @{$inline_parsers} ){ 
    29             $l = $parser->parse($l); 
    30         } 
    31  
     27        $l = $self->replace($l); 
    3228        $c->htmllines($l); 
    3329    } 
  • library/perl/trunk/Text-Trac/lib/Text/Trac/Ul.pm

    r324 r332  
    1616 
    1717    my $space = length($1); 
    18     my $level = $c->ul->{level}
     18    my $level = $c->ul->{level} || 0
    1919    $c->ul->{space} ||= 0; 
    2020 
    2121    if ( $space > $c->ul->{space} ) { 
    22         $l = '<ul>' . $l; 
    23         $level++; 
     22        for ( 1 .. ( $space + 1 ) / 2 - $level ) { 
     23            $l = '<ul>' . $l; 
     24            $level++; 
     25        } 
    2426    } 
    2527    elsif ( $space < $c->ul->{space} ) { 
    26         $l = '</ul>' . $l; 
    27         $level--; 
     28        for ( 1 .. ( $c->ul->{space} - $space ) / 2 ) { 
     29            $l = '</ul>' . $l; 
     30            $level--; 
     31        } 
    2832    } 
    2933 
    30     $c->ul({level => $level, space => $space }); 
     34    $c->ul({ level => $level, space => $space }); 
    3135 
    3236    $l =~ s{ $pattern }{<li>$2</li>}xmsg; 
     
    4347 
    4448    # parse inline nodes 
    45     my $parsers = $self->_get_matched_parsers('inline', $l); 
    46     for ( @{$parsers} ){ 
    47         $l = $_->parse($l); 
    48     } 
    49  
     49    $l = $self->replace($l); 
    5050    $c->htmllines($l); 
    5151 
  • library/perl/trunk/Text-Trac/t/01-text-trac.t

    r330 r332  
    217217--- expected 
    218218<p> 
    219 <a class="ext-link" href="http://mizzy.org/">http://mizzy.org/</a> 
    220 <a class="ext-link" href="http://mizzy.org/">Title</a> 
     219<a class="ext-link" href="http://mizzy.org/"><span class="icon"></span>http://mizzy.org/</a> 
     220<a class="ext-link" href="http://mizzy.org/"><span class="icon"></span>Title</a> 
    221221</p> 
    222222 
     
    323323</dl> 
    324324 
     325### unknown short link 
     326--- input 
     327unknown:target 
     328--- expected 
     329<p> 
     330unknown:target 
     331</p> 
     332 
     333### unknown long link 
     334--- input 
     335[unknown:target label] 
     336--- expected 
     337<p> 
     338[unknown:target label] 
     339</p> 
  • library/perl/trunk/Text-Trac/t/02-macros.t

    r328 r332  
    4545[[TheUnknownMacro]] 
    4646</p> 
    47  
    48 ### macros outside of Text::Trac::Macro:: are ok too 
    49 --- input 
    50 [[TestMacro]] 
    51 --- expected 
    52 <p> 
    53 testing, testing, one, two, three... 
    54 </p> 
    55  
  • library/perl/trunk/Text-Trac/t/03-trac-links.t

    r330 r332  
    1111--- expected 
    1212<p> 
    13 <a class="new ticket" href="http://trac.mizzy.org/public/ticket/1">#1</a> 
     13<a class="ticket" href="http://trac.mizzy.org/public/ticket/1">#1</a> 
    1414</p> 
    1515 
     
    1919--- expected 
    2020<p> 
    21 <a class="new ticket" href="http://trac.mizzy.org/public/ticket/1">ticket:1</a> 
     21<a class="ticket" href="http://trac.mizzy.org/public/ticket/1">ticket:1</a> 
    2222</p> 
    2323 
     
    4343--- expected 
    4444<p> 
    45 <a class="new ticket" href="http://trac.mizzy.org/public/ticket/1">1</a> 
     45<a class="ticket" href="http://trac.mizzy.org/public/ticket/1">1</a> 
    4646</p> 
    4747 
     
    5151--- expected 
    5252<p> 
    53 <a class="new ticket" href="http://trac.mizzy.org/public/ticket/1">ticket 1</a> 
     53<a class="ticket" href="http://trac.mizzy.org/public/ticket/1">ticket 1</a> 
    5454</p> 
    5555 
     
    243243### wiki link test 2 
    244244--- input 
     245wiki:trac_links 
     246--- expected 
     247<p> 
     248<a class="wiki" href="http://trac.mizzy.org/public/wiki/trac_links">wiki:trac_links</a> 
     249</p> 
     250 
     251### wiki link test 3 
     252--- input 
     253!TracLinks 
     254--- expected 
     255<p> 
     256TracLinks 
     257</p> 
     258 
     259### wiki link test 4 
     260--- input 
     261!wiki:TracLinks 
     262--- expected 
     263<p> 
    245264wiki:TracLinks 
    246 --- expected 
    247 <p> 
    248 <a class="wiki" href="http://trac.mizzy.org/public/wiki/TracLinks">wiki:TracLinks</a> 
    249 </p> 
    250  
    251 ### wiki link test 3 
    252 --- input 
    253 !TracLinks 
    254 --- expected 
    255 <p> 
    256 TracLinks 
    257 </p> 
    258  
    259 ### wiki link test 4 
    260 --- input 
    261 !wiki:TracLinks 
    262 --- expected 
    263 <p> 
    264 wiki:TracLinks 
    265265</p> 
    266266 
     
    419419 
    420420### source link test 8 
    421 --- input 
     421--- inputx 
    422422!source:trunk/COPYING#200 
    423423--- expected