Skip to content

Commit

Permalink
update to version 3.1.0
Browse files Browse the repository at this point in the history
1. fix bug when the flowchart is not rendered.
2. simplify the configuration.
  • Loading branch information
D0n9X1n committed Sep 21, 2017
1 parent 39efc40 commit 3c081be
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 56 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ If your plugin folder is not `.vim/bundle`, you should config it first, by addin
Like:
```
" markdown-preview.vim {{{
let g:SourceMarkDownResDir = '/Users/Mike/.vim/bundle/markdown-preview.vim/resources'
let g:MarkDownResDir = '/Users/Mike/.vim/MarkDownRes'
let g:PluginDir = '/Users/Mike/.vim/bundle/'
" }}}
```
+ g:SourceMarkDownResDir is your plugin folder.
Expand Down
12 changes: 6 additions & 6 deletions TEST.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
###Flowchart
### Flowchart
```chart
sequenceDiagram
participant Alice
Expand Down Expand Up @@ -61,18 +61,18 @@ sequenceDiagram
end
```

###HTML BLOCK
### HTML BLOCK

<center> In god we trust. </center>

###Table
### Table
| Tables | Are | Cool |
| ------------- |:-------------:| -----:|
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |

###PYTHON
### PYTHON
```
#!/usr/bin/env python
# encoding: utf-8
Expand Down Expand Up @@ -104,7 +104,7 @@ if __name__ == '__main__':
```

###C/C++
### C/C++
```
class Solution {
public:
Expand All @@ -126,7 +126,7 @@ int main() {
}
```

