Created
March 23, 2010 21:40
-
-
Save markburns/341704 to your computer and use it in GitHub Desktop.
Adapted script to preview markdown in a browser
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
#!/usr/bin/env ruby | |
#Adapted from http://pragmatig.wordpress.com/2009/06/17/quick-markdown-preview-for-github-readme/ | |
#Added --firefox or -f parameter so that it won't open firefox each time, and you can just hit refresh instead. | |
raise "Usage:\nmarkdown <filename> [-f|--firefox]" unless ARGV[0] | |
require 'rubygems' | |
#e.g. rdiscount, gem install rdiscount (or any other bluecloth flavour...) | |
require 'markdown' | |
text = Markdown.new(File.read(ARGV[0])).to_html | |
File.open('/tmp/markdown.html','w'){|f| f.puts text} | |
if ARGV[1] == "--firefox" or ARGV[1]=="-f" | |
exec "firefox /tmp/markdown.html" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment