diff options
author | Marcia Ramos <virtua.creative@gmail.com> | 2018-12-07 21:20:11 +0300 |
---|---|---|
committer | Marcia Ramos <virtua.creative@gmail.com> | 2018-12-07 21:20:11 +0300 |
commit | 6e294d3f197fc9cb743894c53cfcf3300ae34f41 (patch) | |
tree | 328ad6a3505defd2628652c811abaa833a0b1bfa /Rules | |
parent | d5b7c6d9e72335c55f5fa32df9bde937d42e2bef (diff) |
Revert "Merge branch 'redirect-check-md' into 'master'"
This reverts merge request !380
Diffstat (limited to 'Rules')
-rw-r--r-- | Rules | 18 |
1 files changed, 8 insertions, 10 deletions
@@ -7,21 +7,19 @@ preprocess do @items.each do |item| if item.identifier.to_s.end_with?(".md") && !item.binary? - # Check if there is a 'redirect_to' defined in the yaml frontmatter. - if item[:redirect_to] - # If the provided URL is in Markdown, correct it to HTML. - if item[:redirect_to].to_s.match(/.md$/) - item[:redirect_to] = item[:redirect_to].gsub!(/\.md/, '.html') - end # If there isn't already a 'redirect_to' defined in the yaml frontmatter, # use the text to assume the redirect URL. - else - # If the pattern 'This document was moved to [here](link)' is found. + unless item[:redirect_to] if item.raw_content =~ /^This document was moved to \[.*\]\(.*\)/m # Capture the intended page so the redirect page can redirect to it. item[:redirect_to] = item.raw_content.match(/^This document was moved to \[.*\]\((.*)\)/m)[1] - # If the provided URL is in Markdown, correct it to HTML. - item[:redirect_to] = item[:redirect_to].gsub!(/\.md/, '.html') if item[:redirect_to].to_s.match(/.md/) + # Correct the URL. + item[:redirect_to] = item[:redirect_to].gsub!(/\.md/, '.html') + end + else + # If the provided relative URL is in Markdown, correct it to HTML. + unless item[:redirect_to].to_s.match(/.html$/) + item[:redirect_to] = item[:redirect_to].gsub!(/\.md/, '.html') end end |