Skip to content
This repository
Newer
Older
100644 45 lines (39 sloc) 1.07 kb
f79cd1f6 »
2009-05-10 Rakefile: Copy images to output/; tweak logic.
1 SOURCE_HTML = FileList['text/**/*.html']
2 IMAGES = FileList['images/*']
dc815dca »
2009-05-10 Rakefile: constantised name of HTML output file.
3 OUTPUT_HTML = 'output/all.html'
4663b0b2 »
2009-05-05 Created Rakefile for generating PDF.
4
f79cd1f6 »
2009-05-10 Rakefile: Copy images to output/; tweak logic.
5 directory "output"
6
7 task :images => :output
8 task :images => IMAGES do |t|
9 IMAGES.each do |image|
10 cp image, "output"
11 end
12 end
13
dc815dca »
2009-05-10 Rakefile: constantised name of HTML output file.
14 task OUTPUT_HTML => [:output, :images]
15 file OUTPUT_HTML => FileList['text/**/*.html'] do |t|
4663b0b2 »
2009-05-05 Created Rakefile for generating PDF.
16 File.open(t.name,'w') do |out|
f79cd1f6 »
2009-05-10 Rakefile: Copy images to output/; tweak logic.
17 SOURCE_HTML.sort.each do |source|
4663b0b2 »
2009-05-05 Created Rakefile for generating PDF.
18 out.puts File.open(source).read
19 end
20 end
21 end
22
dc815dca »
2009-05-10 Rakefile: constantised name of HTML output file.
23 file 'output/vim-recipes.pdf' => OUTPUT_HTML do |t|
4663b0b2 »
2009-05-05 Created Rakefile for generating PDF.
24 system("prince #{t.prerequisites.first} #{t.name}")
25 end
26
f79cd1f6 »
2009-05-10 Rakefile: Copy images to output/; tweak logic.
27 task :pdf => 'output/vim-recipes.pdf'
5871e9e2 »
2009-05-09 Add :ilinks task to display broken internal links.
28
dc815dca »
2009-05-10 Rakefile: constantised name of HTML output file.
29 task :ilinks => OUTPUT_HTML do |t|
5871e9e2 »
2009-05-09 Add :ilinks task to display broken internal links.
30 require 'hpricot'
31 target = {}
32 source = {}
33 FileList['text/**/*.html'].each do |file|
34 doc = Hpricot(File.open(file, 'r'))
35 doc.search("a[@href*='#']").each do |a|
36 source[a['href'][/[^#]+/]] = file
37 end
38 doc.search("*[@id]").each do |e|
39 target[e['id']] = 1
40 end
41 end
42 source.keys.each do |s|
43 $stderr.puts "Link #{s} from #{source[s]} is broken" unless target.key? s
44 end
45 end
Something went wrong with that request. Please try again.