module WikiCloth
class ReferencesExtension < Extension
# reference content
# reference content
#
# reference content
#
element 'ref' do |buffer|
# find our named reference reference if it exists
named_ref = buffer.get_attribute_by_name("name")
ref = @options[:link_handler].find_reference_by_name(named_ref) unless named_ref.nil?
# reference either not "named" or first time in document
if ref.nil?
@options[:link_handler].references << { :name => named_ref, :value => buffer.element_content, :count => 0, :group => buffer.get_attribute_by_name("group") }
ref = @options[:link_handler].references.last
end
ref_id = (named_ref.nil? ? "" : "#{named_ref}_") + "#{@options[:link_handler].reference_index(ref)}-#{ref[:count]}"
cite_anchor = "#cite_note-" + (named_ref.nil? ? "" : "#{named_ref}_") + @options[:link_handler].reference_index(ref).to_s
group_label = buffer.get_attribute_by_name("group") ? "#{buffer.get_attribute_by_name("group")} " : ""
ref_link = "#{@options[:link_handler].reference_index(ref)}"
ref[:count] += 1
"[#{group_label}#{ref_link}]"
end
#