module RD::RD2HTMLExtVisitor::RefExtension

TextBlock Label Reference Extension from rd2rwiki-lib.rb

Public Instance Methods

apply_to_RefToElement(element, content) click to toggle source
# File lib/rd/rd2html-ext-lib.rb, line 170
def apply_to_RefToElement(element, content)
  content = content.join("")
  apply_ref_extension(element, element_label(element), content)
end

Private Instance Methods

apply_ref_extension(element, label, content) click to toggle source
# File lib/rd/rd2html-ext-lib.rb, line 176
def apply_ref_extension(element, label, content)
  @ref_extension.each do |entry|
    result = __send__(entry, element, label, content)
    return result if result
  end
end
default_ref_ext(element, label, content) click to toggle source
# File lib/rd/rd2html-ext-lib.rb, line 192
def default_ref_ext(element, label, content)
  if anchor = refer(element)
    content = content.sub(/^function#/, "")
    %Q[<a href="\##{anchor}">#{content}</a>]
  else
    # warning?
    label = hyphen_escape(element.to_label)
    %Q[<!-- Reference, RDLabel "#{label}" doesn't exist -->] +
      %Q[<em class="label-not-found">#{content}</em><!-- Reference end -->]
    #'
  end
end
element_label(element) click to toggle source
# File lib/rd/rd2html-ext-lib.rb, line 183
def element_label(element)
  case element
  when RDElement
    element.to_label
  else
    element
  end
end
ref_ext_IMG(element, label, content) click to toggle source
# File lib/rd/rd2html-ext-lib.rb, line 221
def ref_ext_IMG(element, label, content)
  return nil unless /^IMG:(.+)$/i =~ label
  file = $1
  label.to_s == content.to_s and content = file
  if @use_image_size
    begin
      unless @image_size[ file ]
        open( file ) do |img|
          is = ImageSize::new( img )
          @image_size[ file ] = [ is.get_height, is.get_width ]
        end
      end

      height, width = @image_size[ file ]
      %Q[<img src="#{$1}" alt="#{content}" height="#{height}" width="#{width}" />]
    rescue
      %Q[<img src="#{$1}" alt="#{content}">]
    end
  else
    %Q[<img src="#{$1}" alt="#{content}" />]
  end
end
ref_ext_RAA(element, label, content) click to toggle source
# File lib/rd/rd2html-ext-lib.rb, line 214
def ref_ext_RAA(element, label, content)
  return nil unless /^RAA:(.+)$/ =~ label
  name = CGI.escape($1)
  content = "[#{label}]" if label == content
  %Q[<a href="http://raa.ruby-lang.org/list.rhtml?name=#{ name }">#{ content }</a>]
end
ref_ext_RubyML(element, label, content) click to toggle source
# File lib/rd/rd2html-ext-lib.rb, line 205
def ref_ext_RubyML(element, label, content)
  return nil unless /^(ruby-(?:talk|list|dev|math)):(.+)$/ =~ label
  ml = $1
  article = $2.sub(/^0+/, '')
  content = "[#{label}]" if label == content

  %Q[<a href="http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/#{ ml }/#{ article }">#{ content }</a>]
end