Changeset 375

Show
Ignore:
Timestamp:
03/22/07 16:17:19 (2 years ago)
Author:
astrange
Message:

Make seperate SSA tags immediately following each other work.
Translate \h to " ".
Ignore <b> in srt because the text is bold anyway.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/SSATagParsing.m.rl

    r370 r375  
    432432                                 
    433433                                action nl_handler { 
     434                                        NSString *append = @"\n"; 
    434435                                        parsetmp = [NSString stringWithCharacters:skipbegin length:(p-2)-skipbegin]; 
    435436                                        [output appendString:parsetmp]; 
     
    437438                                        skipbegin = p; 
    438439 
    439                                         [output appendString:@"\n"]; 
     440                                        if (*(p - 1) == 'h') append = @" "; 
     441                     
     442                                        [output appendString:append]; 
    440443                                         
    441444                                        lengthreduce++; 
     
    443446                                 
    444447                                action enter_tag { 
    445                                         parsetmp = [NSString stringWithCharacters:skipbegin length:p-skipbegin]; 
     448                                        unsigned taglen = p - skipbegin; 
     449                                        parsetmp = [NSString stringWithCharacters:skipbegin length:taglen]; 
    446450                                        [output appendString:parsetmp]; 
    447                                          
    448                                          
    449451                                        skipbegin = p; 
    450452                                         
     
    469471                                 
    470472                                action exit_tag { 
     473                                        // XXX exit_tag ideally should run one char later, so we just pretend it does 
     474                                        p++; 
    471475                                        outputoffset += p - skipbegin; 
    472476                                        skipbegin = p; 
     
    494498                                                re = nre; 
    495499                                        } 
     500                                        p--; 
    496501                                } 
    497502                                 
     
    577582                                                                ); 
    578583                                 
    579                                 cmd = "\\"  cmd_specific; 
    580                                  
    581                                 tag = "{" :> ((cmd*) | ([^\\}]*)) "}"; 
    582                                  
    583                                 nl = "\\" [Nn]; 
    584                                  
    585                                 special = nl % nl_handler |  
    586                                                  (tag > enter_tag % exit_tag); 
     584                                cmd = ("\\" :> cmd_specific)+; 
     585                                 
     586                                plaintext = [^}]*; 
     587 
     588                                tag = "{" (cmd | plaintext) % exit_tag "}"; 
     589                                 
     590                                nl = "\\" [Nnh]; 
     591                                 
     592                                special = nl % nl_handler | (tag > enter_tag); 
    587593                                                                 
    588594                                text = any*; 
     
    606612                 
    607613        } 
    608          
    609614        return rentities; 
    610615} 
  • trunk/TextSubCodec.c

    r351 r375  
    305305                if (!buf) return noErr; 
    306306                CFStringFindAndReplace(buf, CFSTR("<i>"),  CFSTR("{\\i1}"), CFRangeMake(0,CFStringGetLength(buf)), 0); 
    307                 CFStringFindAndReplace(buf, CFSTR("<b>"),  CFSTR("{\\b1}"), CFRangeMake(0,CFStringGetLength(buf)), 0); 
    308307                CFStringFindAndReplace(buf, CFSTR("</i>"), CFSTR("{\\i0}"), CFRangeMake(0,CFStringGetLength(buf)), 0); 
    309                 CFStringFindAndReplace(buf, CFSTR("</b>"), CFSTR("{\\b0}"), CFRangeMake(0,CFStringGetLength(buf)), 0);           
    310308                CFStringFindAndReplace(buf, CFSTR("<"),    CFSTR("{"),      CFRangeMake(0,CFStringGetLength(buf)), 0); 
    311309                CFStringFindAndReplace(buf, CFSTR(">"),   CFSTR("}"),      CFRangeMake(0,CFStringGetLength(buf)), 0);