diff options
author | Connor Shea <connor.james.shea@gmail.com> | 2016-11-10 02:00:26 +0300 |
---|---|---|
committer | Connor Shea <connor.james.shea@gmail.com> | 2016-11-10 02:00:26 +0300 |
commit | 810ddc9fcdab13f31e3783dc8e789f95fd559d0a (patch) | |
tree | 7e4db10eee83a13e1c90acad75ab6bcd67ccdebb /Rules | |
parent | 8e56bab9577d1e0b13f83ff0527b5b579b12fdca (diff) |
Remove rescue statement. It's unnecessary now.
Diffstat (limited to 'Rules')
-rw-r--r-- | Rules | 26 |
1 files changed, 10 insertions, 16 deletions
@@ -3,23 +3,17 @@ preprocess do @items.each do |item| if item.identifier.to_s.end_with?(".md") && !item.binary? - begin - # If the page is a redirect, make it a redirect. - if item.raw_content =~ /^This document was moved to \[.*\]\(.*\)/m - # Capture the intended page so the redirect page can redirect to it. - item[:redirect] = item.raw_content.match(/^This document was moved to \[.*\]\((.*)\)/m)[1] - # Correct the URL. - item[:redirect] = item[:redirect].gsub!(/\.md/, '.html') - end - - title = item.raw_content.match(/^[#] .*$/).to_s - title.gsub!('# ', '') - item[:title] = title unless title.empty? - # Encoding errors happen on some files for some reason, so we - # rescue them. - rescue Encoding::CompatibilityError - puts "(warning) Encoding error: #{item.identifier}" + # If the page is a redirect, make it a redirect. + if item.raw_content =~ /^This document was moved to \[.*\]\(.*\)/m + # Capture the intended page so the redirect page can redirect to it. + item[:redirect] = item.raw_content.match(/^This document was moved to \[.*\]\((.*)\)/m)[1] + # Correct the URL. + item[:redirect] = item[:redirect].gsub!(/\.md/, '.html') end + + title = item.raw_content.match(/^[#] .*$/).to_s + title.gsub!('# ', '') + item[:title] = title unless title.empty? end end end |