Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add :ilinks task to display broken internal links.

  • Loading branch information...
commit 5871e9e22cbaaf38b50a1f03e1ed4e4d1e7249bf 1 parent bb86bfe
@runpaint authored
Showing with 18 additions and 0 deletions.
  1. +18 −0 Rakefile
View
18 Rakefile
@@ -13,3 +13,21 @@ end
task :pdf => ['output/vim-recipes.pdf'] do
end
+
+task :ilinks => ['output/all.html'] do |t|
+ require 'hpricot'
+ target = {}
+ source = {}
+ FileList['text/**/*.html'].each do |file|
+ doc = Hpricot(File.open(file, 'r'))
+ doc.search("a[@href*='#']").each do |a|
+ source[a['href'][/[^#]+/]] = file
+ end
+ doc.search("*[@id]").each do |e|
+ target[e['id']] = 1
+ end
+ end
+ source.keys.each do |s|
+ $stderr.puts "Link #{s} from #{source[s]} is broken" unless target.key? s
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.