Giter VIP home page Giter VIP logo

markdown-preview.vim's Introduction

Introduction

Join the chat at https://gitter.im/iamcco/markdown-preview.vim

中文

Using the markdown-preview.vim plugin, you can preview Markdown in real-time with a web browser.

This plugin needs your Vim to support Python 2 / Python 3 features. Tested on Windows / Ubuntu 14 / Mac OS X.

Note: PLEASE USE markdown-preview.nvim INSTEAD

Screenshots

Markdown preview

screenshot

Typeset math

screenshot

Installation

With vim-plug:

Add Plug 'iamcco/markdown-preview.vim' to the vimrc or init.vim file and type :PlugInstall.

Or with MathJax support for typesetting math:

Plug 'iamcco/mathjax-support-for-mkdp'
Plug 'iamcco/markdown-preview.vim'

Usage

Command:

    MarkdownPreview
    " Open preview window in markdown buffer

    MarkdownPreviewStop
    " Close the preview window and server

When MarkdownPreview command can't open the preview window, you can use the MarkdownPreviewStop command before using MarkdownPreview command.

Default Setting:

    let g:mkdp_path_to_chrome = ""
    " Path to the chrome or the command to open chrome (or other modern browsers).
    " If set, g:mkdp_browserfunc would be ignored.

    let g:mkdp_browserfunc = 'MKDP_browserfunc_default'
    " Callback Vim function to open browser, the only parameter is the url to open.

    let g:mkdp_auto_start = 0
    " Set to 1, Vim will open the preview window on entering the Markdown
    " buffer.

    let g:mkdp_auto_open = 0
    " Set to 1, Vim will automatically open the preview window when you edit a
    " Markdown file.

    let g:mkdp_auto_close = 1
    " Set to 1, Vim will automatically close the current preview window when
    " switching from one Markdown buffer to another.

    let g:mkdp_refresh_slow = 0
    " Set to 1, Vim will just refresh Markdown when saving the buffer or
    " leaving from insert mode. With default 0, it will automatically refresh
    " Markdown as you edit or move the cursor.

    let g:mkdp_command_for_global = 0
    " Set to 1, the MarkdownPreview command can be used for all files,
    " by default it can only be used in Markdown files.

    let g:mkdp_open_to_the_world = 0
    " Set to 1, the preview server will be available to others in your network.
    " By default, the server only listens on localhost (127.0.0.1).

Key Mapping:

By default this plugin has no mapping: if you want to have your own mappings, you can map the keys to <Plug>MarkdownPreview for opening the Markdown preview window and map keys to <Plug>StopMarkdownPreview for closing the preview window.

Examples for mapping the F8 key to open Markdown preview window and F9 key to close preview window:

" for normal mode
nmap <silent> <F8> <Plug>MarkdownPreview
" for insert mode
imap <silent> <F8> <Plug>MarkdownPreview
" for normal mode
nmap <silent> <F9> <Plug>StopMarkdownPreview
" for insert mode
imap <silent> <F9> <Plug>StopMarkdownPreview

For OS X users, you can set the g:mkdp_path_to_chrome as below (if you use Chrome):

let g:mkdp_path_to_chrome = "open -a Google\\ Chrome"
" or
let g:mkdp_path_to_chrome = "/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome"

See issue #1 for details.

FAQ

Q: The Firefox preview window didn't close when leaving the Markdown file in Vim.

A: If you want the plugin to auto-close the preview window in Firefox, you have to do some configuration:

  1. Open Firefox.
  2. Type about:config in the address bar and press the Enter key.
  3. Search for dom.allow_scripts_to_close_windows and set its value to true.

You have to know what will happen when you make the above changes.

Changelog

  • 2017/07/16: Add g:mkdp_open_to_the_world option.
  • 2016/11/19: MathJax support with mathjax-support-for-mkdp plugin.
  • 2016/08/28: Set the title of preview page with filename.
  • 2016/05/18: Support key mapping and new g:mkdp_command_for_global option item.
  • 2016/03/12: New Github-like Markdown styles markdown.css and support task list.
  • 2016/01/24: Support to display the local picture in Markdown.

Buy Me A Coffee ☕️

image

markdown-preview.vim's People

Contributors

bat9r avatar deadbaed avatar eskwayrd avatar gitter-badger avatar haoqixu avatar iamcco avatar jimgreen2013 avatar newbiegreen4ever avatar ptzz avatar sglavoie avatar voldikss avatar zsaberlv0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

