-- pdfviewer + pdfview
local pdfviewer = 'qpdfview'

vis:command_register('ppdf', function(argv, force, win, selection, range)
	local pandocoptions = '-V fontsize:12pt -V geometry:margin=3cm'

	-- TODO:
	-- evaluate whether custom args are needed, cuz it would require something
	-- more complex than this
	--if argv[1] then
		--pandocoptions = argv[1]
	--end

	local ppdfresult, ppdfstdout = vis:pipe(
		win.file,
		{ start = 0, finish = 0 },
		'pandoc '..win.file.path..' '..pandocoptions..' -o '..win.file.path..'.pdf'..' && '..pdfviewer..' '..win.file.path..'.pdf'
	)

	end, 'Converts current file (.md) into a pdf and views it using '..pdfviewer
)