Created
May 30, 2012 14:18
-
-
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
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
<!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 <article> element with class "markdown-body"</li> | |
<li>Copy the HTML from this element, including the <article> element itself</li> | |
<li>Paste into the box below and hit "Show"</li> | |
<li>In your browser, select File -> Print and select to Save as PDF.</li> | |
</ol> | |
<form action="" method="POST"> | |
<div> | |
<label for="html">Github hosted markdown file HTML (<article> element with class "markdown-body"):</label> | |
<textarea id="html" name="html" placeholder="Paste your markdown HTML, including the <article> element with class "markdown-body""></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