markdown-preview.vim's Issues

How to insert a local image?

I try to insert a local image like this:

![image](d:/image/001.jpg)

But the preview page shows nothing about the image.

Could I insert a local image using relative path to the md file like this:

# example.md
![image](image/001.jpg)

Notice that "image" is at the same level with the "example.md". That would make the images management more convenient.

Thanks very much!

不能显示流程图

st=>start: Start
e=>end
op=>operation: My Operation
cond=>condition: Yes or No?

st->op->cond
cond(yes)->e
cond(no)->op

但是并未显示流程图,应该怎么办?

我默认使用 safari,应该如何修改

python v2x支持,输入 command 后没有任何反应。。我猜是因为你的插件默认使用 chrome,我使用 safari
我是直接在.vimrc 里面加了let g:mkdp_path_to_chrome = "/Applications/Safari.app"
但是safari没有反应,是应该在 bundle 里 markdown-preview 里面找文件修改吗?

换行预览bug

在markdown中一个换行符不应该换行,在markdown-preview.vim插件中,测试发现一个换行符在预览时会被渲染成真的换行,这与markdown语法有冲突,具体如下:

eg:
=============下面的内容是markdown正文===============

1.bundle的概念来源于NeXTSTEP,它不是一个文件,而是一个按某种标准结构来组织的目录,其中包含了二进制文件及运行所需的资222
源.正向开发中常见的App和framework都是以bundle的形式存在的;framework也是bundle,但framework的bundle中存放的是一个222
dylib,而不是可执行文件.相对来说,framework的地位比App更高,因为一个App的绝大多数功能都是通过调用framework提供的接口222
来实现的.将某个bundle确立为逆向目标后,绝大多数逆向线索都可以在bundle内找到,这大大降低了逆向工程的复杂度

2.Xcode自带的plutil工具可查看plist文件,命令为plutil -p xxx.plist

=============上面的内容是markdown正文===============

在上面的markdown内容中,用markdown-preview.vim预览时,上面的222的位置会真的换行,实际上在markdown语法中,这里是不会换行的,markdown的换行需要2个空格+换行符,在markdown语法中一个换行符在渲染后只会变成一个空格符,也即真实的markdown渲染成html后应该是下面这个样子:

===========真实效果===========
1.bundle的概念来源于NeXTSTEP,它不是一个文件,而是一个按某种标准结构来组织的目录,其中包含了二进制文件及运行所需的资222 源.正向开发中常见的App和framework都是以bundle的形式存在的;framework也是bundle,但framework的bundle中存放的是一个222 dylib,而不是可执行文件.相对来说,framework的地位比App更高,因为一个App的绝大多数功能都是通过调用framework提供的接口222 来实现的.将某个bundle确立为逆向目标后,绝大多数逆向线索都可以在bundle内找到,这大大降低了逆向工程的复杂度
===========真实效果===========

而预览效果是下面这样的:

===========预览效果===========
1.bundle的概念来源于NeXTSTEP,它不是一个文件,而是一个按某种标准结构来组织的目录,其中包含了二进制文件及运行所需的资222
源.正向开发中常见的App和framework都是以bundle的形式存在的;framework也是bundle,但framework的bundle中存放的是一个222
dylib,而不是可执行文件.相对来说,framework的地位比App更高,因为一个App的绝大多数功能都是通过调用framework提供的接口222
来实现的.将某个bundle确立为逆向目标后,绝大多数逆向线索都可以在bundle内找到,这大大降低了逆向工程的复杂度
===========预览效果===========

在firefox不支持同步滚动

在firefox下不支持同步滚动,而使用chromium-browser可以!
能不能支持firefox下同步滚动?
谢谢!

在Linux下的小bug

在启动预览之后,需要在vim中滚动一下才会显示,如:按一下j

Mac下预览问题

Mac 系统下用safari是页面可以打开 但是会报错 用Google Chrome可以打开也但是整个vim会卡住不动 退出Chrome后 vim会报一个和safari一样的错误:

Error detected while processing function <SNR>104_serverStart[10]..mkdp#browserStart[2]..<SNR>194_browserStart:
line   13:
E488: Trailing characters

Not working NeoVim

Opens to a blank screen with a rectangle at the top. Same issue as with instant-markdown-d

