Changeset 243

Show
Ignore:
Timestamp:
02/22/2008 16:06:26 (9 months ago)
Author:
jgarber
Message:

Fix escapement of special characters inside inline code bits.

Location:
branches/superredcloth
Files:
3 modified

Legend:

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

    r238 r243  
    99/* function defs */ 
    1010void rb_str_cat_escaped(VALUE str, char *tokstart, char *tokend); 
     11void rb_str_cat_escaped_for_preformatted(VALUE str, char *tokstart, char *tokend); 
    1112VALUE superredcloth_inline(VALUE, char *, char *); 
    1213VALUE superredcloth_inline2(VALUE, VALUE); 
     
    1718VALUE red_pass2(VALUE, VALUE, VALUE, VALUE); 
    1819VALUE red_pass(VALUE, VALUE, VALUE, ID); 
     20VALUE red_pass_code(VALUE, VALUE, VALUE, ID); 
    1921 
    2022/* parser macros */ 
     
    2527#define PASS(H, A, T)  rb_str_append(H, red_pass(rb_formatter, regs, ID2SYM(rb_intern(#A)), rb_intern(#T))) 
    2628#define PASS2(H, A, T) rb_str_append(H, red_pass2(rb_formatter, regs, ID2SYM(rb_intern(#A)), ID2SYM(rb_intern(#T)))) 
     29#define PASS_CODE(H, A, T) rb_str_append(H, red_pass_code(rb_formatter, regs, ID2SYM(rb_intern(#A)), rb_intern(#T))) 
    2730#define ADD_BLOCK() \ 
    2831  rb_str_append(html, red_block(rb_formatter, regs, block)); \ 
  • branches/superredcloth/ext/superredcloth_scan/superredcloth_inline.rl

    r235 r243  
    5959  # markup 
    6060  code = "["? "@" >X C mtext >A %T :> "@" "]"? ; 
     61  code_tag = ("<code>" mspace?) >X (( mtext ) >A %T) :>> (mspace? "</code>") ; 
    6162  strong = "["? "*" >X C mtext >A %T :> "*" "]"? ; 
    6263  b = "["? "**" >X C mtext >A %T :> "**" "]"? ; 
     
    100101    link { STORE_URL(href); PASS(block, name, link); }; 
    101102 
    102     code { PASS(block, text, code); }; 
     103    code { PASS_CODE(block, text, code); }; 
     104    code_tag { PASS_CODE(block, text, code); }; 
    103105    strong { PASS(block, text, strong); }; 
    104106    b { PASS(block, text, b); }; 
     
    156158 
    157159VALUE 
     160red_pass_code(VALUE rb_formatter, VALUE regs, VALUE ref, ID meth) 
     161{ 
     162  VALUE txt = rb_hash_aref(regs, ref); 
     163  if (!NIL_P(txt)) { 
     164    VALUE txt2 = rb_str_new2(""); 
     165    rb_str_cat_escaped_for_preformatted(txt2, RSTRING(txt)->ptr, RSTRING(txt)->ptr + RSTRING(txt)->len); 
     166    rb_hash_aset(regs, ref, txt2); 
     167  } 
     168  return rb_funcall(rb_formatter, meth, 1, regs); 
     169} 
     170 
     171VALUE 
    158172red_pass2(VALUE rb_formatter, VALUE regs, VALUE ref, VALUE btype) 
    159173{ 
  • branches/superredcloth/test/threshold.yml

    r242 r243  
    367367  // display a hello message 
    368368  </code> 
    369   <code>         print "Hello, World"; 
     369  <code>        print "Hello, World"; 
    370370  } 
    371371  ?&gt;