Comments (1)
Patch using Python to provide EXITCODE
, CMD
, STDOUT
, and STDERR
:
diff --git a/plugin/vim-markdown-preview.vim b/plugin/vim-markdown-preview.vim
index 082c69f..10f41d1 100644
--- a/plugin/vim-markdown-preview.vim
+++ b/plugin/vim-markdown-preview.vim
@@ -58,20 +58,42 @@ if !exists("g:vim_markdown_preview_hotkey")
let g:vim_markdown_preview_hotkey='<C-p>'
endif
+function! s:PyPopen(cmd)
+ let l:pinfo = { 'exitcode': 2, 'stdout': '', 'stderr': 'default err:' }
+py3 << EOPY
+import vim, subprocess
+cmd = vim.eval("a:cmd")
+pinfo = vim.eval("l:pinfo")
+proc = subprocess.Popen([cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True, shell=True)
+exit_code = str(proc.wait()).replace("'", "'")
+stdout = proc.stdout.read().decode().replace("'", "'")
+stderr = proc.stderr.read().decode().replace("'", "'")
+vim.command(f"let pinfo.exitcode = '{exit_code}'")
+vim.command(f"let pinfo.stdout = '{stdout}'")
+vim.command(f"let pinfo.stderr = '{stderr}'")
+EOPY
+ return l:pinfo
+endfunction
+
function! Vim_Markdown_Preview()
let b:curr_file = expand('%:p')
-
+ let l:cmd = ''
if g:vim_markdown_preview_github == 1
- call system('grip "' . b:curr_file . '" --export /tmp/vim-markdown-preview.html --title vim-markdown-preview.html')
+ let l:cmd = 'grip "' . b:curr_file . '" --export /tmp/vim-markdown-preview.html --title vim-markdown-preview.html'
elseif g:vim_markdown_preview_perl == 1
- call system('Markdown.pl "' . b:curr_file . '" > /tmp/vim-markdown-preview.html')
+ let l:cmd = 'Markdown.pl "' . b:curr_file . '" > /tmp/vim-markdown-preview.html'
elseif g:vim_markdown_preview_pandoc == 1
- call system('pandoc --standalone "' . b:curr_file . '" > /tmp/vim-markdown-preview.html')
+
+ let l:cmd = 'pandoc --standalone "' . b:curr_file . '" > /tmp/vim-markdown-preview.html'
else
- call system('markdown "' . b:curr_file . '" > /tmp/vim-markdown-preview.html')
+ let l:cmd = 'markdown "' . b:curr_file . '" > /tmp/vim-markdown-preview.html'
endif
- if v:shell_error
- echo 'Please install the necessary requirements: https://github.com/JamshedVesuna/vim-markdown-preview#requirements'
+ let l:pinfo = s:PyPopen(l:cmd)
+ if l:pinfo.exitcode != 0
+ echo 'Please install check necessary requirements: https://github.com/JamshedVesuna/vim-markdown-preview#requirements'
+ echo 'EXITCODE,CMD: '.l:pinfo.exitcode.','.l:cmd
+ echo 'STDOUT: '.l:pinfo.stdout
+ echo 'STDERR: '.l:pinfo.stderr
endif
if g:vmp_osname == 'unix'
After applying the patch, if PyPopen
fails within Vim_Markdown_Preview
the output looks like so
Please install check necessary requirements: https://github.com/JamshedVesuna/vim-markdown-preview#require
ments
EXITCODE,CMD: 127,pandoc --standalone "/home/archie/README.md" > /tmp/vim-markdown-preview.html
STDOUT:
STDERR: pandoc: error while loading shared libraries: libHSQuickCheck-2.13.2-F1caelbelL24B6NyiafVp6-ghc8.8
.1.so: cannot open shared object file: No such file or directory
from vim-markdown-preview.
Related Issues (20)
- This plugin doesn't support arch HOT 2
- How do I set url?
- Support for Brave Browser HOT 3
- Doesn't work with remote files HOT 2
- Suggestion - Better syntax highlighting in ```code``` ```enhancement```
- executing job failed: Bad CPU type in executable - Mac M1
- html file created
- I get "Internal Server Error" when call Vim_Markdown_Preview() HOT 1
- Allow preview to be displayed in kiosk mode? HOT 2
- 'call Vim_Markdown_Preview()' can't open the chrome automatically HOT 5
- Opens a new tab on every buffer write on Firefox 60.0.1 HOT 7
- adding syntax highlightening?
- Markdown not matching with Github HOT 1
- Change the top title
- CSS 404 not found HOT 1
- Vim_Markdown_Preview_Local error HOT 1
- wrong error if attempting preview if the file is not saved
- How to Install Daring Fireball's Markdown.pl? HOT 2
- Can you make it more clear which `grip` you are referring to in the README
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-markdown-preview.