Method: RedClothForTex#links

Defined in:
lib/redcloth_for_tex.rb


448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
# File 'lib/redcloth_for_tex.rb', line 448

def links( text ) 
text.gsub!( /
 ([\s\[{(]|[#{PUNCT}])?     # $pre
        "                          # start
        (#{C})                     # $atts
        ([^"]+?)                   # $text
  \s?
   (?:\(([^)]+?)\)(?="))?     # $title
        ":
                    (\S+?)                     # $url
                     (\/)?                      # $slash
                      ([^\w\/;]*?)               # $post
                       (?=\s|$)
  /x ) do |m|
    pre,atts,text,title,url,slash,post = $~[1..7]

    url.gsub!(/(\\)(.)/, '\2')
    url = check_refs( url )
    
    atts = pba( atts )
    atts << " title=\"#{ title }\"" if title
    atts = shelve( atts ) if atts
    
    "#{ pre }\\textit{#{ text }} \\footnote{\\texttt{\\textless #{ url }#{ slash }" + 
        "\\textgreater}#{ post }}"
  end
end