From 99dc186df0ac6a22e79ac2813e7dfe65b8ccd86d Mon Sep 17 00:00:00 2001 From: Rane Brown Date: Thu, 28 Mar 2019 22:56:01 -0600 Subject: [PATCH] Possible fix for #642. When using a custom Wiki2HTML on Windows the normalized paths caused the closing quote to be escaped and not pass the correct arguments to the system call. This fix removes the trailing slash for Windows while leaving the default behavior the same. --- autoload/vimwiki/html.vim | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim index 1bc66f8..beb294f 100644 --- a/autoload/vimwiki/html.vim +++ b/autoload/vimwiki/html.vim @@ -1418,24 +1418,38 @@ function! s:use_custom_wiki2html() \ (s:file_exists(custom_wiki2html) || s:binary_exists(custom_wiki2html)) endfunction - function! vimwiki#html#CustomWiki2HTML(path, wikifile, force) call vimwiki#path#mkdir(a:path) + + " fix for trailing / causing " to be escaped on windows, see #642 + if has('win16') || has('win95') || has('win32') || has('win64') + let l:path = substitute(a:path, '\\$', '', '') + let l:css = substitute(shellescape(s:default_CSS_full_name(a:path)), '\\$', '', '') + " template path ends in / even on windows hence the different substitute + let l:tmpl = shellescape(expand(substitute(vimwiki#vars#get_wikilocal('template_path'), '/$', '', ''))) + let l:rpath = substitute(shellescape(s:root_path(vimwiki#vars#get_bufferlocal('subdir'))), '\\$', '', '') + else + let l:path = a:path + let l:css = shellescape(s:default_CSS_full_name(a:path)) + let l:tmpl = shellescape(expand(vimwiki#vars#get_wikilocal('template_path'))) + let l:rpath = shellescape(s:root_path(vimwiki#vars#get_bufferlocal('subdir'))) + endif + echomsg system(vimwiki#vars#get_wikilocal('custom_wiki2html'). ' '. \ a:force. ' '. \ vimwiki#vars#get_wikilocal('syntax'). ' '. \ strpart(vimwiki#vars#get_wikilocal('ext'), 1). ' '. - \ shellescape(a:path). ' '. + \ shellescape(l:path). ' '. \ shellescape(a:wikifile). ' '. - \ shellescape(s:default_CSS_full_name(a:path)). ' '. + \ l:css . ' '. \ (len(vimwiki#vars#get_wikilocal('template_path')) > 1 ? - \ shellescape(expand(vimwiki#vars#get_wikilocal('template_path'))) : '-'). ' '. + \ l:tmpl : '-'). ' '. \ (len(vimwiki#vars#get_wikilocal('template_default')) > 0 ? \ vimwiki#vars#get_wikilocal('template_default') : '-'). ' '. \ (len(vimwiki#vars#get_wikilocal('template_ext')) > 0 ? \ vimwiki#vars#get_wikilocal('template_ext') : '-'). ' '. \ (len(vimwiki#vars#get_bufferlocal('subdir')) > 0 ? - \ shellescape(s:root_path(vimwiki#vars#get_bufferlocal('subdir'))) : '-'). ' '. + \ l:rpath : '-'). ' '. \ (len(vimwiki#vars#get_wikilocal('custom_wiki2html_args')) > 0 ? \ vimwiki#vars#get_wikilocal('custom_wiki2html_args') : '-')) endfunction