• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision81a17217b749fc4f3f66a462922427bfe442ec89 (tree)
Time2023-04-26 18:30:02
Authorbadcoff33 <none@none>
Commiterbadcoff33

Log Message

avoid error message in case no file exists

Change Summary

Incremental Difference

--- a/after/ftplugin/markdown_preview.vim
+++ b/after/ftplugin/markdown_preview.vim
@@ -14,21 +14,26 @@ else
1414 let b:markdown_template_file = " --template=" .. b:markdown_template_file
1515 endif
1616
17-let b:markdown_command = "pandoc -f gfm -t html5 --toc --toc-depth=3"
18- \ .. b:markdown_css_file
19- \ .. b:markdown_template_file
20- \ .." --metadata title=\""..expand("%:t:r").."\""
21- \ .." -o "..getenv("TEMP")..g:slash..expand("%:t")..".html"
22- \ .." "..getenv("TEMP")..g:slash.."_"..expand("%:t")
2317
2418 function! s:OpenHTML()
25- exe "terminal ++close ++hidden cmd /C start" getenv("TEMP")..g:slash..expand("%:t")..".html"
19+ exe "terminal ++close ++hidden cmd /C start" getenv("TEMP") .. g:slash .. expand("%:t") .. ".html"
20+endfunction
21+
22+function! s:ComputeCommand(file)
23+ return "pandoc -f gfm -t html5 --toc --toc-depth=3"
24+ \ .. b:markdown_css_file
25+ \ .. b:markdown_template_file
26+ \ .. " --metadata title=\"" .. expand("%:t:r") .. "\""
27+ \ .. " -o " .. getenv("TEMP") .. g:slash .. expand("%:t") .. ".html"
28+ \ .. " " .. getenv("TEMP") .. g:slash.."_" .. expand("%:t")
2629 endfunction
2730
2831 function! s:MakeHTML(...)
29- if exists("b:markdown_command")
30- silent exe "write!" getenv("TEMP")..g:slash.."_"..expand("%:t")
31- silent exe "bwipeout!" getenv("TEMP")..g:slash.."_"..expand("%:t")
32+ if filereadable(expand("%"))
33+ let b:markdown_command = s:ComputeCommand(expand("%"))
34+ let b:markdown_temp_file = getenv("TEMP") .. g:slash .. "_" .. expand("%:t")
35+ silent exe "write!" b:markdown_temp_file
36+ silent exe "bwipeout!" b:markdown_temp_file
3237 call run#RunStart(#{
3338 \ cmd: b:markdown_command,
3439 \ background: v:true,
--- a/after/ftplugin/rst_preview.vim
+++ b/after/ftplugin/rst_preview.vim
@@ -16,26 +16,30 @@ else
1616 let b:rst_template_file = " --template=" .. b:rst_template_file
1717 endif
1818
19-let b:rst_command = "pandoc -f rst -t html5 --toc --toc-depth=3"
20- \ .. b:rst_css_file
21- \ .. b:rst_template_file
22- \ .." --metadata title=\""..expand("%:t:r").."\""
23- \ .." -o "..getenv("TEMP")..g:slash..expand("%:t")..".html"
24- \ .." "..getenv("TEMP")..g:slash.."_"..expand("%:t")
25-
2619 function! s:OpenHTML()
2720 exe "terminal ++close ++hidden cmd /C start" getenv("TEMP")..g:slash..expand("%:t")..".html"
2821 endfunction
2922
23+function! s:ComputeCommand(file)
24+ return "pandoc -f rst -t html5 --toc --toc-depth=3"
25+ \ .. b:rst_css_file
26+ \ .. b:rst_template_file
27+ \ .. " --metadata title=\"" .. expand("%:t:r") .. "\""
28+ \ .. " -o " .. getenv("TEMP") .. g:slash .. expand("%:t") .. ".html"
29+ \ .. " " .. getenv("TEMP") .. g:slash .. "_" .. expand("%:t")
30+endfunction
31+
3032 function! s:MakeHTML(...)
31- if exists("b:rst_command")
32- silent exe "write!" getenv("TEMP")..g:slash.."_"..expand("%:t")
33- silent exe "bwipeout!" getenv("TEMP")..g:slash.."_"..expand("%:t")
33+ if filereadable(expand("%"))
34+ let b:rst_command = s:ComputeCommand(expand("%"))
35+ let b:rst_temp_file = getenv("TEMP") .. g:slash .. "_" .. expand("%:t")
36+ silent exe "write!" b:rst_temp_file
37+ silent exe "bwipeout!" b:rst_temp_file
3438 call run#RunStart(#{
3539 \ cmd: b:rst_command,
3640 \ background: v:true,
3741 \ no_write: v:true
38- })
42+ \ })
3943 endif
4044 endfunction
4145