Changeset 299

Show
Ignore:
Timestamp:
04/16/2008 06:37:22 (7 months ago)
Author:
jgarber
Message:

RedCloth::VERSION on a line all by itself outputs the version. Handy for debugging someone else's site.

Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/ext/redcloth_scan/redcloth_scan.rl

    r298 r299  
    7171  table = ( tdef? trows >{INLINE(table, table_open);} ) >{ reg = NULL; } ; 
    7272 
     73  # info 
     74  redcloth_version = "RedCloth::VERSION" (CRLF* EOF | double_return) ; 
     75 
    7376  pre_tag := |* 
    7477    pre_tag_end         { CAT(block); DONE(block); fgoto main; }; 
     
    281284    link_alias      { rb_hash_aset(refs_found, rb_hash_aref(regs, ID2SYM(rb_intern("text"))), rb_hash_aref(regs, ID2SYM(rb_intern("href")))); DONE(block); }; 
    282285    aligned_image   { rb_hash_aset(regs, ID2SYM(rb_intern("type")), plain_block); fgoto block; }; 
     286    redcloth_version { INLINE(html, redcloth_version); }; 
    283287    blank_line => cat; 
    284288    default 
  • trunk/lib/formatters/html.rb

    r274 r299  
    214214    txt.gsub(/&/, '&') 
    215215  end 
     216   
     217  def redcloth_version(opts) 
     218    p(:text => RedCloth::VERSION) 
     219  end 
    216220end 
  • trunk/test/test_parser.rb

    r289 r299  
    3030    assert_match /td/, red("html", %Q{|one || |\nthree | four |}) 
    3131  end 
     32   
     33  def test_redcloth_version_in_output 
     34    assert_equal "<p>#{RedCloth::VERSION}</p>", red("html", "RedCloth::VERSION") 
     35  end 
     36   
     37  def test_redcloth_version_only_on_line_by_itself 
     38    input = "RedCloth::VERSION won't output the RedCloth::VERSION unless it's on a line all by itself.\n\nRedCloth::VERSION" 
     39    html = "<p>RedCloth::<span class=\"caps\">VERSION</span> won&#8217;t output the RedCloth::<span class=\"caps\">VERSION</span> unless it&#8217;s on a line all by itself.</p>\n<p>#{RedCloth::VERSION}</p>" 
     40    assert_equal html, red("html", input) 
     41  end 
    3242 
    3343end