Changeset 260

Show
Ignore:
Timestamp:
03/10/2008 14:07:59 (8 months ago)
Author:
jgarber
Message:

Refactor how extended blocks are ended; fixes problem with block picking up next block's attributes.

Location:
branches/superredcloth/ext/superredcloth_scan
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/superredcloth/ext/superredcloth_scan/superredcloth.h

    r258 r260  
    3535  regs = rb_hash_new() 
    3636#define ADD_EXTENDED_BLOCK()    rb_str_append(html, red_block(rb_formatter, regs, block, refs)); CLEAR(block); 
     37#define END_EXTENDED()     extend = Qnil; regs = rb_hash_new(); 
    3738#define ADD_BLOCKCODE()    rb_str_append(html, red_blockcode(rb_formatter, regs, block)); CLEAR(block); regs = rb_hash_new() 
    3839#define ADD_EXTENDED_BLOCKCODE()    rb_str_append(html, red_blockcode(rb_formatter, regs, block)); CLEAR(block); 
  • branches/superredcloth/ext/superredcloth_scan/superredcloth_scan.rl

    r258 r260  
    3333  btype = ( "p" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "div" ) ; 
    3434  block_start = ( btype >A %{ STORE(type) } A C :> "." ( "." %extend | "" ) " "+ ) ; 
    35   next_block_start = ( btype A C :> "." ) ; 
     35  next_block_start = ( btype A C :> "."+ " " ) >A @{ p = reg - 1; } ; 
    3636  double_return = CRLF{2,} ; 
    3737  block_end = ( double_return | EOF ); 
    38   extended_block_end = double_return . next_block_start >A @{ p = reg - 1; } ; 
    3938  ftype = ( "fn" >A %{ STORE(type) } digit+ >A %{ STORE(id) } ) ; 
    4039  footnote_start = ( ftype A C :> dotspace ) ; 
     
    7574  pre_block := |* 
    7675    EOF                { ADD_BLOCKCODE(); fgoto main; }; 
    77     extended_block_end { ADD_BLOCKCODE(); fgoto main; }; 
    7876    double_return      { if (NIL_P(extend)) { ADD_BLOCKCODE(); fgoto main; } else { ADD_EXTENDED_BLOCKCODE(); } }; 
     77    next_block_start   { END_EXTENDED(); fgoto main; }; 
    7978    default => esc_pre; 
    8079  *|; 
     
    8786  notextile_block := |* 
    8887    EOF                { DONE(block); fgoto main; }; 
    89     extended_block_end { DONE(block); fgoto main; }; 
    9088    double_return      { if (NIL_P(extend)) { DONE(block); fgoto main; } else { DONE(block); } }; 
     89    next_block_start   { END_EXTENDED(); fgoto main; }; 
    9190    default => cat; 
    9291  *|; 
     
    9998  bc := |* 
    10099    EOF                { ADD_BLOCKCODE(); INLINE(html, bc_close); plain_block = rb_str_new2("p"); fgoto main; }; 
    101     extended_block_end { ADD_BLOCKCODE(); INLINE(html, bc_close); plain_block = rb_str_new2("p"); fgoto main; }; 
    102100    double_return      { if (NIL_P(extend)) { ADD_BLOCKCODE(); INLINE(html, bc_close); plain_block = rb_str_new2("p"); fgoto main; } else { ADD_EXTENDED_BLOCKCODE(); } }; 
     101    next_block_start   { INLINE(html, bc_close); plain_block = rb_str_new2("p");  END_EXTENDED(); fgoto main; }; 
    103102    default => esc_pre; 
    104103  *|; 
     
    106105  bq := |* 
    107106    EOF                { ADD_BLOCK(); INLINE(html, bq_close); fgoto main; }; 
    108     extended_block_end { ADD_BLOCK(); INLINE(html, bq_close); fgoto main; }; 
    109107    double_return      { if (NIL_P(extend)) { ADD_BLOCK(); INLINE(html, bq_close); fgoto main; } else { ADD_EXTENDED_BLOCK(); } }; 
    110108    default => cat; 
     109    next_block_start   { INLINE(html, bq_close); END_EXTENDED(); fgoto main; }; 
    111110  *|; 
    112111 
    113112  block := |* 
    114113    EOF                { ADD_BLOCK(); fgoto main; }; 
    115     extended_block_end { ADD_BLOCK(); fgoto main; }; 
    116114    double_return      { if (NIL_P(extend)) { ADD_BLOCK(); fgoto main; } else { ADD_EXTENDED_BLOCK(); } }; 
     115    next_block_start   { END_EXTENDED(); fgoto main; }; 
    117116    default => cat; 
    118117  *|;