Just wanted to let you know, maybe you can fix it.

不支持mathjax

想请教以下对md文件的解析是在哪个部分完成的?目前似乎不支持mathjax显示数学公式

能否把 s:serverStart() 和 s:serverClose() 变成全局命令?

如果我有个文件的后缀名是 .txt,但内容是 Markdown,我想手动启动 Markdown Preview,但是 s:serverStart()s:serverClose()是不可见的,无法完成 Preview。

如果要想 Preview Markdown 的内容,该文件名必须是 *.{md,mkd,markdown,mdown,mkdn,mdwn}

如果 s:serverStart()s:serverClose() 是个全局命令,用户可以自由地 启动停止 Markdown Preview。

一个样例:

fu! StartMarkdownPreview()
    call s:serverStart()
endfu

fu! StopMarkdownPreview()
    call s:serverClose()
endfu

这样,用户就可以自定义快捷键,如:

nmap <F8> :call StartMarkdownPreview()<cr>
nmap <F9> :call StopMarkdownPreview()<cr>

执行 MarkdownPreview 命令错误

截图

screenshot_20170811_214909

vim配置

Plug 'iamcco/mathjax-support-for-mkdp'
Plug 'iamcco/markdown-preview.vim'


let g:mkdp_path_to_chrome = 'firefox'
nmap <silent> <F7> <Plug>MarkdownPreview
imap <silent> <F7> <Plug>MarkdownPreview

环境

ArchLinux vim 8.0

补充

用了root运行vim还是错误,似乎不是权限问题
用了一个新的vim还是错误,似乎不是其他插件冲突

如何保存生成后的网页?

真的很喜欢这个插件,尤其生成的页面挺不错
我想用这些页面做成wiki
因为一些正则替换在index.js和marked.js里完成的,我目前只能用浏览器的另存为才行
但我有许多经常更新的md文件
我该如何快速获得这些网页

无法进行预览

打开markdown文件后输入
MarkdownPreview后显示这个错误

image

这是我的vim配置文件参数

let g:mkdp_path_to_chrome = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
" 设置 chrome 浏览器的路径(或是启动 chrome(或其他现代浏览器)的命令)

let g:mkdp_auto_start = 0
" 设置为 1 可以在打开 markdown 文件的时候自动打开浏览器预览,只在打开
" markdown 文件的时候打开一次

let g:mkdp_auto_open = 1
" 设置为 1 在编辑 markdown 的时候检查预览窗口是否已经打开,否则自动打开预
" 览窗口

let g:mkdp_auto_close = 1
" 在切换 buffer 的时候自动关闭预览窗口,设置为 0 则在切换 buffer 的时候不
" 自动关闭预览窗口

let g:mkdp_refresh_slow = 0
" 设置为 1 则只有在保存文件,或退出插入模式的时候更新预览,默认为 0,实时
" 更新预览

let g:mkdp_command_for_global = 0
" 设置为 1 则所有文件都可以使用 MarkdownPreview 进行预览,默认只有 markdown
" 文件可以使用改命令

我的chrome浏览器的路径也是正确的
image

Picture Support

Picture which are included via <img src="images/pic.jpg" /> will not be found.

Is it possible to enhance the experience of inserting pictures in gvim?

