if !exists('g:VMPoutputformat') let g:VMPoutputformat = 'html' endif if !exists('g:VMPoutputdirectory') let g:VMPoutputdirectory = '/tmp' endif if !exists('g:VMPhtmlreader') if has('mac') let g:VMPhtmlreader = 'open' elseif has('win32') || has('win64') let g:VMPhtmlreader = 'start' elseif has('unix') && executable('xdg-open') let g:VMPhtmlreader = 'xdg-open' else let g:VMPhtmlreader = '' end endif if !exists('g:VMPstylesheet') let g:VMPstylesheet = 'github.css' endif function! PreviewMKD() ruby << RUBY runtime = Vim.evaluate('&runtimepath').split(',') runtime.each { |path| $LOAD_PATH.unshift(File.join(path, 'plugin', 'vim-markdown-preview')) } css_base = runtime.detect { |path| File.exists? File.join(path, 'plugin', 'vmp.vim') } stylesheet = File.join(css_base, 'plugin', 'vim-markdown-preview', 'stylesheets', Vim.evaluate('g:VMPstylesheet')) name = Vim::Buffer.current.name.nil? ? 'Untitled' : File.basename(Vim::Buffer.current.name) output_dir = Vim.evaluate('g:VMPoutputdirectory') contents = Array.new(VIM::Buffer.current.count) { |i| VIM::Buffer.current[i + 1] }.join("\n") require('kramdown/kramdown') layout = <<-LAYOUT