Method: RedClothForTex#image

Defined in:
lib/redcloth_for_tex.rb

#image(text) ⇒ Object



487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
# File 'lib/redcloth_for_tex.rb', line 487

def image( text ) 
  text.gsub!( /
             \!                   # opening
              (\<|\=|\>)?          # optional alignment atts
               (#{C})               # optional style,class atts
                (?:\. )?             # optional dot-space
                 ([^\s(!]+?)          # presume this is the src
  \s?                  # optional space
   (?:\(((?:[^\(\)]|\([^\)]+\))+?)\))?   # optional title
  \!                   # closing
   (?::#{ HYPERLINK })? # optional href
   /x ) do |m|
    algn,atts,url,title,href,href_a1,href_a2 = $~[1..7]
    atts = pba( atts )
    atts << " align=\"#{ i_align( algn ) }\"" if algn
    atts << " title=\"#{ title }\"" if title
    atts << " alt=\"#{ title }\"" 
    # size = @getimagesize($url);
    # if($size) $atts.= " $size[3]";
    
    href = check_refs( href ) if href
    url = check_refs( url )
    
    out = ''
    out << "<a href=\"#{ href }\">" if href
    out << "<img src=\"#{ url }\"#{ atts } />"
    out << "</a>#{ href_a1 }#{ href_a2 }" if href
    
    out
  end
end