Created
January 13, 2012 09:22
-
-
Save joshnesbitt/1605261 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'rubygems' | |
require 'redcarpet' | |
require 'pathname' | |
path = Pathname.new(ARGV.shift) | |
raise "Input path must be absolute." unless path.absolute? | |
raise "Input path must point to a file that exists" unless path.exist? | |
raise "Input path must point to a file that is readable" unless path.readable? | |
output = Pathname.new(path.dirname.join(path.basename.sub(".md", ".html"))) | |
engine = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true) | |
document = engine.render(path.read) | |
output.open("w") { |f| f.write(document) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment