Created
February 23, 2017 15:21
-
-
Save scrooloose/a2b834bd19962c8f5c457d374256e9ca 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
"stick this shit in a markdown ftplugin | |
" | |
"Usage: | |
" | |
"Open a markdown file. | |
"Use the :MdLive command. | |
"Save the file and it will update | |
command MdLive call s:InitMarkdownHacks() | |
autocmd bufwritepost <buffer> call s:CheckToBuildMd() | |
"compile current MD file if it is THE ONE we are focused on | |
function! s:CheckToBuildMd() abort | |
if exists("g:markdown_autobuild_buf") && g:markdown_autobuild_buf == bufnr("") | |
call jobstart(system(s:CompileMdCmd())) | |
endif | |
endfunction | |
"select current buffer as THE ONE | |
"kill any open mdlive procs | |
"spawn new mdlive proc for current buf | |
function! s:InitMarkdownHacks() abort | |
let g:markdown_autobuild_buf = bufnr("") | |
"seems dodgy as fuck | |
call system("killall mdlive") | |
call system(s:CompileMdCmd()) | |
call system("mdlive " . expand("%:p:r") . ".html") | |
endfunction | |
function! s:CompileMdCmd() abort | |
return "marked -i " . expand("%:p") . " -o " . expand("%:p:r") . ".html" | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment