Merge pull request #5 from vimwiki/dev

Merge upstream patches
This commit is contained in:
Michael F. Schönitzer 2017-11-15 16:32:54 +01:00 committed by GitHub
commit 0df94e47a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 99 additions and 37 deletions

22
LICENSE Normal file
View File

@ -0,0 +1,22 @@
MIT License
Copyright (c) 2008-2010 Maxim Kim
2013-2017 Daniel Schemala
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -8,6 +8,13 @@ if exists("g:loaded_vimwiki_auto") || &cp
endif endif
let g:loaded_vimwiki_auto = 1 let g:loaded_vimwiki_auto = 1
" s:safesubstitute
function! s:safesubstitute(text, search, replace, mode) "{{{
" Substitute regexp but do not interpret replace
let escaped = escape(a:replace, '\&')
return substitute(a:text, a:search, escaped, a:mode)
endfunction " }}}
" s:vimwiki_get_known_syntaxes " s:vimwiki_get_known_syntaxes
function! s:vimwiki_get_known_syntaxes() " {{{ function! s:vimwiki_get_known_syntaxes() " {{{
" Getting all syntaxes that different wikis could have " Getting all syntaxes that different wikis could have
@ -465,7 +472,7 @@ function! vimwiki#base#generate_links() "{{{
let abs_filepath = vimwiki#path#abs_path_of_link(link) let abs_filepath = vimwiki#path#abs_path_of_link(link)
if !s:is_diary_file(abs_filepath) if !s:is_diary_file(abs_filepath)
call add(lines, bullet. call add(lines, bullet.
\ substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', '\='."'".link."'", '')) \ s:safesubstitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', link, ''))
endif endif
endfor endfor
@ -677,13 +684,13 @@ function! s:jump_to_anchor(anchor) "{{{
let segments = split(anchor, '#', 0) let segments = split(anchor, '#', 0)
for segment in segments for segment in segments
let anchor_header = substitute( let anchor_header = s:safesubstitute(
\ g:vimwiki_{VimwikiGet('syntax')}_header_match, \ g:vimwiki_{VimwikiGet('syntax')}_header_match,
\ '__Header__', "\\='".segment."'", '') \ '__Header__', segment, '')
let anchor_bold = substitute(g:vimwiki_{VimwikiGet('syntax')}_bold_match, let anchor_bold = s:safesubstitute(g:vimwiki_{VimwikiGet('syntax')}_bold_match,
\ '__Text__', "\\='".segment."'", '') \ '__Text__', segment, '')
let anchor_tag = substitute(g:vimwiki_{VimwikiGet('syntax')}_tag_match, let anchor_tag = s:safesubstitute(g:vimwiki_{VimwikiGet('syntax')}_tag_match,
\ '__Tag__', "\\='".segment."'", '') \ '__Tag__', segment, '')
if !search(anchor_tag, 'Wc') if !search(anchor_tag, 'Wc')
\ && !search(anchor_header, 'Wc') \ && !search(anchor_header, 'Wc')
@ -840,7 +847,7 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...) "{{{
" then " then
" [[test*file]]... " [[test*file]]...
" you'll have E77: Too many file names " you'll have E77: Too many file names
let fname = escape(a:filename, '% *|#') let fname = escape(a:filename, '% *|#`')
let dir = fnamemodify(a:filename, ":p:h") let dir = fnamemodify(a:filename, ":p:h")
let ok = vimwiki#path#mkdir(dir, 1) let ok = vimwiki#path#mkdir(dir, 1)
@ -1176,8 +1183,8 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header,
" write new listing " write new listing
let new_header = whitespaces_in_first_line let new_header = whitespaces_in_first_line
\ . substitute(g:vimwiki_rxH1_Template, \ . s:safesubstitute(g:vimwiki_rxH1_Template,
\ '__Header__', '\='."'".a:start_header."'", '') \ '__Header__', a:start_header, '')
call append(start_lnum - 1, new_header) call append(start_lnum - 1, new_header)
let start_lnum += 1 let start_lnum += 1
let lines_diff += 1 + len(a:strings) let lines_diff += 1 + len(a:strings)
@ -1273,7 +1280,7 @@ function! vimwiki#base#follow_link(split, reuse, move_cursor, ...) "{{{
" remove the extension from the filename if exists, because non-vimwiki " remove the extension from the filename if exists, because non-vimwiki
" markdown files usually include the extension in links " markdown files usually include the extension in links
let lnk = substitute(lnk, VimwikiGet('ext').'$', '', '') let lnk = substitute(lnk, '\'.VimwikiGet('ext').'$', '', '')
endif endif
let current_tab_page = tabpagenr() let current_tab_page = tabpagenr()
@ -1326,7 +1333,13 @@ function! vimwiki#base#goto_index(wnum, ...) "{{{
endif endif
if a:0 if a:0
if a:1 == 1
let cmd = 'tabedit' let cmd = 'tabedit'
elseif a:1 == 2
let cmd = 'split'
elseif a:1 == 3
let cmd = 'vsplit'
endif
else else
let cmd = 'edit' let cmd = 'edit'
endif endif
@ -1826,9 +1839,9 @@ function! vimwiki#base#table_of_contents(create)
for [lvl, link, desc] in headers for [lvl, link, desc] in headers
let esc_link = substitute(link, "'", "''", 'g') let esc_link = substitute(link, "'", "''", 'g')
let esc_desc = substitute(desc, "'", "''", 'g') let esc_desc = substitute(desc, "'", "''", 'g')
let link = substitute(g:vimwiki_WikiLinkTemplate2, '__LinkUrl__', let link = s:safesubstitute(g:vimwiki_WikiLinkTemplate2, '__LinkUrl__',
\ '\='."'".'#'.esc_link."'", '') \ '#'.esc_link, '')
let link = substitute(link, '__LinkDescription__', '\='."'".esc_desc."'", '') let link = s:safesubstitute(link, '__LinkDescription__', esc_desc, '')
call add(lines, startindent.repeat(indentstring, lvl-1).bullet.link) call add(lines, startindent.repeat(indentstring, lvl-1).bullet.link)
endfor endfor
@ -1849,13 +1862,13 @@ endfunction
function! vimwiki#base#apply_template(template, rxUrl, rxDesc, rxStyle) "{{{ function! vimwiki#base#apply_template(template, rxUrl, rxDesc, rxStyle) "{{{
let lnk = a:template let lnk = a:template
if a:rxUrl != "" if a:rxUrl != ""
let lnk = substitute(lnk, '__LinkUrl__', '\='."'".a:rxUrl."'", 'g') let lnk = s:safesubstitute(lnk, '__LinkUrl__', a:rxUrl, 'g')
endif endif
if a:rxDesc != "" if a:rxDesc != ""
let lnk = substitute(lnk, '__LinkDescription__', '\='."'".a:rxDesc."'", 'g') let lnk = s:safesubstitute(lnk, '__LinkDescription__', a:rxDesc, 'g')
endif endif
if a:rxStyle != "" if a:rxStyle != ""
let lnk = substitute(lnk, '__LinkStyle__', '\='."'".a:rxStyle."'", 'g') let lnk = s:safesubstitute(lnk, '__LinkStyle__', a:rxStyle, 'g')
endif endif
return lnk return lnk
endfunction " }}} endfunction " }}}
@ -1894,8 +1907,8 @@ function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template) " {{{
if descr == "" if descr == ""
let descr = s:clean_url(url) let descr = s:clean_url(url)
endif endif
let lnk = substitute(template, '__LinkDescription__', '\="'.descr.'"', '') let lnk = s:safesubstitute(template, '__LinkDescription__', descr, '')
let lnk = substitute(lnk, '__LinkUrl__', '\="'.url.'"', '') let lnk = s:safesubstitute(lnk, '__LinkUrl__', url, '')
return lnk return lnk
endfunction " }}} endfunction " }}}
@ -1903,7 +1916,7 @@ endfunction " }}}
function! vimwiki#base#normalize_imagelink_helper(str, rxUrl, rxDesc, rxStyle, template) "{{{ function! vimwiki#base#normalize_imagelink_helper(str, rxUrl, rxDesc, rxStyle, template) "{{{
let lnk = vimwiki#base#normalize_link_helper(a:str, a:rxUrl, a:rxDesc, a:template) let lnk = vimwiki#base#normalize_link_helper(a:str, a:rxUrl, a:rxDesc, a:template)
let style = matchstr(a:str, a:rxStyle) let style = matchstr(a:str, a:rxStyle)
let lnk = substitute(lnk, '__LinkStyle__', '\="'.style.'"', '') let lnk = s:safesubstitute(lnk, '__LinkStyle__', style, '')
return lnk return lnk
endfunction " }}} endfunction " }}}
@ -1995,8 +2008,8 @@ function! s:normalize_link_syntax_v() " {{{
if s:is_diary_file(expand("%:p")) if s:is_diary_file(expand("%:p"))
let sub = s:normalize_link_in_diary(@") let sub = s:normalize_link_in_diary(@")
else else
let sub = substitute(g:vimwiki_WikiLinkTemplate1, let sub = s:safesubstitute(g:vimwiki_WikiLinkTemplate1,
\ '__LinkUrl__', '\=' . "'" . @" . "'", '') \ '__LinkUrl__', @", '')
endif endif
" Put substitution in register " and change text " Put substitution in register " and change text

View File

@ -65,7 +65,7 @@ fun! s:read_captions(files) "{{{
let result = {} let result = {}
for fl in a:files for fl in a:files
" remove paths and extensions " remove paths and extensions
let fl_key = fnamemodify(fl, ':t:r') let fl_key = substitute(fnamemodify(fl, ':t'), VimwikiGet('ext').'$', '', '')
if filereadable(fl) if filereadable(fl)
for line in readfile(fl, '', s:vimwiki_max_scan_for_caption) for line in readfile(fl, '', s:vimwiki_max_scan_for_caption)
@ -174,8 +174,14 @@ function! vimwiki#diary#make_note(wnum, ...) "{{{
call vimwiki#path#mkdir(VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx)) call vimwiki#path#mkdir(VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx))
if a:0 && a:1 == 1 if a:0
if a:1 == 1
let cmd = 'tabedit' let cmd = 'tabedit'
elseif a:2 == 2
let cmd = 'split'
elseif a:3 == 3
let cmd = 'vsplit'
endif
else else
let cmd = 'edit' let cmd = 'edit'
endif endif

View File

@ -6,6 +6,13 @@
" MISC helper functions {{{ " MISC helper functions {{{
" s:safesubstitute
function! s:safesubstitute(text, search, replace, mode) "{{{
" Substitute regexp but do not interpret replace
let escaped = escape(a:replace, '\&')
return substitute(a:text, a:search, escaped, a:mode)
endfunction " }}}
" vimwiki#markdown_base#reset_mkd_refs " vimwiki#markdown_base#reset_mkd_refs
function! vimwiki#markdown_base#reset_mkd_refs() "{{{ function! vimwiki#markdown_base#reset_mkd_refs() "{{{
call VimwikiClear('markdown_refs') call VimwikiClear('markdown_refs')
@ -139,8 +146,8 @@ function! s:normalize_link_syntax_v() " {{{
try try
norm! gvy norm! gvy
let visual_selection = @" let visual_selection = @"
let link = substitute(g:vimwiki_Weblink1Template, '__LinkUrl__', '\='."'".visual_selection."'", '') let link = Safesubstitute(g:vimwiki_Weblink1Template, '__LinkUrl__', visual_selection, '')
let link = substitute(link, '__LinkDescription__', '\='."'".visual_selection."'", '') let link = Safesubstitute(link, '__LinkDescription__', visual_selection, '')
call setreg('"', link, 'v') call setreg('"', link, 'v')

View File

@ -1244,14 +1244,9 @@ LaTeX code).
Note: the highlighting in Vim is automatic. For the rendering in HTML, you Note: the highlighting in Vim is automatic. For the rendering in HTML, you
have two alternative options: have two alternative options:
1. using the MathJax server for rendering (needs internet connection). 1. installing MathJax locally (Recommended: faster, no internet required).
Add to your HTML template the following line: Choose a folder on your hard drive and save MathJax in it. Then add to your
HTML template the following line:
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
2. installing MathJax locally (faster, no internet required). Choose a
folder on your hard drive and save MathJax in it. Then add to your HTML
template the following line:
<script type="text/javascript" src="<mathjax_folder>/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> <script type="text/javascript" src="<mathjax_folder>/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
@ -1266,6 +1261,11 @@ template folder. For instance, a sensible folder structure could be:
In this case, <mathjax_folder> would be "../mathjax" (without quotes). In this case, <mathjax_folder> would be "../mathjax" (without quotes).
2. Loading MathJax from a CDN-server (needs internet connection).
Add to your HTML template the following line:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/config/TeX-AMS-MML_HTMLorMML.js"></script>
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
5.9. Blockquotes *vimwiki-syntax-blockquotes* 5.9. Blockquotes *vimwiki-syntax-blockquotes*
@ -2886,6 +2886,19 @@ Contributors and their Github usernames in roughly chronological order:
- @wangzq - @wangzq
- Jinzhou Zhang (@lotabout) - Jinzhou Zhang (@lotabout)
- Michael Riley (@optik-aper) - Michael Riley (@optik-aper)
- Irfan Sharif (@irfansharif)
- John Conroy (@jconroy77)
- Christian Rondeau (@christianrondeau)
- Alex Thorne (@thornecc)
- Shafqat Bhuiyan (@priomsrb)
- Bradley Cicenas (@bcicen)
- Michael Thessel (@MichaelThessel)
- Michael F. Schönitzer (@nudin)
- @sqlwwx
- Guilherme Salazar (@salazar)
- Daniel Trnka (@trnila)
- Yuchen Pei (@ycpei)
- @maqiv
============================================================================== ==============================================================================
@ -3133,10 +3146,11 @@ http://code.google.com/p/vimwiki/issues/list
============================================================================== ==============================================================================
16. License *vimwiki-license* 16. License *vimwiki-license*
The MIT Licence The MIT License
http://www.opensource.org/licenses/mit-license.php http://www.opensource.org/licenses/mit-license.php
Copyright (c) 2008-2010 Maxim Kim Copyright (c) 2008-2010 Maxim Kim
2013-2017 Daniel Schemala
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal