Skip to content

Instantly share code, notes, and snippets.

@alanshaw
Created May 30, 2012 14:18
Show Gist options
  • Save alanshaw/2836615 to your computer and use it in GitHub Desktop.
Save alanshaw/2836615 to your computer and use it in GitHub Desktop.
Github styles markdown nicely, use this tool to make a PDF with those styles
<!doctype html>
<html>
<head>
<title>Github styled markdown to PDF</title>
<link href="https://a248.e.akamai.net/assets.github.com/stylesheets/bundles/github-c7ba6c512453df8f611d2a8568351b86323d2a76.css" media="all" rel="stylesheet" type="text/css" />
<link href="https://a248.e.akamai.net/assets.github.com/stylesheets/bundles/github2-77e5855e2aded4d3c3957eb064a24cea174c93b8.css" media="all" rel="stylesheet" type="text/css" />
<style media="screen">
body {padding: 1em;}
#setup label, #setup textarea {display: block; margin: 0.5em 0;}
#setup textarea {width: 60em; height: 10em;}
#setup ol {margin: 1em 0 1em 1em; list-style-position:inside;}
</style>
</head>
<body>
<div id="setup">
<h1>Github styles markdown nicely, use this tool to make a PDF with those styles</h1>
<ol>
<li>Put your markdown file in git and push it up to your github account</li>
<li>In your browser navigate to your markdown file</li>
<li>Using your favourite DOM inspector, find the &lt;article&gt; element with class &quot;markdown-body&quot;</li>
<li>Copy the HTML from this element, including the &lt;article&gt; element itself</li>
<li>Paste into the box below and hit &quot;Show&quot;</li>
<li>In your browser, select File -&gt; Print and select to Save as PDF.</li>
</ol>
<form action="" method="POST">
<div>
<label for="html">Github hosted markdown file HTML (&lt;article&gt; element with class &quot;markdown-body&quot;):</label>
<textarea id="html" name="html" placeholder="Paste your markdown HTML, including the &lt;article&gt; element with class &quot;markdown-body&quot;"></textarea>
<input type="submit" value="Show"/>
</div>
</form>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
(function($) {
$('form').submit(function(event) {
var html = $('#html').val(), body = $('body');
body.empty();
body.html(html);
$('title').text($('h1').text());
event.preventDefault();
});
})(jQuery);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment