Skip to content

Commit

Permalink
fixed rewriting of remote .md links
Browse files Browse the repository at this point in the history
  • Loading branch information
dmalan committed Aug 29, 2024
1 parent 46c40e9 commit bb43845
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/jekyll-theme-cs50.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bb43845

Please sign in to comment.