Skip to content

Instantly share code, notes, and snippets.

@funkaoshi funkaoshi/md2html.rb
Created Mar 28, 2013

What would you like to do?
A simple script that takes a template, markdown file, and an optional foreword and spits out an HTML file.
#!/usr/bin/env ruby
require 'liquid'
require 'redcarpet'
if ARGV.length < 2
puts "Usage: md2html <template> <markdown_doc> [markdown_foreword]"
template =[0])
document =[1])
preamble =[2]) if ARGV.length > 2
renderer = => true)
markdown =, :autolink => true, :space_after_headers => true, :tables => true)
tocgen =
preamble = markdown.render(preamble) if preamble
contents = markdown.render(document)
toc = tocgen.render(document)
print Liquid::Template.parse(template).render('content' => contents,
'toc' => toc,
'preamble' => preamble,
'title' => "Philotomy's Musings")

This comment has been minimized.

Copy link
Owner Author

commented Mar 28, 2013

This is currently used to generate this page: Philotomy's Musings and a few other simple pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.