Skip to content

Instantly share code, notes, and snippets.

@antonj
Created August 28, 2013 10:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antonj/6364719 to your computer and use it in GitHub Desktop.
Save antonj/6364719 to your computer and use it in GitHub Desktop.
source 'https://rubygems.org'
group :development do
gem 'guard-shell'
gem 'guard-sass'
gem 'guard-livereload'
gem 'coderay'
gem 'kramdown'
end
# 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