markdown: Add pandoc generation keymap
authorStefan Huber <shuber@sthu.org>
Tue, 11 Dec 2018 12:28:33 +0000 (13:28 +0100)
committerStefan Huber <stefan.huber@br-automation.com>
Tue, 11 Dec 2018 12:41:18 +0000 (13:41 +0100)
keymaps.vim
macros.vim

index 39a61b03344b7ab028bc5a505feb9fbf47f685a6..4b273558e2d4e0aa6cdb87e076ff2348cb46f01b 100644 (file)
@@ -22,6 +22,7 @@ au Filetype c,cpp,objc map <buffer> <S-F11> :FSHere<CR>
 au BufNewFile *.{h,hpp,hxx} call AddIncludeGuards()
 
 au Filetype html,xml imap <buffer> <C-_> <C-X>/
+au Filetype markdown map <buffer> <F5> :call RunPandoc()<CR>
 
 " Start interactive EasyAlign in visual mode (e.g. vipga)
 vmap <Enter> <Plug>(EasyAlign)
index 55335b1bdb720543c68e54104181e60fc318a2ba..1397f0f3f580b08d579c5c564cb5cebada048d98 100644 (file)
@@ -86,6 +86,17 @@ function AddIncludeGuards()
 endfunction
 
 
+function RunPandoc()
+  " If pandoc.css exists, use it
+  let cssopts = ""
+  if findfile("pandoc.css", ".") == "pandoc.css"
+    let cssopts = "-c pandoc.css --self-contained"
+  endif
+
+  execute ":!pandoc " . cssopts . " --toc " . @% . " -o " . @% . ".html"
+endfunction
+
+
 if filereadable($HOME . '/.vim/macros-local.vim')
   source ~/.vim/macros-local.vim
 endif