Skip to content

Commit bb43845

Browse files
committed
fixed rewriting of remote .md links
1 parent 46c40e9 commit bb43845

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/jekyll-theme-cs50.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -576,11 +576,15 @@ def parse_link
576576
current_link = @tree.children.select{ |element| [:a].include?(element.type) }.last
577577
unless current_link.nil?
578578

579-
# If inline link ends with .md
580-
if match = current_link.attr["href"].match(/\A([^\s]*)\.md(\s*.*)\z/)
581-
582-
# Rewrite as /, just as jekyll-relative-links does
583-
current_link.attr["href"] = match.captures[0] + "/" + match.captures[1]
579+
# If a relative link
580+
if !current_link.attr["href"].start_with?("https://", "http://")
581+
582+
# If link ends with .md
583+
if match = current_link.attr["href"].match(/\A([^\s]*)\.md(\s*.*)\z/)
584+
585+
# Rewrite as /, just as jekyll-relative-links does
586+
current_link.attr["href"] = match.captures[0] + "/" + match.captures[1]
587+
end
584588
end
585589
end
586590
end

0 commit comments

Comments
 (0)