Permalink
Browse files

Add :ilinks task to display broken internal links.

  • Loading branch information...
1 parent bb86bfe commit 5871e9e22cbaaf38b50a1f03e1ed4e4d1e7249bf @runpaint committed May 9, 2009
Showing with 18 additions and 0 deletions.
  1. +18 −0 Rakefile
View
@@ -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

0 comments on commit 5871e9e

Please sign in to comment.