Class: Marker::ExternalLink

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

Instance Method Summary collapse

Methods inherited from Treetop::Runtime::SyntaxNode

#present?

Instance Method Details

#lObject

:nodoc:



133
134
135
# File 'lib/marker/links.rb', line 133

def l #:nodoc:
  nil
end

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



107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/marker/links.rb', line 107

def label( format, options = {} )
  if l
    case format
    when :html
      l.to_html(options)
    else
      l.to_s(options)
    end
  else
    ''
  end
end

#tObject

– defaults ++



129
130
131
# File 'lib/marker/links.rb', line 129

def t #:nodoc:
  nil
end

#targetObject



120
121
122
123
124
125
126
# File 'lib/marker/links.rb', line 120

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

#to_html(options = {}) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/marker/links.rb', line 74

def to_html( options = {} )
  if l
    "<a href='#{target}'>#{label(:html, options)}</a>"
  else
    f = options[:footnotes]
    if f
      n = f.add( target )
      "<a href='#{target}'>[#{n}]</a>"
    else
      "<a href='#{target}'>#{target}</a>"
    end
  end
end

#to_s(options = {}) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/marker/links.rb', line 88

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