Created
September 29, 2015 17:37
-
-
Save BBonifield/32d6b1f1c51c1a35fa74 to your computer and use it in GitHub Desktop.
Github flavored markdown template for compiled kramdown markdown
This file contains hidden or 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>Rendered Markdown</title> | |
<link rel="stylesheet" href="http://yandex.st/highlightjs/6.1/styles/default.min.css"/> | |
<link rel="stylesheet" href="http://sindresorhus.com/github-markdown-css/github-markdown.css"/> | |
</head> | |
<body> | |
<div class="markdown-body"> | |
<%= body %> | |
</div> | |
<script type="text/javascript" src="http://yandex.st/highlightjs/6.1/highlight.min.js"></script> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> | |
<script type="text/javascript"> | |
var hilight_hljs = function(){ | |
$('pre code').each(function(i, e){hljs.highlightBlock(e, ' ');}); | |
}; | |
var hilight_copy = function(){ | |
$('.insert').each(function(index, element){ | |
var e = $(element); | |
e.html($(e.html() + ' pre').parent().html()); | |
}); | |
}; | |
$(function(){ | |
hilight_hljs(); | |
hilight_copy(); | |
}); | |
</script> | |
</body> | |
</html> |
YUSSSSS
Works like a charm.
Here's a version of that vim command broken out into a function:
function! g:RenderMarkdown(template_path)
let rubyscript = '
\ require "rubygems";
\ require "kramdown";
\ require "erb";
\ body = Kramdown::Document.new(STDIN.read.chomp, input: "GFM", hard_wrap: false).to_html;
\ print ERB.new(File.read("' . a:template_path . '/.vim/support/kramdown.html.erb")).result(binding)'
execute "w !ruby -e '" . rubyscript . "' > /tmp/mdresult.html; open /tmp/mdresult.html"
endfunction
map <silent> <Leader>md :call g:RenderMarkdown($HOME)<CR>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Place this file at:
~/.vim-support/kramdown.html.erb
Add this to your
.vimrc
: