Skip to content

Solve problems related with Windows paths (\) and double quotes #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions autoload/rmarkdown/command.vim
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ endfunction

function! s:MapExt(ot)
let ot = tolower(a:ot)
if ot == "" || ot == "html" || ot == "md" || ot == "pdf"
if ot == ""
let ext = "html"
elseif ot == "html" || ot == "md" || ot == "pdf"
let ext = ot
elseif ot == "word"
let ext = "docx"
Expand All @@ -42,11 +44,13 @@ function! s:MapExt(ot)
endfunction

function! rmarkdown#command#Command(bang, args)
let @9 = @+
let @+ = expand("%:p")
let args_data = split(a:args, " ", 1)
try
let output_type = s:MapOT(args_data[0])
if type(output_type) == type("")
let output_type_arg = '\"' . output_type . '\"'
let output_type_arg = "'" . output_type . "'"
elseif type(output_type) == type([])
let output_types = map(output_type, '"\\\"".v:val."\\\""')
let output_type_arg = 'c(' . join(output_types, ",").')'
Expand Down Expand Up @@ -85,13 +89,13 @@ function! rmarkdown#command#Command(bang, args)
endif

if output_type == "revealjs_presentation"
let invocation = 'Rscript -e "library(rmarkdown);library(revealjs);render(\"'.
\ expand("%:p") . '\", '.
let invocation = 'Rscript -e "library(rmarkdown);library(revealjs);render('.
\ 'readClipboard(), '.
\ 'revealjs_presentation()' .
\ render_opts.')"'
else
let invocation = 'Rscript -e "library(rmarkdown);render(\"'.
\ expand("%:p") . '\", '.
let invocation = 'Rscript -e "library(rmarkdown);render('.
\ 'readClipboard(), '.
\ output_type_arg .
\ render_opts.')"'
endif
Expand All @@ -118,6 +122,7 @@ function! rmarkdown#command#Command(bang, args)
call s:RmarkdownSuccess(a:bang == "!")
endif
endif
let @+ = @9
endfunction

function! rmarkdown#command#Callback(open)
Expand Down Expand Up @@ -148,7 +153,13 @@ endfunction

function! rmarkdown#command#OpenFile(open)
if a:open == 1
call system('xdg-open '. s:output_file)
echo "Opening " . s:output_file
if has('win32')
call system(s:output_file)
return
else
call system('xdg-open '. s:output_file)
endif
endif
endfunction

Expand Down