module Gollum
class Markup
# Attempt to process the tag as a page link tag.
#
# tag - The String tag contents (the stuff inside the double
# brackets).
# no_follow - Boolean that determines if rel="nofollow" is added to all
# tags.
#
# Returns the String HTML if the tag is a valid page link tag or nil
# if it is not.
def process_page_link_tag(tag, no_follow = false)
parts = tag.split('|')
name = parts[0].strip
cname = @wiki.page_class.cname((parts[1] || parts[0]).strip)
if pos = cname.index('#')
extra = cname[pos..-1]
cname = cname[0..(pos-1)]
end
tag = if name =~ %r{^https?://} && parts[1].nil?
%{#{name}}
else
presence = "absent"
link_name = cname
page = find_page_from_name(cname)
if page
presence = "present"
end
link = ::File.join(@wiki.base_path, CGI.escape(link_name))
%{#{name}}
end
if tag && no_follow
tag.sub! /^