Created
March 5, 2012 19:45
-
-
Save cdmwebs/1980586 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env ruby | |
require 'redcarpet' | |
require 'albino' | |
require 'nokogiri' | |
raise "No file specified" if ARGV[0].nil? | |
@content = File.read(ARGV[0]) | |
class HTMLwithAlbino < Redcarpet::Render::HTML | |
end | |
marker = Redcarpet::Markdown.new(HTMLwithAlbino, :fenced_code_blocks => true) | |
@html = marker.render(@content) | |
layout = <<-HTML | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Preview</title> | |
<meta charset="utf-8"> | |
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css" /> | |
<link rel="stylesheet" href="http://yandex.st/highlightjs/6.1/styles/zenburn.min.css" /> | |
<style type="text/css"> | |
body { | |
width: 650px; | |
margin: 2em auto; | |
} | |
pre code.ruby { | |
line-height: 1.45em; | |
} | |
</style> | |
</head> | |
<body> | |
REPLACE_ME | |
<script src="http://yandex.st/highlightjs/6.1/highlight.min.js"></script> | |
<script>hljs.initHighlightingOnLoad();</script> | |
</body> | |
</html> | |
HTML | |
puts layout.gsub(/REPLACE_ME/, @html) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment