#!/usr/bin/env ruby # -*- coding: utf-8 -*- require 'rdiscount' require 'erb' license_urls = { "CC BY-SA-3.0" => 'https://creativecommons.org/licenses/by-sa/3.0/', 'WTFPL-2' => "http://www.wtfpl.net/txt/copying/", } template = 'template.erb' input = ARGV.first lines = File.read(input).split("\n") markdown = '' tags = {} for line in lines do if (line =~ /^:/) (key, val) = line.sub(/^:/, '').split(/\s+/, 2) tags[key] = val else markdown += "\n"+line end end @title = tags['title'] || lines.first @copyright = tags['copyright'] || "Luke Shumaker" @license = tags['license'] || "CC BY-SA-3.0" unless license_urls[@license].nil? @license="#{@license}" end @content = RDiscount.new(markdown).to_html erb = ERB.new(File.read(template)); erb.filename = template erb.run()