From bb43845cc4eecd742301a2daa53adf040cb988ce Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Wed, 28 Aug 2024 20:43:14 -0400 Subject: [PATCH] fixed rewriting of remote .md links --- lib/jekyll-theme-cs50.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/jekyll-theme-cs50.rb b/lib/jekyll-theme-cs50.rb index 73d86ec..fe1680e 100644 --- a/lib/jekyll-theme-cs50.rb +++ b/lib/jekyll-theme-cs50.rb @@ -576,11 +576,15 @@ def parse_link current_link = @tree.children.select{ |element| [:a].include?(element.type) }.last unless current_link.nil? - # If inline link ends with .md - if match = current_link.attr["href"].match(/\A([^\s]*)\.md(\s*.*)\z/) - - # Rewrite as /, just as jekyll-relative-links does - current_link.attr["href"] = match.captures[0] + "/" + match.captures[1] + # If a relative link + if !current_link.attr["href"].start_with?("https://", "http://") + + # If link ends with .md + if match = current_link.attr["href"].match(/\A([^\s]*)\.md(\s*.*)\z/) + + # Rewrite as /, just as jekyll-relative-links does + current_link.attr["href"] = match.captures[0] + "/" + match.captures[1] + end end end end