Created
August 28, 2013 10:45
-
-
Save antonj/6364719 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
group :development do | |
gem 'guard-shell' | |
gem 'guard-sass' | |
gem 'guard-livereload' | |
gem 'coderay' | |
gem 'kramdown' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# More info at https://github.com/guard/guard#readme | |
require 'kramdown' | |
def markd (m) | |
# puts caller | |
puts "Running markd" | |
md_str = Kramdown::Document.new(File.read(m[0]), | |
{ :enable_coderay => true, | |
:coderay_css => :class, | |
:coderay_line_numbers => :table, | |
}).to_html | |
css = File.read("style.css") | |
newFile = File.open("#{m[1]}.html", "w") | |
newFile.write(<<-eos | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<style>#{css}</style> | |
</head> | |
<body><div class="container">#{md_str}</div></body> | |
</html> | |
eos | |
) | |
newFile.close | |
end | |
guard 'sass', :output => '.' do | |
watch(%r{^(.+\.s[ac]ss)$}) | |
end | |
guard 'shell' do | |
watch(/(.*)\.(css)/) { markd ["api.md", "api"] } | |
end | |
guard 'shell' do | |
watch(/(.*).(md)/) { |m| markd m } | |
end | |
guard 'livereload' do | |
watch(%r{\.(html)}) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment