Class: Marker::URL

Inherits:
ParseNode show all
Defined in:
lib/marker/links.rb

Instance Method Summary collapse

Methods inherited from Treetop::Runtime::SyntaxNode

#present?

Instance Method Details

#bare_urlObject

returns just the URL that was matched



154
155
156
# File 'lib/marker/links.rb', line 154

def bare_url
  text_value
end

#to_html(options = {}) ⇒ Object



139
140
141
142
143
144
145
146
# File 'lib/marker/links.rb', line 139

def to_html( options = {} )
  url = bare_url
  if url =~ /[.,!?:]$/
    "<a href='#{url[0...-1]}'>#{url[0...-1]}</a>#{url[-1,1]}"
  else
    "<a href='#{url}'>#{url}</a>"
  end
end

#to_s(options = {}) ⇒ Object



148
149
150
151
# File 'lib/marker/links.rb', line 148

def to_s( options = {} )
  # no need to worry about trailing punctuation since it's all text.
  bare_url
end