#!/usr/bin/env ruby # -*- coding: utf-8 -*- require 'erb' require 'date' load 'pandoc.rb' Pandoc::prog='pandoc' def erb(file, context=nil) _erb = ERB.new(File.read(file)) _erb.filename = file if context.nil? return _erb.result() else return _erb.result(context) end end template = 'lib/template.erb' infile = ARGV.first input = File.read(infile) @title = 'TITLE GOES HERE' case File.extname(infile) when '.md' doc = Pandoc::load('markdown', input) @title = doc['title'] || input.split("\n",2).first @body = doc.to('html5') when '.org' doc = Pandoc::load('org', input) @title = doc['title'] || input.split("\n",2).first @body = doc.to('html5') when '.erb' erb_body = ERB.new(input) erb_body.filename = infile @body = erb_body.result() else abort end @footer = Pandoc::load('markdown', File.read('lib/footer.md')).to('html5') erb = ERB.new(File.read(template)); erb.filename = template erb.run()