Method: RbbCode::URLTagNode#url_to_html

Defined in:
lib/rbbcode/node_extensions.rb

#url_to_html(options) ⇒ Object



153
154
155
156
157
158
159
160
161
162
163
# File 'lib/rbbcode/node_extensions.rb', line 153

def url_to_html(options)
  # The :url child node (defined in the .treetop file) may or may not exist,
  # depending on how the link is formatted in the BBCode source.
  if respond_to?(:url) and respond_to?(:text)
    # This is a URL tag formatted like [url=http://example.com]Example[/url].
    '<a href="' + strip_quotes(url.text_value) + '">' + text.text_value + '</a>'
  else
    # This is a URL tag formatted like [url]http://example.com[/url].
    '<a href="' + inner_bbcode + '">' + inner_bbcode + '</a>'
  end
end