vim-pandoc / vim-pandoc-legacy

[UNSUPPORTED/use vim-pandoc/vim-pandoc] vim bundle for pandoc users
143 stars 23 forks source link

spaces in filenames causes issues #94

Closed opennomad closed 10 years ago

opennomad commented 10 years ago

I've got a lot of markdown files which contain spaces in the filenames. Those don't behave correctly when I use 'html+'.

Here is a patch that seems to make things work by adding quotes around the filename as part of the exec call.

diff --git a/autoload/pandoc_exec.vim b/autoload/pandoc_exec.vim
index 0da5031..6b5d122 100644
--- a/autoload/pandoc_exec.vim
+++ b/autoload/pandoc_exec.vim
@@ -13,12 +13,13 @@ import re, string
 import shlex
 from os.path import exists, relpath, basename, splitext
 from subprocess import call, Popen, PIPE
+import pipes

 pandoc_variable_substitutions = {
    # current file
-   "%%": lambda r: relpath(vim.current.buffer.name),
+   "%%": lambda r: pipes.quote(relpath(vim.current.buffer.name)),
    # current file, w/o extension
-   "%:r": lambda r: splitext(relpath(vim.current.buffer.name))[0],
+   "%:r": lambda r: pipes.quote(splitext(relpath(vim.current.buffer.name))[0]),
    # the values in b:pandoc_bibfiles, as arguments for a pandoc-compatible program
    "PANDOC#P_BIBS" : lambda r: " ".join(["--bibliography "+ i for i in vim.eval('b:pandoc_bibfiles')]),
    # the values in b:pandoc_bibfiles, as a list
fmoralesc commented 10 years ago

I'll add this, but won't use the pipes module, since quoteis deprecated.