Permalink
Browse files

Version 2.1

    * Concealing of links can be turned off - set |g:vimwiki_url_maxsave| to 0.
      The option g:vimwiki_url_mingain was removed
    * |g:vimwiki_folding| also accepts value 'list'; with 'expr' both sections
      and code blocks folded, g:vimwiki_fold_lists option was removed
    * Issue 261: Syntax folding is back. |g:vimwiki_folding| values are
      changed to '', 'expr', 'syntax'.
    * Issue 372: Ignore case in g:vimwiki_valid_html_tags
    * Issue 374: Make autowriteall local to vimwiki. It is not 100% local
      though.
    * Issue 384: Custom_wiki2html script now receives templating arguments
    * Issue 393: Custom_wiki2html script path can contain tilde character
    * Issue 392: Custom_wiki2html arguments are quoted, e.g names with spaces
    * Various small bug fixes.
  • Loading branch information...
1 parent d19cc85 commit cb5c38a575bcdffa52747aef962dc9d61c7a8207 @habamax habamax committed with Apr 14, 2013
Showing with 330 additions and 187 deletions.
  1. +3 −3 autoload/vimwiki/base.vim
  2. +23 −22 autoload/vimwiki/html.vim
  3. +39 −30 autoload/vimwiki/tbl.vim
  4. +79 −38 doc/vimwiki.txt
  5. +119 −55 ftplugin/vimwiki.vim
  6. +17 −9 plugin/vimwiki.vim
  7. +50 −30 syntax/vimwiki.vim