Hi iamcco! When we copy a picture in the system clipboard and then paste it to gvim, could gvim response differently from terminal vim? That is, could gvim identify that there is a picture in the clipboard, then save the picture to a directory named image at the same directory with the md file, and then insert a ![image](image/md_name_0001.jpg to the md file?
It is real cool if that can come to implementation!

Again, thanks very much for your work!

Pathogen support

Hi your work seems interesting. But I am using pathogen as package manager for vim and I prefer to not use another one.

I have tried but with no success.

Is it possible to make it work with pathogen?

The proxy cause the connection problem

I configure the web borwser proxy to a proxy URL(by default the connection setting is No proxy),but occur a connection problem when start the markdown-preview.

How to solve the problem when I configure the web borwser proxy to a proxy URL?
Thanks in advance!

中文标题的问题

比如

测试

转换成浏览器html会变成

测试

id属性会变成了"-",写跳转的时候就是会出问题了

up主,看到你的截图也是在windows端下面的,我想问问vim如何添加python支持

up主,看到你的截图也是在windows端下面的,我想问问vim如何添加python支持。之前用的Spacevim不能预览Markdown文件,换成了spf13的在Mac下可以预览,但是在windows下,就说要添加Python支持,google一下,都是Mac或者ubuntu的,都没有window下面的,所以在此想问问,up的Vim是如何添加python支持的,希望您有时间,可以指点一下,先谢过了。

我听别人说,在windows下面添加python挺麻烦的,不像在Linux或者mac下之类,但是看到up主做到了

预览时chrome未收到数据

用的windows上64位的vim7.3
有64位python2,已经添加path可以在cmd中输入python直接打开交互解释器了
echo has(“python”)输出1,是支持python的

在使用插件预览的时候能够打开chrome,但是显示

未收到数据

ERR_EMPTY_RESPONSE
服务器未发送任何数据,因此无法加载该网页。

vim中提示server start failed
手动运行python server.py可以在8686看到空白的渲染后的内容(;´д`)ゞ

Possibility of using under WSL (Windows Subsystem for Linux)? | WSL下有可能使用嘛?

Thanks for your working at first.
This is a powerful plugin, but is it possible to run in WSL?
I've tried to set g:mkdp_path_to_chrome to the correct expression in WSL.
Like this in my case:

let g:mkdp_path_to_chrome = '/mnt/c/Program\ Files\ \(x86\)/Google/Chrome/Application/chrome.exe'

After this, the command MarkdownPreview do open a chrome tab, but can't connect correctly.
Is there any solution?


首先感謝大大寫了這個插件
這插件超棒的,但我想請問在WSL下有沒有可能運作?
我試過把 g:mkdp_path_to_chrome 設成在WSL下正確的路徑。
我個人的設定是這樣:

let g:mkdp_path_to_chrome = '/mnt/c/Program\ Files\ \(x86\)/Google/Chrome/Application/chrome.exe'

完成之後, MarkdownPreview 會打開一個chrome分頁,但是無法正確連線。
有任何解決方法嘛?

Proper page title when previewing in Chrome

I set auto_close to false, so I will have multiple preview pages open in Chrome. However all of their titles are the same "Markdown Preview", which confuse me when I want to view a certain page.
Can we make the preview page title identical to the corresponding name of the markdown file?
Thanks very much!

使用Vundle安装之后,完全没有启动

你好!
我是一个Windows平台的用户,今天花了一天时间在网上查询可能在Win平台能够实时预览pandoc's markdown的插件,发现几乎无一另外,全只支持Unix系统,直到发现这款插件。
在使用Vundle安装插件后,发现与没有安装完全一样,无法使用MarkdownPreview,相关命令就没有出现在Commandline的自动补全菜单里。双击启动server.py则一闪而过。请问为何?
感谢开发这款插件,谢谢!

code block language shell

I am not sure if code block language feature is fully supported, but when I did this

```shell
:; cd ~/temp

The syntax highlighting does not look to be right.

Windows下网页无法预览

你好!感谢你发布了这么神奇的插件。在使用插件中出现了无法预览的问题。
显示如下:
image 2
已将Chrome添加进Path环境变量。Windows 10 X64系统,64位Python 2.7,Vim 7.4。
请问应该如何解决?
非常感谢!

又另:
直接运行Python server.py没有反应。

GFM line breaks

Can GFM newlines behavior be supported? That is,

A new
line

will be converted to
A new<br>line

(suggestion) make refresh_slow slow

The difference between mkdp_refresh_slow = 0 or 1 is not so important; I suggest to change in autoload/mkdp.vim the 1 option

if g:mkdp_refresh_slow
    au BufWrite <buffer> call mkdp#markdownRefresh()

or something like this. It would need also (perhaps) a change in the initialization routine. In this way only writing the buffer would refresh the view: an option useful when the html is large and complex (many mathematical formulas, for instance).
Thank you!!

Add a configuration to change the preview page background

Hi, shall we add a configuration to change the background color of the preview page? That is we can set the default background color to a more eyes-friendly one, such as light green, light yellow or the color of the parchment?
Thanks very much!

Install with Vundle

Can this plugin be installed with Vundle? I tried, but it didn't seem to work..

无法打开预览

设置好浏览器chrome后运行成功浏览器无法显示。
启动好像不太稳定,老是失败,弹出如下提示。
image
帮忙看下是什么问题,win7 64位系统

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.