Changeset 238
- Timestamp:
- 02/19/2008 09:29:09 (9 months ago)
- Location:
- branches/superredcloth
- Files:
-
- 3 modified
-
ext/superredcloth_scan/superredcloth.h (modified) (1 diff)
-
ext/superredcloth_scan/superredcloth_scan.rl (modified) (6 diffs)
-
lib/superredcloth.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/superredcloth/ext/superredcloth_scan/superredcloth.h
r237 r238 25 25 #define PASS(H, A, T) rb_str_append(H, red_pass(rb_formatter, regs, ID2SYM(rb_intern(#A)), rb_intern(#T))) 26 26 #define PASS2(H, A, T) rb_str_append(H, red_pass2(rb_formatter, regs, ID2SYM(rb_intern(#A)), ID2SYM(rb_intern(#T)))) 27 #define ADD_BLOCK() rb_str_append(html, red_block(rb_formatter, regs, block)); CLEAR(block); regs = rb_hash_new() 27 #define ADD_BLOCK() \ 28 rb_str_append(html, red_block(rb_formatter, regs, block)); \ 29 extend = Qnil; \ 30 CLEAR(block); \ 31 regs = rb_hash_new() 28 32 #define ADD_EXTENDED_BLOCK() rb_str_append(html, red_block(rb_formatter, regs, block)); CLEAR(block); 29 33 #define ADD_BLOCKCODE() rb_str_append(html, red_blockcode(rb_formatter, regs, block)); CLEAR(block); regs = rb_hash_new() 34 #define ADD_EXTENDED_BLOCKCODE() rb_str_append(html, red_blockcode(rb_formatter, regs, block)); CLEAR(block); 30 35 #define ASET(T, V) rb_hash_aset(regs, ID2SYM(rb_intern(#T)), rb_str_new2(#V)); 31 36 #define AINC(T) red_inc(regs, ID2SYM(rb_intern(#T))); -
branches/superredcloth/ext/superredcloth_scan/superredcloth_scan.rl
r237 r238 19 19 include superredcloth_common "ext/superredcloth_scan/superredcloth_common.rl"; 20 20 21 action notextile { rb_str_append(html, rb_funcall(rb_formatter, rb_intern("ignore"), 1, regs)); } 22 action extend { extend = 1; } 23 action no_extend { extend = 0; } 24 action add_unless_extended { if (extend == 0) { ADD_BLOCK(); fgoto main; } else { ADD_EXTENDED_BLOCK(); } } 21 action extend { extend = rb_hash_aref(regs, ID2SYM(rb_intern("type"))); } 25 22 26 23 # blocks … … 30 27 pre_start = "<pre" [^>]* ">" (space* "<code>")? ; 31 28 pre_end = ("</code>" space*)? "</pre>" ; 32 bc_start = ( "bc" A C :> "." ( "." %extend | "" %no_extend ) " "+ ) ; 33 btype = ( "p" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "bq" | "bc" | "pre" | "notextile" | "div" ) >A %{ STORE(type) } ; 34 block_start = ( btype A C :> "." ( "." %extend | "" %no_extend ) " "+ ) ; 35 block_end = ( CRLF{2} | EOF ); 36 extended_block_end = block_end . block_start >A @{ p = reg - 1; }; 29 bc_start = ( "bc" >A %{ STORE(type) } A C :> "." ( "." %extend | "" ) " "+ ) ; 30 bq_start = ( "bq" >A %{ STORE(type) } A C :> "." ( "." %extend | "" ) " "+ ) ; 31 btype = ( "p" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "pre" | "notextile" | "div" ) ; 32 block_start = ( btype >A %{ STORE(type) } A C :> "." ( "." %extend | "" ) " "+ ) ; 33 next_block_start = ( btype A C :> "." ) ; 34 double_return = CRLF{2} ; 35 block_end = ( double_return | EOF ); 36 extended_block_end = double_return . next_block_start >A @{ p = reg - 1; } ; 37 37 ftype = ( "fn" >A %{ STORE(type) } digit+ >A %{ STORE(id) } ) ; 38 38 footnote_start = ( ftype A C :> dotspace ) ; … … 61 61 table = ( tdef? trows >{INLINE(table, table_open);} ) >{ reg = NULL; } ; 62 62 63 bc := |*64 block_end { ADD_BLOCKCODE(); fgoto main; };65 default => esc_pre;66 *|;67 68 63 pre := |* 69 64 pre_end { CAT(block); DONE(block); fgoto main; }; … … 81 76 *|; 82 77 78 bc := |* 79 EOF { ADD_BLOCKCODE(); INLINE(html, bc_close); plain_block = rb_str_new2("p"); fgoto main; }; 80 extended_block_end { ADD_BLOCKCODE(); INLINE(html, bc_close); plain_block = rb_str_new2("p"); fgoto main; }; 81 double_return { if (NIL_P(extend)) { ADD_BLOCKCODE(); INLINE(html, bc_close); plain_block = rb_str_new2("p"); fgoto main; } else { ADD_EXTENDED_BLOCKCODE(); } }; 82 default => esc_pre; 83 *|; 84 85 bq := |* 86 EOF { ADD_BLOCK(); INLINE(html, bq_close); fgoto main; }; 87 extended_block_end { ADD_BLOCK(); INLINE(html, bq_close); fgoto main; }; 88 double_return { if (NIL_P(extend)) { ADD_BLOCK(); INLINE(html, bq_close); fgoto main; } else { ADD_EXTENDED_BLOCK(); } }; 89 default => cat; 90 *|; 91 83 92 block := |* 84 block_end => add_unless_extended;93 EOF { ADD_BLOCK(); fgoto main; }; 85 94 extended_block_end { ADD_BLOCK(); fgoto main; }; 95 double_return { if (NIL_P(extend)) { ADD_BLOCK(); fgoto main; } else { ADD_EXTENDED_BLOCK(); } }; 86 96 default => cat; 87 97 *|; … … 104 114 standalone_html { CAT(block); DONE(block); }; 105 115 html_start { ASET(type, notextile); CAT(block); fgoto html; }; 106 bc_start { ASET(type, bc); fgoto bc; }; 116 bc_start { INLINE(html, bc_open); ASET(type, code); plain_block = rb_str_new2("code"); fgoto bc; }; 117 bq_start { INLINE(html, bq_open); ASET(type, p); fgoto bq; }; 107 118 block_start { fgoto block; }; 108 119 footnote_start { fgoto footnote; }; … … 139 150 int list_continue = 0; 140 151 VALUE plain_block = rb_str_new2("p"); 141 int extend = 0;152 VALUE extend = Qnil; 142 153 char listm[10] = ""; 143 154 -
branches/superredcloth/lib/superredcloth.rb
r235 r238 98 98 end 99 99 100 def bc (opts)100 def bc_open(opts) 101 101 opts[:block] = true 102 "<pre#{pba(opts)}> <code#{pba(opts)}>#{opts[:text]}</code></pre>"102 "<pre#{pba(opts)}>" 103 103 end 104 104 105 def bq(opts) 105 def bc_close(opts) 106 "</pre>" 107 end 108 109 def bq_open(opts) 106 110 opts[:block] = true 107 "<blockquote#{pba(opts)}><p#{pba(opts)}>#{opts[:text]}</p></blockquote>" 111 "<blockquote#{pba(opts)}>" 112 end 113 114 def bq_close(opts) 115 "</blockquote>" 108 116 end 109 117