forked from bgrins/devtools-snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
39 lines (28 loc) · 857 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require 'nokogiri'
# <div class="snippet" data-src="snippets/jquerify.js"></div>
task :deploy do
system "git checkout gh-pages"
system "git merge master"
Rake::Task["build"].execute
system "git commit -am 'Deploying to gh-pages'"
system "git status"
system "git push origin gh-pages"
system "git checkout master"
end
task :build do
FileUtils.cd(File.dirname(__FILE__))
replace_snippets('snippets.html', 'index.html')
end
def replace_snippets(infile, outfile)
doc = Nokogiri::HTML( File.read(infile) )
doc.css("div.snippet").each do |div|
cmd = "pygmentize -f html " + div.attr("data-src")
content = `#{cmd}`
div.inner_html = content
end
renderedhtml = doc.to_html()
File.open(outfile, "w") do |io|
io.write renderedhtml
end
end
task :default => [:build]