Skip to content

Instantly share code, notes, and snippets.

@rbq
Created November 27, 2013 16:50
Show Gist options
  • Save rbq/7679076 to your computer and use it in GitHub Desktop.
Save rbq/7679076 to your computer and use it in GitHub Desktop.
class RDoc::Markup::Formatter
def parse_url url
case url
when /^rdoc-label:([^:]*)(?::(.*))?/ then
scheme = 'link'
path = "##{$1}"
id = " id=\"#{$2}\"" if $2
when /([A-Za-z]+):(.*)/ then
scheme = $1.downcase
path = $2
when /^#/ then
else
scheme = 'http'
path = url
url = url
end
if scheme == 'link' then
url = if path[0, 1] == '#' then # is this meaningful?
path
else
self.class.gen_relative_url @from_path, path
end
end
[scheme, url, id]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment