Skip to content

Instantly share code, notes, and snippets.

@cdmwebs
Created March 5, 2012 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdmwebs/1980586 to your computer and use it in GitHub Desktop.
Save cdmwebs/1980586 to your computer and use it in GitHub Desktop.
#!/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