Class: Marker::InternalLink

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

Instance Method Summary collapse

Methods inherited from Treetop::Runtime::SyntaxNode

#present?

Instance Method Details

#aObject

:nodoc:



64
65
66
# File 'lib/marker/links.rb', line 64

def a #:nodoc:
  nil
end

#lObject

:nodoc:



68
69
70
# File 'lib/marker/links.rb', line 68

def l #:nodoc:
  nil
end

#label(format, options = {}) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/marker/links.rb', line 32

def label( format, options = {} )
  if l
    case format
    when :html
      l.to_html(options)
    else
      l.to_s(options)
    end
  else
    if a
      # an arg delimiter was present, but without a label
      # sanitize: remove trailing parenthetical remarks
      target.gsub(/\s*\([^)]*\)$/, '')
    else
      target
    end
  end
end

#path(options = {}) ⇒ Object



26
27
28
29
30
# File 'lib/marker/links.rb', line 26

def path( options = {} )
  p = options[:link_base] || ''
  p.chomp! '/'
  p += '/' + target
end

#tObject

– defaults ++



60
61
62
# File 'lib/marker/links.rb', line 60

def t #:nodoc:
  nil
end

#targetObject



51
52
53
54
55
56
57
# File 'lib/marker/links.rb', line 51

def target
  if t
    t.text_value
  else
    ''
  end
end

#to_html(options = {}) ⇒ Object



11
12
13
# File 'lib/marker/links.rb', line 11

def to_html( options = {} )
  "<a href='#{path(options)}'>#{label(:html, options)}</a>"
end

#to_s(options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/marker/links.rb', line 15

def to_s( options = {} )
  f = options[:footnotes]
  if f
    l = label(:text, options)
    n = f.add( path(options), l )
    "#{l} [#{n}]"
  else
    "#{label(:text, options)} [#{path}]"
  end
end