Changeset 234

Show
Ignore:
Timestamp:
02/12/2008 13:56:38 (9 months ago)
Author:
jgarber
Message:

The best implementation of the dimension pattern yet.

Location:
branches/superredcloth
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/superredcloth/ext/superredcloth_scan/superredcloth_inline.rl

    r231 r234  
    8282  acronym = ( [A-Z] >A [A-Z0-9]{2,} %T "(" default+ >A %{ STORE(title) } :> ")" ) >X ; 
    8383  caps = ( upper{3,} >A %*T ) >X ; 
    84   dim = ( digit+ >A %{ STORE(x) } (" x " | "x") digit+ >A %*{ STORE(y) } ) >X ; 
     84  dim = ( digit+ >A %{ STORE(x) } (" x " @{ ASET(space, true)} | "x") digit @{ fhold; } ) >X ; 
    8585  tm = [Tt] [Mm] ; 
    8686  trademark = " "? ( "[" tm "]" | "(" tm ")" ) ; 
     
    9090  copyright = ( "[" cee "]" | "(" cee ")" ) ; 
    9191  entity = ( "&" %A ( '#' digit+ | alpha+ ) %T ';' ) >X ; 
     92 
     93  other_phrase = phrase -- dim; 
     94 
    9295 
    9396  main := |* 
     
    132135    html_comment => cat; 
    133136 
    134     phrase => esc; 
     137    other_phrase => esc; 
    135138    PUNCT => esc; 
    136139    space => esc; 
  • branches/superredcloth/lib/superredcloth.rb

    r232 r234  
    161161   
    162162  def dim(opts) 
    163     "#{opts[:x]} × #{opts[:y]}" 
     163    space = opts[:space] ? " " : '' 
     164    "#{opts[:x]}#{space}×#{space}" 
    164165  end 
    165166   
  • branches/superredcloth/test/hobix.yml

    r232 r234  
    6969desc: The letter 'x' becomes a dimension sign when used between digits. 
    7070in: "Observe: 2x3." 
    71 out: "<p>Observe: 2 &#215; 3.</p>" 
     71out: "<p>Observe: 2&#215;3.</p>" 
    7272---  
    7373name: dimension sign with spaces 
     
    7777name: dimension signs chained 
    7878in: "Observe: 2x3x4." 
    79 out: "<p>Observe: 2 &#215; 3 &#215; 4.</p>" 
     79out: "<p>Observe: 2&#215;3&#215;4.</p>" 
    8080---  
    8181name: trademark and copyright