###Java
### Java
```
public class FourSum {
public static void main(String[] args) {
Expand Down
2 changes: 1 addition & 1 deletion plugin/markdown-preview.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""""""""""""""""""""""
" markdown-preview.vim
" version: v3.0.3
" version: v3.1.0
" author: Dongxin Tang
" mail: [email protected]
"""""""""""""""""""""""
Expand Down
72 changes: 37 additions & 35 deletions pythonx/markdown_init.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
#!/usr/bin/env python
# encoding: utf-8

import os
import vim
import platform
import shutil
import markdown_version
# import os
# import vim
# import platform
# import shutil
# import markdown_version


def init():
if vim.eval("exists('g:MarkDownResDir')") == '1':
DisResDir = vim.eval('g:MarkDownResDir')
else:
if platform.system() == 'Windows':
DisResDir = os.path.join(vim.eval('$HOME'), '.vim', 'MarkDownRes')
elif vim.eval("has('nvim')") == '1':
DisResDir = os.path.join(vim.eval('$HOME'), '.nvim', 'MarkDownRes')
else:
DisResDir = os.path.join(vim.eval('$HOME'), '.vim', 'MarkDownRes')

if vim.eval("exists('g:SourceMarkDownResDir')") == '1':
SourceResDir = vim.eval('g:SourceMarkDownResDir')
else:
if platform.system() == 'Windows':
SourceResDir = os.path.join(vim.eval('$HOME'), '.vim', 'bundle/markdown-preview.vim/resources')
elif vim.eval("has('nvim')") == '1':
SourceResDir = os.path.join(vim.eval('$HOME'), '.nvim', 'bundle/markdown-preview.vim/resources')
else:
SourceResDir = os.path.join(vim.eval('$HOME'), '.vim', 'bundle/markdown-preview.vim/resources')

if not os.path.isdir(DisResDir) or not os.path.isfile(os.path.join(DisResDir, markdown_version.__PLUGIN_VERSION__)):
if os.path.isdir(DisResDir):
shutil.rmtree(DisResDir)
print('updating markdown-preview plugin...')

shutil.copytree(SourceResDir, DisResDir)

open(os.path.join(DisResDir, markdown_version.__PLUGIN_VERSION__), "w")

print('markdown-preview plugin has been updated to the lastest version: ' + markdown_version.__PLUGIN_VERSION__)
# if vim.eval("exists('g:PluginDir')") == '1':
# DisResDir = vim.eval('g:PluginDir')
# else:
# print('No config path, use the default path instead.')

# if platform.system() == 'Windows':
# DisResDir = os.path.join(vim.eval('$HOME'), '.vim', 'MarkDownRes')
# elif vim.eval("has('nvim')") == '1':
# DisResDir = os.path.join(vim.eval('$HOME'), '.nvim', 'MarkDownRes')
# else:
# DisResDir = os.path.join(vim.eval('$HOME'), '.vim', 'MarkDownRes')

# if vim.eval("exists('g:SourceMarkDownResDir')") == '1':
# SourceResDir = vim.eval('g:SourceMarkDownResDir')
# else:
# if platform.system() == 'Windows':
# SourceResDir = os.path.join(vim.eval('$HOME'), '.vim', 'bundle/markdown-preview.vim/resources')
# elif vim.eval("has('nvim')") == '1':
# SourceResDir = os.path.join(vim.eval('$HOME'), '.nvim', 'bundle/markdown-preview.vim/resources')
# else:
# SourceResDir = os.path.join(vim.eval('$HOME'), '.vim', 'bundle/markdown-preview.vim/resources')

# if not os.path.isdir(DisResDir) or not os.path.isfile(os.path.join(DisResDir, markdown_version.__PLUGIN_VERSION__)):
# if os.path.isdir(DisResDir):
# shutil.rmtree(DisResDir)
# print('updating markdown-preview plugin...')

# shutil.copytree(SourceResDir, DisResDir)

# open(os.path.join(DisResDir, markdown_version.__PLUGIN_VERSION__), "w")

# print('markdown-preview plugin has been updated to the lastest version: ' + markdown_version.__PLUGIN_VERSION__)

return False
20 changes: 9 additions & 11 deletions pythonx/markdown_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,18 @@ def getBuff():


def getHead(cssStyle='github', codeStyle='default'):
if vim.eval("exists('g:MarkDownResDir')") == '1':
resDir = vim.eval('g:MarkDownResDir')
if vim.eval("exists('g:PluginDir')") == '1':
resDir = os.path.join(vim.eval('g:PluginDir'), 'resources')
else:
resDir = os.path.join('markdown-preview.vim', 'resources');
resDir = os.path.join('bundle', resDir);
if platform.system() == 'Windows':
resDir = os.path.join(vim.eval('$HOME'), '.vim', 'MarkDownRes')
resDir = os.path.join(vim.eval('$HOME'), '.vim', resDir)
elif vim.eval("has('nvim')") == '1':
resDir = os.path.join(vim.eval('$HOME'), '.nvim', 'MarkDownRes')
resDir = os.path.join(vim.eval('$HOME'), '.nvim', resDir)
else:
resDir = os.path.join(vim.eval('$HOME'), '.vim', 'MarkDownRes')
resDir = os.path.join(vim.eval('$HOME'), '.vim', resDir)
print resDir

if cssStyle == '':
cssStyle = 'github'
Expand All @@ -76,14 +79,9 @@ def getHead(cssStyle='github', codeStyle='default'):
content += '<script src="' + resDir + '/js/highlight.pack.js"></script>\n'
content += '<script src="' + resDir + '/js/jquery-1.11.3.min.js"></script>\n'
content += '<script src="' + resDir + '/js/mermaid.js"></script>\n'
content += '<script> hljs.initHighlightingOnLoad(); window.onload = function() { mermaid.init({noteMargin: 5}, ".lang-chart"); }; </script>\n'

# if isLive == True:
# content += '<script src="' + resDir + '/js/autoload.js"></script>\n'

content += '<script> hljs.initHighlightingOnLoad(); window.onload = function() { mermaid.init({noteMargin: 5}, ".language-chart"); }; </script>\n'
content += '</head>\n<body id="content">'
return content


def getBody():
return "</body></html>\r\n\r\n\r\n\r\n"
2 changes: 1 addition & 1 deletion pythonx/markdown_version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# encoding: utf-8

__PLUGIN_VERSION__ = '3.0.3'
__PLUGIN_VERSION__ = '3.1.0'
__AUTHOR__ = 'Tang Dongxin'
__MAIL__ = '[email protected]'
__DEBUG__ = False

0 comments on commit 3c081be

Please sign in to comment.