I use Neovim in a Linux (Arch Linux) environment. I have written a function to help me preview my markdown documents in PDF format without using a whole plugin. I've also added a simple command named "Prev" to call this function.
Here's the relevant part of my vimrc file :
function! s:pdf_preview() ! pandoc % -s -f markdown -t odt -o ~/.cache/%:t:r.odt > ~/.cache/%:t:r_Prev_log.txt 2>&1 ! soffice --headless --convert-to pdf --outdir ~/.cache ~/.cache/%:t:r.odt >> ~/.cache/%:t:r_Prev_log.txt 2>&1 ! zathura ~/.cache/%:t:r.pdf >> ~/.cache/%:t:r_Prev_log.txt 2>&1 endfunction command Prev call s:pdf_preview()
Note : I'm using
soffice to convert from odt to pdf to avoid installing a LaTeX processor (which I think would be required by pandoc for a direct conversion from markdown to pdf).
I'd like to improve this function in two ways :
- save the current file in the .cache folder before the "! pandoc" command, so that I can use this temporary file for the preview instead of having to save my document each time ;
- delete the temporary files (the odt and the pdf files) once the preview with zathura is closed.
Thanx for any help !