@@ -441,7 +441,7 @@ function! vimwiki#base#system_open_link(url) "{{{
execute '!open ' . shellescape(a:url, 1)
endfunction
function! s:linux_handler(url)
- execute 'silent !xdg-open ' . shellescape(a:url, 1)
+ call system('xdg-open ' . shellescape(a:url, 1).' &')
endfunction
let success = 0
try
@@ -549,7 +549,7 @@ endfunction "}}}
function! vimwiki#base#backlinks() "{{{
execute 'lvimgrep "\%(^\|[[:blank:][:punct:]]\)'.
\ expand("%:t:r").
- \ '\([[:blank:][:punct:]]\|$\)" '.
+ \ '\([[:blank:][:punct:]]\|$\)\C" '.
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
endfunction "}}}
@@ -639,7 +639,7 @@ function! vimwiki#base#edit_file(command, filename, ...) "{{{
" then
" [[test*file]]...
" 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")
if vimwiki#base#mkdir(dir, 1)
execute a:command.' '.fname
@@ -4,7 +4,15 @@
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
-" XXX: This file should be refactored!
+" TODO: We need vimwiki abstract syntax tree. If properly designed it wourld
+" greatly symplify different syntax to HTML generation.
+"
+" vimwiki -- --> PDF
+" \ /
+" markdown -----> AST -----> HTML
+" / \
+" mediawiki -- --> Latex
+"
" Load only once {{{
if exists("g:loaded_vimwiki_html_auto") || &cp
@@ -137,22 +145,12 @@ endfunction "}}}
function! s:safe_html(line) "{{{
" escape & < > when producing HTML text
- " uses variables s:lt_pattern, s:gt_pattern that are
- " set in vimwiki#html#Wiki2HTML() according to g:vimwiki_valid_html_tags
- "" htmlize symbols: < > &
-
+ " s:lt_pattern, s:gt_pattern depend on g:vimwiki_valid_html_tags
+ " and are set in vimwiki#html#Wiki2HTML()
let line = substitute(a:line, '&', '\&amp;', 'g')
- " the following depends on g:vimwiki_valid_html_tags
let line = substitute(line,s:lt_pattern,'\&lt;', 'g')
let line = substitute(line,s:gt_pattern,'\&gt;', 'g')
- "let tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
- "let line = substitute(line,'<\%(/\?\%('
- " \.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?>\)\@!',
- " \'\&lt;', 'g')
- "let line = substitute(line,'\%(</\?\%('
- " \.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?\)\@<!>',
- " \'\&gt;', 'g')
return line
endfunction "}}}
@@ -456,11 +454,10 @@ function! s:tag_wikilink(value) "{{{
if g:vimwiki_debug > 1
echom '[[idx='.idx.', scheme='.scheme.', path='.path.', subdir='.subdir.', lnk='.lnk.', ext='.ext.']]'
endif
- let url = escape(url, '#')
let line = vimwiki#html#linkify_link(url, descr)
return line
endfunction "}}}
-"}}} v1.3 links
+"}}}
function! s:tag_remove_internal_link(value) "{{{
@@ -1352,13 +1349,17 @@ endfunction " }}}
function! vimwiki#html#CustomWiki2HTML(path, wikifile, force) "{{{
call vimwiki#base#mkdir(a:path)
- execute '!'.VimwikiGet('custom_wiki2html'). ' '
+ echomsg system(VimwikiGet('custom_wiki2html'). ' '.
\ a:force. ' '.
\ VimwikiGet('syntax'). ' '.
\ strpart(VimwikiGet('ext'), 1). ' '.
- \ a:path. ' '.
- \ a:wikifile. ' '.
- \ s:default_CSS_full_name(a:path)
+ \ shellescape(a:path, 1). ' '.
+ \ shellescape(a:wikifile, 1). ' '.
+ \ shellescape(s:default_CSS_full_name(a:path), 1). ' '.
+ \ (len(VimwikiGet('template_path')) > 1 ? shellescape(expand(VimwikiGet('template_path')), 1) : '-'). ' '.
+ \ (len(VimwikiGet('template_default')) > 0 ? VimwikiGet('template_default') : '-'). ' '.
+ \ (len(VimwikiGet('template_ext')) > 0 ? VimwikiGet('template_ext') : '-'). ' '.
+ \ (len(VimwikiGet('subdir')) > 0 ? shellescape(s:root_path(VimwikiGet('subdir')), 1) : '-'))
endfunction " }}}
function! vimwiki#html#Wiki2HTML(path_html, wikifile) "{{{
@@ -1415,8 +1416,8 @@ function! vimwiki#html#Wiki2HTML(path_html, wikifile) "{{{
let s:gt_pattern = '>'
if g:vimwiki_valid_html_tags != ''
let tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
- let s:lt_pattern = '<\%(/\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?>\)\@!'
- let s:gt_pattern = '\%(</\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?\)\@<!>'
+ let s:lt_pattern = '\c<\%(/\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?>\)\@!'
+ let s:gt_pattern = '\c\%(</\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?\)\@<!>'
endif
for line in lsource
@@ -1566,7 +1567,7 @@ function! vimwiki#html#WikiAll2HTML(path_html) "{{{
endfunction "}}}
function! s:file_exists(fname) "{{{
- return !empty(getftype(a:fname))
+ return !empty(getftype(expand(a:fname)))
endfunction "}}}
" uses VimwikiGet('path')
@@ -16,10 +16,13 @@ let g:loaded_vimwiki_tbl_auto = 1
"}}}
let s:textwidth = &tw
-let s:rxSep = g:vimwiki_rxTableSep
" Misc functions {{{
+function! s:rxSep() "{{{
+ return g:vimwiki_rxTableSep
+endfunction "}}}
+
function! s:wide_len(str) "{{{
" vim73 has new function that gives correct string width.
if exists("*strdisplaywidth")
@@ -43,36 +46,36 @@ function! s:wide_len(str) "{{{
endfunction "}}}
function! s:cell_splitter() "{{{
- return '\s*'.s:rxSep.'\s*'
+ return '\s*'.s:rxSep().'\s*'
endfunction "}}}
function! s:sep_splitter() "{{{
- return '-'.s:rxSep.'-'
+ return '-'.s:rxSep().'-'
endfunction "}}}
function! s:is_table(line) "{{{
- return s:is_separator(a:line) || (a:line !~ s:rxSep.s:rxSep && a:line =~ '^\s*'.s:rxSep.'.\+'.s:rxSep.'\s*$')
+ return s:is_separator(a:line) || (a:line !~ s:rxSep().s:rxSep() && a:line =~ '^\s*'.s:rxSep().'.\+'.s:rxSep().'\s*$')
endfunction "}}}
function! s:is_separator(line) "{{{
- return a:line =~ '^\s*'.s:rxSep.'\(--\+'.s:rxSep.'\)\+\s*$'
+ return a:line =~ '^\s*'.s:rxSep().'\(--\+'.s:rxSep().'\)\+\s*$'
endfunction "}}}
function! s:is_separator_tail(line) "{{{
- return a:line =~ '^\{-1}\%(\s*\|-*\)\%('.s:rxSep.'-\+\)\+'.s:rxSep.'\s*$'
+ return a:line =~ '^\{-1}\%(\s*\|-*\)\%('.s:rxSep().'-\+\)\+'.s:rxSep().'\s*$'
endfunction "}}}
function! s:is_last_column(lnum, cnum) "{{{
let line = strpart(getline(a:lnum), a:cnum - 1)
- "echomsg "DEBUG is_last_column> ".(line =~ s:rxSep.'\s*$' && line !~ s:rxSep.'.*'.s:rxSep.'\s*$')
- return line =~ s:rxSep.'\s*$' && line !~ s:rxSep.'.*'.s:rxSep.'\s*$'
+ "echomsg "DEBUG is_last_column> ".(line =~ s:rxSep().'\s*$' && line !~ s:rxSep().'.*'.s:rxSep().'\s*$')
+ return line =~ s:rxSep().'\s*$' && line !~ s:rxSep().'.*'.s:rxSep().'\s*$'
endfunction "}}}
function! s:is_first_column(lnum, cnum) "{{{
let line = strpart(getline(a:lnum), 0, a:cnum - 1)
- "echomsg "DEBUG is_first_column> ".(line =~ '^\s*'.s:rxSep && line !~ '^\s*'.s:rxSep.'.*'.s:rxSep)
- return line =~ '^\s*$' || (line =~ '^\s*'.s:rxSep && line !~ '^\s*'.s:rxSep.'.*'.s:rxSep)
+ "echomsg "DEBUG is_first_column> ".(line =~ '^\s*'.s:rxSep() && line !~ '^\s*'.s:rxSep().'.*'.s:rxSep())
+ return line =~ '^\s*$' || (line =~ '^\s*'.s:rxSep() && line !~ '^\s*'.s:rxSep().'.*'.s:rxSep())
endfunction "}}}
function! s:count_separators_up(lnum) "{{{
@@ -100,8 +103,8 @@ function! s:count_separators_down(lnum) "{{{
endfunction "}}}
function! s:create_empty_row(cols) "{{{
- let row = s:rxSep
- let cell = " ".s:rxSep
+ let row = s:rxSep()
+ let cell = " ".s:rxSep()
for c in range(a:cols)
let row .= cell
@@ -111,8 +114,8 @@ function! s:create_empty_row(cols) "{{{
endfunction "}}}
function! s:create_row_sep(cols) "{{{
- let row = s:rxSep
- let cell = "---".s:rxSep
+ let row = s:rxSep()
+ let cell = "---".s:rxSep()
for c in range(a:cols)
let row .= cell
@@ -274,10 +277,10 @@ function! s:cur_column() "{{{
" TODO: do we need conditional: if s:is_separator(line)
let curs_pos = col('.')
- let mpos = match(line, s:rxSep, 0)
+ let mpos = match(line, s:rxSep(), 0)
let col = -1
while mpos < curs_pos && mpos != -1
- let mpos = match(line, s:rxSep, mpos+1)
+ let mpos = match(line, s:rxSep(), mpos+1)
if mpos != -1
let col += 1
endif
@@ -301,7 +304,7 @@ function! s:fmt_cell(cell, max_len) "{{{
endfunction "}}}
function! s:fmt_row(line, max_lens, col1, col2) "{{{
- let new_line = s:rxSep
+ let new_line = s:rxSep()
let cells = vimwiki#tbl#get_cells(a:line)
for idx in range(len(cells))
if idx == a:col1
@@ -310,12 +313,12 @@ function! s:fmt_row(line, max_lens, col1, col2) "{{{
let idx = a:col1
endif
let value = cells[idx]
- let new_line .= s:fmt_cell(value, a:max_lens[idx]).s:rxSep
+ let new_line .= s:fmt_cell(value, a:max_lens[idx]).s:rxSep()
endfor
let idx = len(cells)
while idx < len(a:max_lens)
- let new_line .= s:fmt_cell('', a:max_lens[idx]).s:rxSep
+ let new_line .= s:fmt_cell('', a:max_lens[idx]).s:rxSep()
let idx += 1
endwhile
return new_line
@@ -330,14 +333,14 @@ function! s:fmt_cell_sep(max_len) "{{{
endfunction "}}}
function! s:fmt_sep(max_lens, col1, col2) "{{{
- let new_line = s:rxSep
+ let new_line = s:rxSep()
for idx in range(len(a:max_lens))
if idx == a:col1
let idx = a:col2
elseif idx == a:col2
let idx = a:col1
endif
- let new_line .= s:fmt_cell_sep(a:max_lens[idx]).s:rxSep
+ let new_line .= s:fmt_cell_sep(a:max_lens[idx]).s:rxSep()
endfor
return new_line
endfunction "}}}
@@ -349,10 +352,10 @@ function! s:kbd_create_new_row(cols, goto_first) "{{{
let cmd .= "\<ESC>:call vimwiki#tbl#format(line('.'))\<CR>"
let cmd .= "\<ESC>0"
if a:goto_first
- let cmd .= ":call search('\\(".s:rxSep."\\)\\zs', 'c', line('.'))\<CR>"
+ let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'c', line('.'))\<CR>"
else
let cmd .= (col('.')-1)."l"
- let cmd .= ":call search('\\(".s:rxSep."\\)\\zs', 'bc', line('.'))\<CR>"
+ let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>"
endif
let cmd .= "a"
@@ -361,16 +364,16 @@ endfunction "}}}
function! s:kbd_goto_next_row() "{{{
let cmd = "\<ESC>j"
- let cmd .= ":call search('.\\(".s:rxSep."\\)', 'c', line('.'))\<CR>"
- let cmd .= ":call search('\\(".s:rxSep."\\)\\zs', 'bc', line('.'))\<CR>"
+ let cmd .= ":call search('.\\(".s:rxSep()."\\)', 'c', line('.'))\<CR>"
+ let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>"
let cmd .= "a"
return cmd
endfunction "}}}
function! s:kbd_goto_prev_row() "{{{
let cmd = "\<ESC>k"
- let cmd .= ":call search('.\\(".s:rxSep."\\)', 'c', line('.'))\<CR>"
- let cmd .= ":call search('\\(".s:rxSep."\\)\\zs', 'bc', line('.'))\<CR>"
+ let cmd .= ":call search('.\\(".s:rxSep()."\\)', 'c', line('.'))\<CR>"
+ let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>"
let cmd .= "a"
return cmd
endfunction "}}}
@@ -432,7 +435,7 @@ function! s:kbd_goto_prev_col(jumpup) "{{{
let cmd .= "$"
endif
let cmd .= ":call vimwiki#tbl#goto_prev_col()\<CR>a"
- " let cmd .= ":call search('\\(".s:rxSep."\\)\\zs', 'b', line('.'))\<CR>"
+ " let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'b', line('.'))\<CR>"
" let cmd .= "a"
"echomsg "DEBUG kbd_goto_prev_col> ".cmd
return cmd
@@ -487,6 +490,9 @@ function! vimwiki#tbl#kbd_shift_tab() "{{{
endfunction "}}}
function! vimwiki#tbl#format(lnum, ...) "{{{
+ if !(&filetype == 'vimwiki')
+ return
+ endif
let line = getline(a:lnum)
if !s:is_table(line)
return
@@ -554,6 +560,9 @@ function! vimwiki#tbl#align_or_cmd(cmd) "{{{
endfunction "}}}
function! vimwiki#tbl#reset_tw(lnum) "{{{
+ if !(&filetype == 'vimwiki')
+ return
+ endif
let line = getline(a:lnum)
if !s:is_table(line)
return
@@ -584,7 +593,7 @@ function! vimwiki#tbl#move_column_left() "{{{
call vimwiki#tbl#format(line('.'), cur_col-1, cur_col)
call cursor(line('.'), 1)
- let sep = '\('.s:rxSep.'\).\zs'
+ let sep = '\('.s:rxSep().'\).\zs'
let mpos = -1
let col = -1
while col < cur_col-1
@@ -617,7 +626,7 @@ function! vimwiki#tbl#move_column_right() "{{{
call vimwiki#tbl#format(line('.'), cur_col, cur_col+1)
call cursor(line('.'), 1)
- let sep = '\('.s:rxSep.'\).\zs'
+ let sep = '\('.s:rxSep().'\).\zs'
let mpos = -1
let col = -1
while col < cur_col+1
Oops, something went wrong. Retry.

0 comments on commit cb5c38a

Please sign in to comment.