replace_relative_links_in_content

in _plugins/jekyll_relative_links.rb [104:126]


    def replace_relative_links_in_content(content, relative_to_path)
      url_base = File.dirname(relative_to_path)

      content.dup.gsub(LINK_REGEX) do |original|
        link = link_parts(Regexp.last_match)

        if (link.path == "" && link.fragment == "" && link.text && link.text.start_with?("http"))
          link.path = link.text

        else
          next original unless replaceable_link?(link.path)

          path = path_from_root(link.path, url_base)
          url  = url_for_path(path, relative_to_path)

          next original unless url

          link.path = url
        end
        replacement_text(link)
      end
    end