From 5ab8e9afabfdc49fe92f85a106188af45060fdc3 Mon Sep 17 00:00:00 2001 From: Oleksandr Shybystyi Date: Fri, 22 May 2015 12:45:24 +0300 Subject: [PATCH] Added support for github flavoured markdown --- README.md | 12 ++++++++++-- plugin/vim-markdown-preview.vim | 8 +++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2834132..5da6ccd 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ Installation * `let vim_markdown_preview_toggle=2` * To disregard images and still automatically preview on buffer write, add: * `let vim_markdown_preview_toggle=3` +5. If you prefer github flavoured markdown you need to install grip (tested only on ubuntu) and set next option: + * `let vim_markdown_preview_github=1` The following example is using the write buffer option on OS X, with displaying images in the markdown preview, adding the following to `.vimrc`: @@ -46,9 +48,9 @@ Support and Requirements ## Unix: -* [Markdown](http://daringfireball.net/projects/markdown/) +* [Markdown](http://daringfireball.net/projects/markdown/) or [grip](https://github.com/joeyespo/grip) if you want to parse github flavoured markdown * [xdotool](https://github.com/jordansissel/xdotool) -* [Google Chrome](https://www.google.com/chrome/browser/) +* [Google Chrome](https://www.google.com/chrome/browser/) or [other browser](https://github.com/JamshedVesuna/vim-markdown-preview/wiki/Use-other-browser-to-preview-markdown#ubuntu-or-debian) Usage ===== @@ -70,3 +72,9 @@ Behind The Scenes 1. First, vim-markdown-preview renders your markdown as html with the filename `.md.html` in the same directory. 2. Next, vim-markdown-preview either opens the html file or refreshes the Google Chrome or Safari tab. 3. There is currently no option to remove this file after previewing. + +Know issues +=========== +* If you've chosen to use github flavoured markdown (with grip), there might some issues: + * necessity to use [access token](https://github.com/joeyespo/grip#access) (a solution is to set `alias grip="grip --user --pass ` in your ***.bashrc/.zshrc***). + * if github is unresponsive you wont be able to render your file. diff --git a/plugin/vim-markdown-preview.vim b/plugin/vim-markdown-preview.vim index 30da259..211f2f0 100644 --- a/plugin/vim-markdown-preview.vim +++ b/plugin/vim-markdown-preview.vim @@ -6,6 +6,7 @@ let b:vim_markdown_preview_browser = get(g:, 'vim_markdown_preview_browser', 'Google Chrome') let b:vim_markdown_preview_temp_file = get(g:, 'vim_markdown_preview_temp_file', 0) let b:vim_markdown_preview_toggle = get(g:, 'vim_markdown_preview_toggle', 0) +let b:vim_markdown_preview_github = get(g:, 'vim_markdown_preview_github', 0) function! Vim_Markdown_Preview() @@ -23,7 +24,12 @@ function! Vim_Markdown_Preview() endif let curr_file = expand('%:p') - call system('markdown ' . curr_file . ' > /tmp/vim-markdown-preview.html') + + if b:vim_markdown_preview_github == 1 + call system('grip ' . curr_file . ' --export /tmp/vim-markdown-preview.html') + else + call system('markdown ' . curr_file . ' > /tmp/vim-markdown-preview.html') + endif if OSNAME == 'unix' let chrome_wid = system("xdotool search --name 'vim-markdown-preview.html - " . b:vim_markdown_preview_browser . "'") -- 2.45.2