Skip to content

Instantly share code, notes, and snippets.

@kachick
Created May 22, 2012 03:52
Show Gist options
  • Select an option

  • Save kachick/2766455 to your computer and use it in GitHub Desktop.

Select an option

Save kachick/2766455 to your computer and use it in GitHub Desktop.
Simple Markdown Converter
$VERBOSE = true
require 'kramdown'
HTML_HEADER = '<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="markdown.css" rel="stylesheet"></link>
</head>'.freeze
abort 'usage: this.rb doc1.md [doc2.md ...docN.md]' unless ARGV.length >= 1
ARGV.each do |path|
open "#{path}.html", 'w:UTF-8' do |html|
html.puts HTML_HEADER
html << Kramdown::Document.new(File.read path).to_html
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment