From: Stefan Huber <shuber@sthu.org>
Date: Sat, 29 Dec 2018 13:14:28 +0000 (+0100)
Subject: markdown: Use python markdown implementations
X-Git-Url: https://git.sthu.org/?a=commitdiff_plain;h=5c61509b1a17b26699b378136e93f3e9c99207ae;p=vimconf.git

markdown: Use python markdown implementations

Support python markdown implementations when converting to html.
---

diff --git a/keymaps.vim b/keymaps.vim
index 7f04452..1ad0f13 100644
--- a/keymaps.vim
+++ b/keymaps.vim
@@ -21,7 +21,7 @@ au Filetype c,cpp,objc map <buffer> <F11> :vsplit<CR>:FSRight<CR>
 au Filetype c,cpp,objc map <buffer> <S-F11> :FSHere<CR>
 au BufNewFile *.{h,hpp,hxx} call AddIncludeGuards()
 
-au Filetype markdown map <buffer> <F5> :call RunPandoc()<CR>
+au Filetype markdown map <buffer> <F5> :call RunMarkdown()<CR>
 
 " Start interactive EasyAlign in visual mode (e.g. vipga)
 vmap <Enter> <Plug>(EasyAlign)
diff --git a/macros.vim b/macros.vim
index dd0b28d..73ce128 100644
--- a/macros.vim
+++ b/macros.vim
@@ -96,6 +96,22 @@ function RunPandoc()
   execute ":!pandoc " . cssopts . " --self-contained --toc " . @% . " -o " . @% . ".html"
 endfunction
 
+function RunMarkdownpy(prog)
+  execute ":!" . a:prog . " " . @% . " > " . @% . ".html"
+endfunction
+
+function RunMarkdown()
+  if executable("pandoc")
+    call RunPandoc()
+  elseif executable("markdown2")
+    call RunMarkdownpy("markdown2")
+  elseif executable("markdown_py")
+    call RunMarkdownpy("markdown_py")
+  else
+    echo "No markdown implementation found."
+  endif
+endfunction
+
 
 if filereadable($HOME . '/.vim/macros-local.vim')
   source ~/.vim/macros-local.vim