Class: Facwparser::Element::A

Inherits:
InlineElementBase show all
Defined in:
lib/facwparser/element.rb

Instance Attribute Summary

Attributes inherited from InlineElementBase

#text

Attributes inherited from ElementBase

#children, #source

Instance Method Summary collapse

Methods inherited from InlineElementBase

#==, #initialize

Methods inherited from ElementBase

#==, #initialize, #render_text

Constructor Details

This class inherits a constructor from Facwparser::Element::InlineElementBase

Instance Method Details

#render_html(options) ⇒ Object



236
237
238
239
240
241
242
243
244
245
# File 'lib/facwparser/element.rb', line 236

def render_html(options)
  if @text =~ /\A(.+)\|((?:https?|ftp|file):.+)\z/
    return '<a href="' + CGI.escapeHTML($2) +'">' + CGI.escapeHTML($1) + '</a>'
  elsif @text =~ /\A(?:https?|ftp|file):.+\z/
    return '<a href="' + CGI.escapeHTML(@text) +'">' + CGI.escapeHTML(@text) + '</a>'
  else
    url_prefix = (options && options['url_prefix']) || '/'
    return '<a href="' + CGI.escapeHTML(url_prefix + @text) +'">' + CGI.escapeHTML(@text) + '</a>'
  end
end