')
+ return toc
+endfunction "}}}
+
+" insert toc into dest.
+function! s:process_toc(dest, placeholders, toc) "{{{
+ let toc_idx = 0
+ if !empty(a:placeholders)
+ for [placeholder, row, idx] in a:placeholders
+ let [type, param] = placeholder
+ if type == 'toc'
+ let toc = a:toc[:]
+ if !empty(param)
+ call insert(toc, '
'.param.'
')
+ endif
+ let shift = toc_idx * len(toc)
+ call extend(a:dest, toc, row + shift)
+ let toc_idx += 1
+ endif
+ endfor
+ endif
+endfunction "}}}
+
+" get title.
+function! s:process_title(placeholders, default_title) "{{{
+ if !empty(a:placeholders)
+ for [placeholder, row, idx] in a:placeholders
+ let [type, param] = placeholder
+ if type == 'title' && !empty(param)
+ return param
+ endif
+ endfor
+ endif
+ return a:default_title
+endfunction "}}}
+
+function! s:is_html_uptodate(wikifile) "{{{
+ let tpl_time = -1
+
+ let tpl_file = s:template_full_name('')
+ if tpl_file != ''
+ let tpl_time = getftime(tpl_file)
+ endif
+
+ let wikifile = fnamemodify(a:wikifile, ":p")
+ let htmlfile = expand(VimwikiGet('path_html').VimwikiGet('subdir').
+ \fnamemodify(wikifile, ":t:r").".html")
+
+ if getftime(wikifile) <= getftime(htmlfile) && tpl_time <= getftime(htmlfile)
+ return 1
+ endif
+ return 0
+endfunction "}}}
+
+function! s:html_insert_contents(html_lines, content) "{{{
+ let lines = []
+ for line in a:html_lines
+ if line =~ '%content%'
+ let parts = split(line, '%content%', 1)
+ if empty(parts)
+ call extend(lines, a:content)
+ else
+ for idx in range(len(parts))
+ call add(lines, parts[idx])
+ if idx < len(parts) - 1
+ call extend(lines, a:content)
+ endif
+ endfor
+ endif
+ else
+ call add(lines, line)
+ endif
+ endfor
+ return lines
+endfunction "}}}
+"}}}
+
+" INLINE TAGS "{{{
+function! s:tag_eqin(value) "{{{
+ " mathJAX wants \( \) for inline maths
+ return '\('.s:mid(a:value, 1).'\)'
+endfunction "}}}
+
+function! s:tag_em(value) "{{{
+ return ''.s:mid(a:value, 1).''
+endfunction "}}}
+
+function! s:tag_strong(value) "{{{
+ return ''.s:mid(a:value, 1).''
+endfunction "}}}
+
+function! s:tag_todo(value) "{{{
+ return ''.a:value.''
+endfunction "}}}
+
+function! s:tag_strike(value) "{{{
+ return ''.s:mid(a:value, 2).''
+endfunction "}}}
+
+function! s:tag_super(value) "{{{
+ return ''.s:mid(a:value, 1).''
+endfunction "}}}
+
+function! s:tag_sub(value) "{{{
+ return ''.s:mid(a:value, 2).''
+endfunction "}}}
+
+function! s:tag_code(value) "{{{
+ return ''.s:safe_html_tags(s:mid(a:value, 1)).''
+endfunction "}}}
+
+"function! s:tag_pre(value) "{{{
+" return ''.s:mid(a:value, 3).''
+"endfunction "}}}
+
+"FIXME dead code?
+"function! s:tag_math(value) "{{{
+" return '\['.s:mid(a:value, 3).'\]'
+"endfunction "}}}
+
+
+"{{{ v2.0 links
+" match n-th ARG within {{URL[|ARG1|ARG2|...]}} " {{{
+" *c,d,e),...
+function! vimwiki#html#incl_match_arg(nn_index)
+ let rx = g:vimwiki_rxWikiInclPrefix. g:vimwiki_rxWikiInclUrl
+ let rx = rx. repeat(g:vimwiki_rxWikiInclSeparator. g:vimwiki_rxWikiInclArg, a:nn_index-1)
+ if a:nn_index > 0
+ let rx = rx. g:vimwiki_rxWikiInclSeparator. '\zs'. g:vimwiki_rxWikiInclArg. '\ze'
+ endif
+ let rx = rx. g:vimwiki_rxWikiInclArgs. g:vimwiki_rxWikiInclSuffix
+ return rx
+endfunction
+"}}}
+
+function! vimwiki#html#linkify_link(src, descr) "{{{
+ let src_str = ' href="'.a:src.'"'
+ let descr = substitute(a:descr,'^\s*\(.*\)\s*$','\1','')
+ let descr = (descr == "" ? a:src : descr)
+ let descr_str = (descr =~ g:vimwiki_rxWikiIncl
+ \ ? s:tag_wikiincl(descr)
+ \ : descr)
+ return ''.descr_str.''
+endfunction "}}}
+
+function! vimwiki#html#linkify_image(src, descr, verbatim_str) "{{{
+ let src_str = ' src="'.a:src.'"'
+ let descr_str = (a:descr != '' ? ' alt="'.a:descr.'"' : '')
+ let verbatim_str = (a:verbatim_str != '' ? ' '.a:verbatim_str : '')
+ return ''
+endfunction "}}}
+
+function! s:tag_weblink(value) "{{{
+ " Weblink Template -> descr
+ let str = a:value
+ let url = matchstr(str, g:vimwiki_rxWeblinkMatchUrl)
+ let descr = matchstr(str, g:vimwiki_rxWeblinkMatchDescr)
+ let line = vimwiki#html#linkify_link(url, descr)
+ return line
+endfunction "}}}
+
+function! s:tag_wikiincl(value) "{{{
+ " {{imgurl|arg1|arg2}} -> ???
+ " {{imgurl}} ->
+ " {{imgurl|descr|style="A"}} ->
+ " {{imgurl|descr|class="B"}} ->
+ let str = a:value
+ " custom transclusions
+ let line = VimwikiWikiIncludeHandler(str)
+ " otherwise, assume image transclusion
+ if line == ''
+ let url_0 = matchstr(str, g:vimwiki_rxWikiInclMatchUrl)
+ let descr = matchstr(str, vimwiki#html#incl_match_arg(1))
+ let verbatim_str = matchstr(str, vimwiki#html#incl_match_arg(2))
+ " resolve url
+ let [idx, scheme, path, subdir, lnk, ext, url] =
+ \ vimwiki#base#resolve_scheme(url_0, 1)
+ " generate html output
+ " TODO: migrate non-essential debugging messages into g:VimwikiLog
+ if g:vimwiki_debug > 1
+ echom '{{idx='.idx.', scheme='.scheme.', path='.path.', subdir='.subdir.', lnk='.lnk.', ext='.ext.'}}'
+ endif
+
+ " Issue 343: Image transclusions: schemeless links have .html appended.
+ " If link is schemeless pass it as it is
+ if scheme == ''
+ let url = lnk
+ endif
+
+ let url = escape(url, '#')
+ let line = vimwiki#html#linkify_image(url, descr, verbatim_str)
+ return line
+ endif
+ return line
+endfunction "}}}
+
+function! s:tag_wikilink(value) "{{{
+ " [[url]] -> url
+ " [[url|descr]] -> descr
+ " [[url|{{...}}]] -> ...
+ " [[fileurl.ext|descr]] -> descr
+ " [[dirurl/|descr]] -> descr
+ let str = a:value
+ let url = matchstr(str, g:vimwiki_rxWikiLinkMatchUrl)
+ let descr = matchstr(str, g:vimwiki_rxWikiLinkMatchDescr)
+ let descr = (substitute(descr,'^\s*\(.*\)\s*$','\1','') != '' ? descr : url)
+
+ " resolve url
+ let [idx, scheme, path, subdir, lnk, ext, url] =
+ \ vimwiki#base#resolve_scheme(url, 1)
+
+ " generate html output
+ " TODO: migrate non-essential debugging messages into g:VimwikiLog
+ if g:vimwiki_debug > 1
+ echom '[[idx='.idx.', scheme='.scheme.', path='.path.', subdir='.subdir.', lnk='.lnk.', ext='.ext.']]'
+ endif
+ let line = vimwiki#html#linkify_link(url, descr)
+ return line
+endfunction "}}}
+"}}}
+
+
+function! s:tag_remove_internal_link(value) "{{{
+ let value = s:mid(a:value, 2)
+
+ let line = ''
+ if value =~ '|'
+ let link_parts = split(value, "|", 1)
+ else
+ let link_parts = split(value, "][", 1)
+ endif
+
+ if len(link_parts) > 1
+ if len(link_parts) < 3
+ let style = ""
+ else
+ let style = link_parts[2]
+ endif
+ let line = link_parts[1]
+ else
+ let line = value
+ endif
+ return line
+endfunction "}}}
+
+function! s:tag_remove_external_link(value) "{{{
+ let value = s:mid(a:value, 1)
+
+ let line = ''
+ if s:is_web_link(value)
+ let lnkElements = split(value)
+ let head = lnkElements[0]
+ let rest = join(lnkElements[1:])
+ if rest==""
+ let rest=head
+ endif
+ let line = rest
+ elseif s:is_img_link(value)
+ let line = ''
+ else
+ " [alskfj sfsf] shouldn't be a link. So return it as it was --
+ " enclosed in [...]
+ let line = '['.value.']'
+ endif
+ return line
+endfunction "}}}
+
+function! s:make_tag(line, regexp, func) "{{{
+ " Make tags for a given matched regexp.
+ " Exclude preformatted text and href links.
+ " FIXME
+ let patt_splitter = '\(`[^`]\+`\)\|'.
+ \ '\('.g:vimwiki_rxPreStart.'.\+'.g:vimwiki_rxPreEnd.'\)\|'.
+ \ '\(\)\|'.
+ \ '\(\)\|'.
+ \ '\('.g:vimwiki_rxEqIn.'\)'
+
+ "FIXME FIXME !!! these can easily occur on the same line!
+ "XXX {{{ }}} ??? obsolete
+ if '`[^`]\+`' == a:regexp || '{{{.\+}}}' == a:regexp || g:vimwiki_rxEqIn == a:regexp
+ let res_line = s:subst_func(a:line, a:regexp, a:func)
+ else
+ let pos = 0
+ " split line with patt_splitter to have parts of line before and after
+ " href links, preformatted text
+ " ie:
+ " hello world `is just a` simple type of prg.
+ " result:
+ " ['hello world ', ' simple ', 'type of', ' prg']
+ let lines = split(a:line, patt_splitter, 1)
+ let res_line = ""
+ for line in lines
+ let res_line = res_line.s:subst_func(line, a:regexp, a:func)
+ let res_line = res_line.matchstr(a:line, patt_splitter, pos)
+ let pos = matchend(a:line, patt_splitter, pos)
+ endfor
+ endif
+ return res_line
+endfunction "}}}
+
+function! s:process_tags_remove_links(line) " {{{
+ let line = a:line
+ let line = s:make_tag(line, '\[\[.\{-}\]\]', 's:tag_remove_internal_link')
+ let line = s:make_tag(line, '\[.\{-}\]', 's:tag_remove_external_link')
+ return line
+endfunction " }}}
+
+function! s:process_tags_typefaces(line) "{{{
+ let line = a:line
+ let line = s:make_tag(line, g:vimwiki_rxItalic, 's:tag_em')
+ let line = s:make_tag(line, g:vimwiki_rxBold, 's:tag_strong')
+ let line = s:make_tag(line, g:vimwiki_rxTodo, 's:tag_todo')
+ let line = s:make_tag(line, g:vimwiki_rxDelText, 's:tag_strike')
+ let line = s:make_tag(line, g:vimwiki_rxSuperScript, 's:tag_super')
+ let line = s:make_tag(line, g:vimwiki_rxSubScript, 's:tag_sub')
+ let line = s:make_tag(line, g:vimwiki_rxCode, 's:tag_code')
+ let line = s:make_tag(line, g:vimwiki_rxEqIn, 's:tag_eqin')
+ return line
+endfunction " }}}
+
+function! s:process_tags_links(line) " {{{
+ let line = a:line
+ let line = s:make_tag(line, g:vimwiki_rxWikiLink, 's:tag_wikilink')
+ let line = s:make_tag(line, g:vimwiki_rxWikiIncl, 's:tag_wikiincl')
+ let line = s:make_tag(line, g:vimwiki_rxWeblink, 's:tag_weblink')
+ return line
+endfunction " }}}
+
+function! s:process_inline_tags(line) "{{{
+ let line = s:process_tags_links(a:line)
+ let line = s:process_tags_typefaces(line)
+ return line
+endfunction " }}}
+"}}}
+
+" BLOCK TAGS {{{
+function! s:close_tag_pre(pre, ldest) "{{{
+ if a:pre[0]
+ call insert(a:ldest, "")
+ return 0
+ endif
+ return a:pre
+endfunction "}}}
+
+function! s:close_tag_math(math, ldest) "{{{
+ if a:math[0]
+ call insert(a:ldest, "\\\]")
+ return 0
+ endif
+ return a:math
+endfunction "}}}
+
+function! s:close_tag_quote(quote, ldest) "{{{
+ if a:quote
+ call insert(a:ldest, "")
+ return 0
+ endif
+ return a:quote
+endfunction "}}}
+
+function! s:close_tag_para(para, ldest) "{{{
+ if a:para
+ call insert(a:ldest, "
")
+ return 0
+ endif
+ return a:para
+endfunction "}}}
+
+function! s:close_tag_table(table, ldest) "{{{
+ " The first element of table list is a string which tells us if table should be centered.
+ " The rest elements are rows which are lists of columns:
+ " ['center',
+ " [ CELL1, CELL2, CELL3 ],
+ " [ CELL1, CELL2, CELL3 ],
+ " [ CELL1, CELL2, CELL3 ],
+ " ]
+ " And CELLx is: { 'body': 'col_x', 'rowspan': r, 'colspan': c }
+
+ function! s:sum_rowspan(table) "{{{
+ let table = a:table
+
+ " Get max cells
+ let max_cells = 0
+ for row in table[1:]
+ let n_cells = len(row)
+ if n_cells > max_cells
+ let max_cells = n_cells
+ end
+ endfor
+
+ " Sum rowspan
+ for cell_idx in range(max_cells)
+ let rows = 1
+
+ for row_idx in range(len(table)-1, 1, -1)
+ if cell_idx >= len(table[row_idx])
+ let rows = 1
+ continue
+ endif
+
+ if table[row_idx][cell_idx].rowspan == 0
+ let rows += 1
+ else " table[row_idx][cell_idx].rowspan == 1
+ let table[row_idx][cell_idx].rowspan = rows
+ let rows = 1
+ endif
+ endfor
+ endfor
+ endfunction "}}}
+
+ function! s:sum_colspan(table) "{{{
+ for row in a:table[1:]
+ let cols = 1
+
+ for cell_idx in range(len(row)-1, 0, -1)
+ if row[cell_idx].colspan == 0
+ let cols += 1
+ else "row[cell_idx].colspan == 1
+ let row[cell_idx].colspan = cols
+ let cols = 1
+ endif
+ endfor
+ endfor
+ endfunction "}}}
+
+ function! s:close_tag_row(row, header, ldest) "{{{
+ call add(a:ldest, '
')
+
+ " Set tag element of columns
+ if a:header
+ let tag_name = 'th'
+ else
+ let tag_name = 'td'
+ end
+
+ " Close tag of columns
+ for cell in a:row
+ if cell.rowspan == 0 || cell.colspan == 0
+ continue
+ endif
+
+ if cell.rowspan > 1
+ let rowspan_attr = ' rowspan="' . cell.rowspan . '"'
+ else "cell.rowspan == 1
+ let rowspan_attr = ''
+ endif
+ if cell.colspan > 1
+ let colspan_attr = ' colspan="' . cell.colspan . '"'
+ else "cell.colspan == 1
+ let colspan_attr = ''
+ endif
+
+ call add(a:ldest, '<' . tag_name . rowspan_attr . colspan_attr .'>')
+ call add(a:ldest, s:process_inline_tags(cell.body))
+ call add(a:ldest, ''. tag_name . '>')
+ endfor
+
+ call add(a:ldest, '
')
+ endfunction "}}}
+
+ let table = a:table
+ let ldest = a:ldest
+ if len(table)
+ call s:sum_rowspan(table)
+ call s:sum_colspan(table)
+
+ if table[0] == 'center'
+ call add(ldest, "
")
+ else
+ call add(ldest, "
")
+ endif
+
+ " Empty lists are table separators.
+ " Search for the last empty list. All the above rows would be a table header.
+ " We should exclude the first element of the table list as it is a text tag
+ " that shows if table should be centered or not.
+ let head = 0
+ for idx in range(len(table)-1, 1, -1)
+ if empty(table[idx])
+ let head = idx
+ break
+ endif
+ endfor
+ if head > 0
+ for row in table[1 : head-1]
+ if !empty(filter(row, '!empty(v:val)'))
+ call s:close_tag_row(row, 1, ldest)
+ endif
+ endfor
+ for row in table[head+1 :]
+ call s:close_tag_row(row, 0, ldest)
+ endfor
+ else
+ for row in table[1 :]
+ call s:close_tag_row(row, 0, ldest)
+ endfor
+ endif
+ call add(ldest, "
")
+ let table = []
+ endif
+ return table
+endfunction "}}}
+
+function! s:close_tag_list(lists, ldest) "{{{
+ while len(a:lists)
+ let item = remove(a:lists, 0)
+ call insert(a:ldest, item[0])
+ endwhile
+endfunction! "}}}
+
+function! s:close_tag_def_list(deflist, ldest) "{{{
+ if a:deflist
+ call insert(a:ldest, "")
+ return 0
+ endif
+ return a:deflist
+endfunction! "}}}
+
+function! s:process_tag_pre(line, pre) "{{{
+ " pre is the list of [is_in_pre, indent_of_pre]
+ "XXX always outputs a single line or empty list!
+ let lines = []
+ let pre = a:pre
+ let processed = 0
+ "XXX huh?
+ "if !pre[0] && a:line =~ '^\s*{{{[^\(}}}\)]*\s*$'
+ if !pre[0] && a:line =~ '^\s*{{{'
+ let class = matchstr(a:line, '{{{\zs.*$')
+ "FIXME class cannot contain arbitrary strings
+ let class = substitute(class, '\s\+$', '', 'g')
+ if class != ""
+ call add(lines, "
")
+ else
+ call add(lines, "
")
+ endif
+ let pre = [1, len(matchstr(a:line, '^\s*\ze{{{'))]
+ let processed = 1
+ elseif pre[0] && a:line =~ '^\s*}}}\s*$'
+ let pre = [0, 0]
+ call add(lines, "
")
+ let processed = 1
+ elseif pre[0]
+ let processed = 1
+ "XXX destroys indent in general!
+ "call add(lines, substitute(a:line, '^\s\{'.pre[1].'}', '', ''))
+ call add(lines, s:safe_html_tags(a:line))
+ endif
+ return [processed, lines, pre]
+endfunction "}}}
+
+function! s:process_tag_math(line, math) "{{{
+ " math is the list of [is_in_math, indent_of_math]
+ let lines = []
+ let math = a:math
+ let processed = 0
+ if !math[0] && a:line =~ '^\s*{{\$[^\(}}$\)]*\s*$'
+ let class = matchstr(a:line, '{{$\zs.*$')
+ "FIXME class cannot be any string!
+ let class = substitute(class, '\s\+$', '', 'g')
+ " Check the math placeholder (default: displaymath)
+ let b:vimwiki_mathEnv = matchstr(class, '^%\zs\S\+\ze%')
+ if b:vimwiki_mathEnv != ""
+ call add(lines, substitute(class, '^%\(\S\+\)%','\\begin{\1}', ''))
+ elseif class != ""
+ call add(lines, "\\\[".class)
+ else
+ call add(lines, "\\\[")
+ endif
+ let math = [1, len(matchstr(a:line, '^\s*\ze{{\$'))]
+ let processed = 1
+ elseif math[0] && a:line =~ '^\s*}}\$\s*$'
+ let math = [0, 0]
+ if b:vimwiki_mathEnv != ""
+ call add(lines, "\\end{".b:vimwiki_mathEnv."}")
+ else
+ call add(lines, "\\\]")
+ endif
+ let processed = 1
+ elseif math[0]
+ let processed = 1
+ call add(lines, substitute(a:line, '^\s\{'.math[1].'}', '', ''))
+ endif
+ return [processed, lines, math]
+endfunction "}}}
+
+function! s:process_tag_quote(line, quote) "{{{
+ let lines = []
+ let quote = a:quote
+ let processed = 0
+ if a:line =~ '^\s\{4,}\S'
+ if !quote
+ call add(lines, "
")
+ let quote = 0
+ endif
+ return [processed, lines, quote]
+endfunction "}}}
+
+function! s:process_tag_list(line, lists) "{{{
+
+ function! s:add_checkbox(line, rx_list, st_tag, en_tag) "{{{
+ let st_tag = a:st_tag
+ let en_tag = a:en_tag
+
+ let chk = matchlist(a:line, a:rx_list)
+ if len(chk) > 0
+ if len(chk[1])>0
+ "wildcard characters are difficult to match correctly
+ if chk[1] =~ '[.*\\^$~]'
+ let chk[1] ='\'.chk[1]
+ endif
+ " let completion = match(g:vimwiki_listsyms, '\C' . chk[1])
+ let completion = s:get_completion_index(chk[1])
+ if completion >= 0 && completion <=4
+ let st_tag = '
'
+ endif
+ endif
+ endif
+ return [st_tag, en_tag]
+ endfunction "}}}
+
+ let in_list = (len(a:lists) > 0)
+
+ " If it is not list yet then do not process line that starts from *bold*
+ " text.
+ if !in_list
+ let pos = match(a:line, g:vimwiki_rxBold)
+ if pos != -1 && strpart(a:line, 0, pos) =~ '^\s*$'
+ return [0, []]
+ endif
+ endif
+
+ let lines = []
+ let processed = 0
+
+ if a:line =~ g:vimwiki_rxListBullet
+ let lstSym = matchstr(a:line, '[*-]')
+ let lstTagOpen = '
'
+ let lstTagClose = '
'
+ let lstRegExp = g:vimwiki_rxListBullet
+ elseif a:line =~ g:vimwiki_rxListNumber
+ let lstSym = '#'
+ let lstTagOpen = ''
+ let lstTagClose = ''
+ let lstRegExp = g:vimwiki_rxListNumber
+ else
+ let lstSym = ''
+ let lstTagOpen = ''
+ let lstTagClose = ''
+ let lstRegExp = ''
+ endif
+
+ if lstSym != ''
+ " To get proper indent level 'retab' the line -- change all tabs
+ " to spaces*tabstop
+ let line = substitute(a:line, '\t', repeat(' ', &tabstop), 'g')
+ let indent = stridx(line, lstSym)
+
+ let checkbox = '\s*\[\(.\?\)\]\s*'
+ let [st_tag, en_tag] = s:add_checkbox(line,
+ \ lstRegExp.checkbox, '
")
+ endif
+ let processed = 1
+ elseif deflist
+ let deflist = 0
+ call add(lines, "
")
+ endif
+ return [processed, lines, deflist]
+endfunction "}}}
+
+function! s:process_tag_para(line, para) "{{{
+ let lines = []
+ let para = a:para
+ let processed = 0
+ if a:line =~ '^\s\{,3}\S'
+ if !para
+ call add(lines, "
")
+ let para = 1
+ endif
+ let processed = 1
+ call add(lines, a:line)
+ elseif para && a:line =~ '^\s*$'
+ call add(lines, "
")
+ let para = 0
+ endif
+ return [processed, lines, para]
+endfunction "}}}
+
+function! s:process_tag_h(line, id) "{{{
+ let line = a:line
+ let processed = 0
+ let h_level = 0
+ let h_text = ''
+ let h_id = ''
+
+ if a:line =~ g:vimwiki_rxHeader
+ let h_level = vimwiki#u#count_first_sym(a:line)
+ endif
+ if h_level > 0
+ let a:id[h_level] += 1
+ " reset higher level ids
+ for level in range(h_level+1, 6)
+ let a:id[level] = 0
+ endfor
+
+ let centered = 0
+ if a:line =~ '^\s\+'
+ let centered = 1
+ endif
+
+ let h_number = ''
+ for l in range(1, h_level-1)
+ let h_number .= a:id[l].'.'
+ endfor
+ let h_number .= a:id[h_level]
+
+ let h_id = 'toc_'.h_number
+
+ let h_part = ''
+ let processed = 1
+ endif
+ return [processed, line, h_level, h_text, h_id]
+endfunction "}}}
+
+function! s:process_tag_hr(line) "{{{
+ let line = a:line
+ let processed = 0
+ if a:line =~ '^-----*$'
+ let line = ''
+ let processed = 1
+ endif
+ return [processed, line]
+endfunction "}}}
+
+function! s:process_tag_table(line, table) "{{{
+ function! s:table_empty_cell(value) "{{{
+ let cell = {}
+
+ if a:value =~ '^\s*\\/\s*$'
+ let cell.body = ''
+ let cell.rowspan = 0
+ let cell.colspan = 1
+ elseif a:value =~ '^\s*>\s*$'
+ let cell.body = ''
+ let cell.rowspan = 1
+ let cell.colspan = 0
+ elseif a:value =~ '^\s*$'
+ let cell.body = ' '
+ let cell.rowspan = 1
+ let cell.colspan = 1
+ else
+ let cell.body = a:value
+ let cell.rowspan = 1
+ let cell.colspan = 1
+ endif
+
+ return cell
+ endfunction "}}}
+
+ function! s:table_add_row(table, line) "{{{
+ if empty(a:table)
+ if a:line =~ '^\s\+'
+ let row = ['center', []]
+ else
+ let row = ['normal', []]
+ endif
+ else
+ let row = [[]]
+ endif
+ return row
+ endfunction "}}}
+
+ let table = a:table
+ let lines = []
+ let processed = 0
+
+ if vimwiki#tbl#is_separator(a:line)
+ call extend(table, s:table_add_row(a:table, a:line))
+ let processed = 1
+ elseif vimwiki#tbl#is_table(a:line)
+ call extend(table, s:table_add_row(a:table, a:line))
+
+ let processed = 1
+ " let cells = split(a:line, vimwiki#tbl#cell_splitter(), 1)[1: -2]
+ let cells = vimwiki#tbl#get_cells(a:line)
+ call map(cells, 's:table_empty_cell(v:val)')
+ call extend(table[-1], cells)
+ else
+ let table = s:close_tag_table(table, lines)
+ endif
+ return [processed, lines, table]
+endfunction "}}}
+
+"}}}
+
+" }}}
+
+" WIKI2HTML "{{{
+function! s:parse_line(line, state) " {{{
+ let state = {}
+ let state.para = a:state.para
+ let state.quote = a:state.quote
+ let state.pre = a:state.pre[:]
+ let state.math = a:state.math[:]
+ let state.table = a:state.table[:]
+ let state.lists = a:state.lists[:]
+ let state.deflist = a:state.deflist
+ let state.placeholder = a:state.placeholder
+ let state.toc = a:state.toc
+ let state.toc_id = a:state.toc_id
+
+ let res_lines = []
+
+ let line = s:safe_html(a:line)
+
+ let processed = 0
+
+ if !processed
+ if line =~ g:vimwiki_rxComment
+ let processed = 1
+ endif
+ endif
+
+ " nohtml -- placeholder
+ if !processed
+ if line =~ '^\s*%nohtml'
+ let processed = 1
+ let state.placeholder = ['nohtml']
+ endif
+ endif
+
+ " title -- placeholder
+ if !processed
+ if line =~ '^\s*%title'
+ let processed = 1
+ let param = matchstr(line, '^\s*%title\s\zs.*')
+ let state.placeholder = ['title', param]
+ endif
+ endif
+
+ " html template -- placeholder "{{{
+ if !processed
+ if line =~ '^\s*%template'
+ let processed = 1
+ let param = matchstr(line, '^\s*%template\s\zs.*')
+ let state.placeholder = ['template', param]
+ endif
+ endif
+ "}}}
+
+ " toc -- placeholder "{{{
+ if !processed
+ if line =~ '^\s*%toc'
+ let processed = 1
+ let param = matchstr(line, '^\s*%toc\s\zs.*')
+ let state.placeholder = ['toc', param]
+ endif
+ endif
+ "}}}
+
+ " pres "{{{
+ if !processed
+ let [processed, lines, state.pre] = s:process_tag_pre(line, state.pre)
+ " pre is just fine to be in the list -- do not close list item here.
+ " if processed && len(state.lists)
+ " call s:close_tag_list(state.lists, lines)
+ " endif
+ if !processed
+ let [processed, lines, state.math] = s:process_tag_math(line, state.math)
+ endif
+ if processed && len(state.table)
+ let state.table = s:close_tag_table(state.table, lines)
+ endif
+ if processed && state.deflist
+ let state.deflist = s:close_tag_def_list(state.deflist, lines)
+ endif
+ if processed && state.quote
+ let state.quote = s:close_tag_quote(state.quote, lines)
+ endif
+ if processed && state.para
+ let state.para = s:close_tag_para(state.para, lines)
+ endif
+ call extend(res_lines, lines)
+ endif
+ "}}}
+
+ " lists "{{{
+ if !processed
+ let [processed, lines] = s:process_tag_list(line, state.lists)
+ if processed && state.quote
+ let state.quote = s:close_tag_quote(state.quote, lines)
+ endif
+ if processed && state.pre[0]
+ let state.pre = s:close_tag_pre(state.pre, lines)
+ endif
+ if processed && state.math[0]
+ let state.math = s:close_tag_math(state.math, lines)
+ endif
+ if processed && len(state.table)
+ let state.table = s:close_tag_table(state.table, lines)
+ endif
+ if processed && state.deflist
+ let state.deflist = s:close_tag_def_list(state.deflist, lines)
+ endif
+ if processed && state.para
+ let state.para = s:close_tag_para(state.para, lines)
+ endif
+
+ call map(lines, 's:process_inline_tags(v:val)')
+
+ call extend(res_lines, lines)
+ endif
+ "}}}
+
+ " headers "{{{
+ if !processed
+ let [processed, line, h_level, h_text, h_id] = s:process_tag_h(line, state.toc_id)
+ if processed
+ call s:close_tag_list(state.lists, res_lines)
+ let state.table = s:close_tag_table(state.table, res_lines)
+ let state.pre = s:close_tag_pre(state.pre, res_lines)
+ let state.math = s:close_tag_math(state.math, res_lines)
+ let state.quote = s:close_tag_quote(state.quote, res_lines)
+ let state.para = s:close_tag_para(state.para, res_lines)
+
+ let line = s:process_inline_tags(line)
+
+ call add(res_lines, line)
+
+ " gather information for table of contents
+ call add(state.toc, [h_level, h_text, h_id])
+ endif
+ endif
+ "}}}
+
+ " tables "{{{
+ if !processed
+ let [processed, lines, state.table] = s:process_tag_table(line, state.table)
+ call extend(res_lines, lines)
+ endif
+ "}}}
+
+ " quotes "{{{
+ if !processed
+ let [processed, lines, state.quote] = s:process_tag_quote(line, state.quote)
+ if processed && len(state.lists)
+ call s:close_tag_list(state.lists, lines)
+ endif
+ if processed && state.deflist
+ let state.deflist = s:close_tag_def_list(state.deflist, lines)
+ endif
+ if processed && len(state.table)
+ let state.table = s:close_tag_table(state.table, lines)
+ endif
+ if processed && state.pre[0]
+ let state.pre = s:close_tag_pre(state.pre, lines)
+ endif
+ if processed && state.math[0]
+ let state.math = s:close_tag_math(state.math, lines)
+ endif
+ if processed && state.para
+ let state.para = s:close_tag_para(state.para, lines)
+ endif
+
+ call map(lines, 's:process_inline_tags(v:val)')
+
+ call extend(res_lines, lines)
+ endif
+ "}}}
+
+ " horizontal rules "{{{
+ if !processed
+ let [processed, line] = s:process_tag_hr(line)
+ if processed
+ call s:close_tag_list(state.lists, res_lines)
+ let state.table = s:close_tag_table(state.table, res_lines)
+ let state.pre = s:close_tag_pre(state.pre, res_lines)
+ let state.math = s:close_tag_math(state.math, res_lines)
+ call add(res_lines, line)
+ endif
+ endif
+ "}}}
+
+ " definition lists "{{{
+ if !processed
+ let [processed, lines, state.deflist] = s:process_tag_def_list(line, state.deflist)
+
+ call map(lines, 's:process_inline_tags(v:val)')
+
+ call extend(res_lines, lines)
+ endif
+ "}}}
+
+ "" P "{{{
+ if !processed
+ let [processed, lines, state.para] = s:process_tag_para(line, state.para)
+ if processed && len(state.lists)
+ call s:close_tag_list(state.lists, lines)
+ endif
+ if processed && state.quote
+ let state.quote = s:close_tag_quote(state.quote, res_lines)
+ endif
+ if processed && state.pre[0]
+ let state.pre = s:close_tag_pre(state.pre, res_lines)
+ endif
+ if processed && state.math[0]
+ let state.math = s:close_tag_math(state.math, res_lines)
+ endif
+ if processed && len(state.table)
+ let state.table = s:close_tag_table(state.table, res_lines)
+ endif
+
+ call map(lines, 's:process_inline_tags(v:val)')
+
+ call extend(res_lines, lines)
+ endif
+ "}}}
+
+ "" add the rest
+ if !processed
+ call add(res_lines, line)
+ endif
+
+ return [res_lines, state]
+
+endfunction " }}}
+
+function! s:use_custom_wiki2html() "{{{
+ let custom_wiki2html = VimwikiGet('custom_wiki2html')
+ return !empty(custom_wiki2html) && s:file_exists(custom_wiki2html)
+endfunction " }}}
+
+function! vimwiki#html#CustomWiki2HTML(path, wikifile, force) "{{{
+ call vimwiki#base#mkdir(a:path)
+ echomsg system(VimwikiGet('custom_wiki2html'). ' '.
+ \ a:force. ' '.
+ \ VimwikiGet('syntax'). ' '.
+ \ strpart(VimwikiGet('ext'), 1). ' '.
+ \ 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) "{{{
+
+ let starttime = reltime() " start the clock
+
+ let done = 0
+
+ let wikifile = fnamemodify(a:wikifile, ":p")
+
+ let path_html = expand(a:path_html).VimwikiGet('subdir')
+ let htmlfile = fnamemodify(wikifile, ":t:r").'.html'
+
+ if s:use_custom_wiki2html()
+ let force = 1
+ call vimwiki#html#CustomWiki2HTML(path_html, wikifile, force)
+ let done = 1
+ endif
+
+ if s:syntax_supported() && done == 0
+ let lsource = readfile(wikifile)
+ let ldest = []
+
+ "if g:vimwiki_debug
+ " echo 'Generating HTML ... '
+ "endif
+
+ call vimwiki#base#mkdir(path_html)
+
+ " nohtml placeholder -- to skip html generation.
+ let nohtml = 0
+
+ " template placeholder
+ let template_name = ''
+
+ " for table of contents placeholders.
+ let placeholders = []
+
+ " current state of converter
+ let state = {}
+ let state.para = 0
+ let state.quote = 0
+ let state.pre = [0, 0] " [in_pre, indent_pre]
+ let state.math = [0, 0] " [in_math, indent_math]
+ let state.table = []
+ let state.deflist = 0
+ let state.lists = []
+ let state.placeholder = []
+ let state.toc = []
+ let state.toc_id = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0 }
+
+ " prepare constants for s:safe_html()
+ let s:lt_pattern = '<'
+ 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 = '\c<\%(/\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?>\)\@!'
+ let s:gt_pattern = '\c\%(\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?\)\@'
+ endif
+
+ for line in lsource
+ let oldquote = state.quote
+ let [lines, state] = s:parse_line(line, state)
+
+ " Hack: There could be a lot of empty strings before s:process_tag_quote
+ " find out `quote` is over. So we should delete them all. Think of the way
+ " to refactor it out.
+ if oldquote != state.quote
+ call s:remove_blank_lines(ldest)
+ endif
+
+ if !empty(state.placeholder)
+ if state.placeholder[0] == 'nohtml'
+ let nohtml = 1
+ break
+ elseif state.placeholder[0] == 'template'
+ let template_name = state.placeholder[1]
+ else
+ call add(placeholders, [state.placeholder, len(ldest), len(placeholders)])
+ endif
+ let state.placeholder = []
+ endif
+
+ call extend(ldest, lines)
+ endfor
+
+
+ if nohtml
+ echon "\r"."%nohtml placeholder found"
+ return
+ endif
+
+ let toc = s:get_html_toc(state.toc)
+ call s:process_toc(ldest, placeholders, toc)
+ call s:remove_blank_lines(ldest)
+
+ "" process end of file
+ "" close opened tags if any
+ let lines = []
+ call s:close_tag_quote(state.quote, lines)
+ call s:close_tag_para(state.para, lines)
+ call s:close_tag_pre(state.pre, lines)
+ call s:close_tag_math(state.math, lines)
+ call s:close_tag_list(state.lists, lines)
+ call s:close_tag_def_list(state.deflist, lines)
+ call s:close_tag_table(state.table, lines)
+ call extend(ldest, lines)
+
+ let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r"))
+
+ let html_lines = s:get_html_template(a:wikifile, template_name)
+
+ " processing template variables (refactor to a function)
+ call map(html_lines, 'substitute(v:val, "%title%", "'. title .'", "g")')
+ call map(html_lines, 'substitute(v:val, "%root_path%", "'.
+ \ s:root_path(VimwikiGet('subdir')) .'", "g")')
+
+ let css_name = expand(VimwikiGet('css_name'))
+ let css_name = substitute(css_name, '\', '/', 'g')
+ call map(html_lines, 'substitute(v:val, "%css%", "'. css_name .'", "g")')
+
+ let enc = &fileencoding
+ if enc == ''
+ let enc = &encoding
+ endif
+ call map(html_lines, 'substitute(v:val, "%encoding%", "'. enc .'", "g")')
+
+ let html_lines = s:html_insert_contents(html_lines, ldest) " %contents%
+
+ "" make html file.
+ call writefile(html_lines, path_html.htmlfile)
+ let done = 1
+
+ endif
+
+ if done == 0
+ echomsg 'vimwiki: conversion to HTML is not supported for this syntax!!!'
+ return
+ endif
+
+ " measure the elapsed time
+ let time1 = vimwiki#u#time(starttime) "XXX
+ call VimwikiLog_extend('html',[htmlfile,time1])
+ "if g:vimwiki_debug
+ " echon "\r".htmlfile.' written (time: '.time1.'s)'
+ "endif
+
+ return path_html.htmlfile
+endfunction "}}}
+
+
+function! vimwiki#html#WikiAll2HTML(path_html) "{{{
+ if !s:syntax_supported() && !s:use_custom_wiki2html()
+ echomsg 'vimwiki: conversion to HTML is not supported for this syntax!!!'
+ return
+ endif
+
+ echomsg 'Saving vimwiki files...'
+ let save_eventignore = &eventignore
+ let &eventignore = "all"
+ let cur_buf = bufname('%')
+ bufdo call s:save_vimwiki_buffer()
+ exe 'buffer '.cur_buf
+ let &eventignore = save_eventignore
+
+ let path_html = expand(a:path_html)
+ call vimwiki#base#mkdir(path_html)
+
+ echomsg 'Deleting non-wiki html files...'
+ call s:delete_html_files(path_html)
+
+ echomsg 'Converting wiki to html files...'
+ let setting_more = &more
+ setlocal nomore
+
+ " temporarily adjust current_subdir global state variable
+ let current_subdir = VimwikiGet('subdir')
+ let current_invsubdir = VimwikiGet('invsubdir')
+
+ let wikifiles = split(glob(VimwikiGet('path').'**/*'.VimwikiGet('ext')), '\n')
+ for wikifile in wikifiles
+ let wikifile = fnamemodify(wikifile, ":p")
+
+ " temporarily adjust 'subdir' and 'invsubdir' state variables
+ let subdir = vimwiki#base#subdir(VimwikiGet('path'), wikifile)
+ call VimwikiSet('subdir', subdir)
+ call VimwikiSet('invsubdir', vimwiki#base#invsubdir(subdir))
+
+ if !s:is_html_uptodate(wikifile)
+ echomsg 'Processing '.wikifile
+
+ call vimwiki#html#Wiki2HTML(path_html, wikifile)
+ else
+ echomsg 'Skipping '.wikifile
+ endif
+ endfor
+ " reset 'subdir' state variable
+ call VimwikiSet('subdir', current_subdir)
+ call VimwikiSet('invsubdir', current_invsubdir)
+
+ call s:create_default_CSS(path_html)
+ echomsg 'Done!'
+
+ let &more = setting_more
+endfunction "}}}
+
+function! s:file_exists(fname) "{{{
+ return !empty(getftype(expand(a:fname)))
+endfunction "}}}
+
+" uses VimwikiGet('path')
+function! vimwiki#html#get_wikifile_url(wikifile) "{{{
+ return VimwikiGet('path_html').
+ \ vimwiki#base#subdir(VimwikiGet('path'), a:wikifile).
+ \ fnamemodify(a:wikifile, ":t:r").'.html'
+endfunction "}}}
+
+function! vimwiki#html#PasteUrl(wikifile) "{{{
+ execute 'r !echo file://'.vimwiki#html#get_wikifile_url(a:wikifile)
+endfunction "}}}
+
+function! vimwiki#html#CatUrl(wikifile) "{{{
+ execute '!echo file://'.vimwiki#html#get_wikifile_url(a:wikifile)
+endfunction "}}}
+"}}}
diff --git a/bash/.vim/autoload/vimwiki/lst.vim b/bash/.vim/autoload/vimwiki/lst.vim
new file mode 100644
index 0000000..7d42517
--- /dev/null
+++ b/bash/.vim/autoload/vimwiki/lst.vim
@@ -0,0 +1,555 @@
+" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
+" Vimwiki autoload plugin file
+" Todo lists related stuff here.
+" Author: Maxim Kim
+" Home: http://code.google.com/p/vimwiki/
+
+if exists("g:loaded_vimwiki_list_auto") || &cp
+ finish
+endif
+let g:loaded_vimwiki_lst_auto = 1
+
+" Script variables {{{
+let s:rx_li_box = '\[.\?\]'
+" }}}
+
+" Script functions {{{
+
+" Get unicode string symbol at index
+function! s:str_idx(str, idx) "{{{
+ " Unfortunatly vimscript cannot get symbol at index in unicode string such as
+ " '✗○◐●✓'
+ return matchstr(a:str, '\%'.a:idx.'v.')
+endfunction "}}}
+
+" Get checkbox regexp
+function! s:rx_li_symbol(rate) "{{{
+ let result = ''
+ if a:rate == 100
+ let result = s:str_idx(g:vimwiki_listsyms, 5)
+ elseif a:rate == 0
+ let result = s:str_idx(g:vimwiki_listsyms, 1)
+ elseif a:rate >= 67
+ let result = s:str_idx(g:vimwiki_listsyms, 4)
+ elseif a:rate >= 34
+ let result = s:str_idx(g:vimwiki_listsyms, 3)
+ else
+ let result = s:str_idx(g:vimwiki_listsyms, 2)
+ endif
+
+ return '\['.result.'\]'
+endfunction "}}}
+
+" Get blank checkbox
+function! s:blank_checkbox() "{{{
+ return '['.s:str_idx(g:vimwiki_listsyms, 1).'] '
+endfunction "}}}
+
+" Get regexp of the list item.
+function! s:rx_list_item() "{{{
+ return '\('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)'
+endfunction "}}}
+
+" Get regexp of the list item with checkbox.
+function! s:rx_cb_list_item() "{{{
+ return s:rx_list_item().'\s*\zs\[.\?\]'
+endfunction "}}}
+
+" Get level of the list item.
+function! s:get_level(lnum) "{{{
+ if VimwikiGet('syntax') == 'media'
+ let level = vimwiki#u#count_first_sym(getline(a:lnum))
+ else
+ let level = indent(a:lnum)
+ endif
+ return level
+endfunction "}}}
+
+" Get previous list item.
+" Returns: line number or 0.
+function! s:prev_list_item(lnum) "{{{
+ let c_lnum = a:lnum - 1
+ while c_lnum >= 1
+ let line = getline(c_lnum)
+ if line =~ s:rx_list_item()
+ return c_lnum
+ endif
+ if line =~ '^\s*$'
+ return 0
+ endif
+ let c_lnum -= 1
+ endwhile
+ return 0
+endfunction "}}}
+
+" Get next list item in the list.
+" Returns: line number or 0.
+function! s:next_list_item(lnum) "{{{
+ let c_lnum = a:lnum + 1
+ while c_lnum <= line('$')
+ let line = getline(c_lnum)
+ if line =~ s:rx_list_item()
+ return c_lnum
+ endif
+ if line =~ '^\s*$'
+ return 0
+ endif
+ let c_lnum += 1
+ endwhile
+ return 0
+endfunction "}}}
+
+" Find next list item in the buffer.
+" Returns: line number or 0.
+function! s:find_next_list_item(lnum) "{{{
+ let c_lnum = a:lnum + 1
+ while c_lnum <= line('$')
+ let line = getline(c_lnum)
+ if line =~ s:rx_list_item()
+ return c_lnum
+ endif
+ let c_lnum += 1
+ endwhile
+ return 0
+endfunction "}}}
+
+" Set state of the list item on line number "lnum" to [ ] or [x]
+function! s:set_state(lnum, rate) "{{{
+ let line = getline(a:lnum)
+ let state = s:rx_li_symbol(a:rate)
+ let line = substitute(line, s:rx_li_box, state, '')
+ call setline(a:lnum, line)
+endfunction "}}}
+
+" Get state of the list item on line number "lnum"
+function! s:get_state(lnum) "{{{
+ let state = 0
+ let line = getline(a:lnum)
+ let opt = matchstr(line, s:rx_cb_list_item())
+ if opt =~ s:rx_li_symbol(100)
+ let state = 100
+ elseif opt =~ s:rx_li_symbol(0)
+ let state = 0
+ elseif opt =~ s:rx_li_symbol(25)
+ let state = 25
+ elseif opt =~ s:rx_li_symbol(50)
+ let state = 50
+ elseif opt =~ s:rx_li_symbol(75)
+ let state = 75
+ endif
+ return state
+endfunction "}}}
+
+" Returns 1 if there is checkbox on a list item, 0 otherwise.
+function! s:is_cb_list_item(lnum) "{{{
+ return getline(a:lnum) =~ s:rx_cb_list_item()
+endfunction "}}}
+
+" Returns start line number of list item, 0 if it is not a list.
+function! s:is_list_item(lnum) "{{{
+ let c_lnum = a:lnum
+ while c_lnum >= 1
+ let line = getline(c_lnum)
+ if line =~ s:rx_list_item()
+ return c_lnum
+ endif
+ if line =~ '^\s*$'
+ return 0
+ endif
+ if indent(c_lnum) > indent(a:lnum)
+ return 0
+ endif
+ let c_lnum -= 1
+ endwhile
+ return 0
+endfunction "}}}
+
+" Returns char column of checkbox. Used in parent/child checks.
+function! s:get_li_pos(lnum) "{{{
+ return stridx(getline(a:lnum), '[')
+endfunction "}}}
+
+" Returns list of line numbers of parent and all its child items.
+function! s:get_child_items(lnum) "{{{
+ let result = []
+ let lnum = a:lnum
+ let p_pos = s:get_level(lnum)
+
+ " add parent
+ call add(result, lnum)
+
+ let lnum = s:next_list_item(lnum)
+ while lnum != 0 && s:is_list_item(lnum) && s:get_level(lnum) > p_pos
+ call add(result, lnum)
+ let lnum = s:next_list_item(lnum)
+ endwhile
+
+ return result
+endfunction "}}}
+
+" Returns list of line numbers of all items of the same level.
+function! s:get_sibling_items(lnum) "{{{
+ let result = []
+ let lnum = a:lnum
+ let ind = s:get_level(lnum)
+
+ while lnum != 0 && s:get_level(lnum) >= ind
+ if s:get_level(lnum) == ind && s:is_cb_list_item(lnum)
+ call add(result, lnum)
+ endif
+ let lnum = s:next_list_item(lnum)
+ endwhile
+
+ let lnum = s:prev_list_item(a:lnum)
+ while lnum != 0 && s:get_level(lnum) >= ind
+ if s:get_level(lnum) == ind && s:is_cb_list_item(lnum)
+ call add(result, lnum)
+ endif
+ let lnum = s:prev_list_item(lnum)
+ endwhile
+
+ return result
+endfunction "}}}
+
+" Returns line number of the parent of lnum item
+function! s:get_parent_item(lnum) "{{{
+ let lnum = a:lnum
+ let ind = s:get_level(lnum)
+
+ let lnum = s:prev_list_item(lnum)
+ while lnum != 0 && s:is_list_item(lnum) && s:get_level(lnum) >= ind
+ let lnum = s:prev_list_item(lnum)
+ endwhile
+
+ if s:is_cb_list_item(lnum)
+ return lnum
+ else
+ return a:lnum
+ endif
+endfunction "}}}
+
+" Creates checkbox in a list item.
+function! s:create_cb_list_item(lnum) "{{{
+ let line = getline(a:lnum)
+ let m = matchstr(line, s:rx_list_item())
+ if m != ''
+ let li_content = substitute(strpart(line, len(m)), '^\s*', '', '')
+ let line = substitute(m, '\s*$', ' ', '').s:blank_checkbox().li_content
+ call setline(a:lnum, line)
+ endif
+endfunction "}}}
+
+" Tells if all of the sibling list items are checked or not.
+function! s:all_siblings_checked(lnum) "{{{
+ let result = 0
+ let cnt = 0
+ let siblings = s:get_sibling_items(a:lnum)
+ for lnum in siblings
+ let cnt += s:get_state(lnum)
+ endfor
+ let result = cnt/len(siblings)
+ return result
+endfunction "}}}
+
+" Creates checkbox on a list item if there is no one.
+function! s:TLI_create_checkbox(lnum) "{{{
+ if a:lnum && !s:is_cb_list_item(a:lnum)
+ if g:vimwiki_auto_checkbox
+ call s:create_cb_list_item(a:lnum)
+ endif
+ return 1
+ endif
+ return 0
+endfunction "}}}
+
+" Switch state of the child list items.
+function! s:TLI_switch_child_state(lnum) "{{{
+ let current_state = s:get_state(a:lnum)
+ if current_state == 100
+ let new_state = 0
+ else
+ let new_state = 100
+ endif
+ for lnum in s:get_child_items(a:lnum)
+ call s:set_state(lnum, new_state)
+ endfor
+endfunction "}}}
+
+" Switch state of the parent list items.
+function! s:TLI_switch_parent_state(lnum) "{{{
+ let c_lnum = a:lnum
+ while s:is_cb_list_item(c_lnum)
+ let parent_lnum = s:get_parent_item(c_lnum)
+ if parent_lnum == c_lnum
+ break
+ endif
+ call s:set_state(parent_lnum, s:all_siblings_checked(c_lnum))
+
+ let c_lnum = parent_lnum
+ endwhile
+endfunction "}}}
+
+function! s:TLI_toggle(lnum) "{{{
+ if !s:TLI_create_checkbox(a:lnum)
+ call s:TLI_switch_child_state(a:lnum)
+ endif
+ call s:TLI_switch_parent_state(a:lnum)
+endfunction "}}}
+
+" Script functions }}}
+
+" Toggle list item between [ ] and [X]
+function! vimwiki#lst#ToggleListItem(line1, line2) "{{{
+ let line1 = a:line1
+ let line2 = a:line2
+
+ if line1 != line2 && !s:is_list_item(line1)
+ let line1 = s:find_next_list_item(line1)
+ endif
+
+ let c_lnum = line1
+ while c_lnum != 0 && c_lnum <= line2
+ let li_lnum = s:is_list_item(c_lnum)
+
+ if li_lnum
+ let li_level = s:get_level(li_lnum)
+ if c_lnum == line1
+ let start_li_level = li_level
+ endif
+
+ if li_level <= start_li_level
+ call s:TLI_toggle(li_lnum)
+ let start_li_level = li_level
+ endif
+ endif
+
+ let c_lnum = s:find_next_list_item(c_lnum)
+ endwhile
+
+endfunction "}}}
+
+function! vimwiki#lst#kbd_cr() "{{{
+ " This function is heavily relies on proper 'set comments' option.
+ let cr = "\"
+ if getline('.') =~ s:rx_cb_list_item()
+ let cr .= s:blank_checkbox()
+ endif
+ return cr
+endfunction "}}}
+
+function! vimwiki#lst#kbd_oO(cmd) "{{{
+ " cmd should be 'o' or 'O'
+
+ let l:count = v:count1
+ while l:count > 0
+
+ let beg_lnum = foldclosed('.')
+ let end_lnum = foldclosedend('.')
+ if end_lnum != -1 && a:cmd ==# 'o'
+ let lnum = end_lnum
+ let line = getline(beg_lnum)
+ else
+ let line = getline('.')
+ let lnum = line('.')
+ endif
+
+ let m = matchstr(line, s:rx_list_item())
+ let res = ''
+ if line =~ s:rx_cb_list_item()
+ let res = substitute(m, '\s*$', ' ', '').s:blank_checkbox()
+ elseif line =~ s:rx_list_item()
+ let res = substitute(m, '\s*$', ' ', '')
+ elseif &autoindent || &smartindent
+ let res = matchstr(line, '^\s*')
+ endif
+
+ if a:cmd ==# 'o'
+ call append(lnum, res)
+ call cursor(lnum + 1, col('$'))
+ else
+ call append(lnum - 1, res)
+ call cursor(lnum, col('$'))
+ endif
+
+ let l:count -= 1
+ endwhile
+
+ startinsert!
+
+endfunction "}}}
+
+function! vimwiki#lst#default_symbol() "{{{
+ " TODO: initialize default symbol from syntax/vimwiki_xxx.vim
+ if VimwikiGet('syntax') == 'default'
+ return '-'
+ else
+ return '*'
+ endif
+endfunction "}}}
+
+function vimwiki#lst#get_list_margin() "{{{
+ if VimwikiGet('list_margin') < 0
+ return &sw
+ else
+ return VimwikiGet('list_margin')
+ endif
+endfunction "}}}
+
+function s:get_list_sw() "{{{
+ if VimwikiGet('syntax') == 'media'
+ return 1
+ else
+ return &sw
+ endif
+endfunction "}}}
+
+function s:get_list_nesting_level(lnum) "{{{
+ if VimwikiGet('syntax') == 'media'
+ if getline(a:lnum) !~ s:rx_list_item()
+ let level = 0
+ else
+ let level = vimwiki#u#count_first_sym(getline(a:lnum)) - 1
+ let level = level < 0 ? 0 : level
+ endif
+ else
+ let level = indent(a:lnum)
+ endif
+ return level
+endfunction "}}}
+
+function s:get_list_indent(lnum) "{{{
+ if VimwikiGet('syntax') == 'media'
+ return indent(a:lnum)
+ else
+ return 0
+ endif
+endfunction "}}}
+
+function! s:compose_list_item(n_indent, n_nesting, sym_nest, sym_bullet, li_content, ...) "{{{
+ if a:0
+ let sep = a:1
+ else
+ let sep = ''
+ endif
+ let li_indent = repeat(' ', max([0,a:n_indent])).sep
+ let li_nesting = repeat(a:sym_nest, max([0,a:n_nesting])).sep
+ if len(a:sym_bullet) > 0
+ let li_bullet = a:sym_bullet.' '.sep
+ else
+ let li_bullet = ''.sep
+ endif
+ return li_indent.li_nesting.li_bullet.a:li_content
+endfunction "}}}
+
+function s:compose_cb_bullet(prev_cb_bullet, sym) "{{{
+ return a:sym.matchstr(a:prev_cb_bullet, '\S*\zs\s\+.*')
+endfunction "}}}
+
+function! vimwiki#lst#change_level(...) "{{{
+ let default_sym = vimwiki#lst#default_symbol()
+ let cmd = '>>'
+ let sym = default_sym
+
+ " parse argument
+ if a:0
+ if a:1 != '<<' && a:1 != '>>'
+ let cmd = '--'
+ let sym = a:1
+ else
+ let cmd = a:1
+ endif
+ endif
+ " is symbol valid
+ if sym.' ' !~ s:rx_cb_list_item() && sym.' ' !~ s:rx_list_item()
+ return
+ endif
+
+ " parsing setup
+ let lnum = line('.')
+ let line = getline('.')
+
+ let list_margin = vimwiki#lst#get_list_margin()
+ let list_sw = s:get_list_sw()
+ let n_nesting = s:get_list_nesting_level(lnum)
+ let n_indent = s:get_list_indent(lnum)
+
+ " remove indent and nesting
+ let li_bullet_and_content = strpart(line, n_nesting + n_indent)
+
+ " list bullet and checkbox
+ let cb_bullet = matchstr(li_bullet_and_content, s:rx_list_item()).
+ \ matchstr(li_bullet_and_content, s:rx_cb_list_item())
+
+ " XXX: it could be not unicode proof --> if checkboxes are set up with unicode syms
+ " content
+ let li_content = strpart(li_bullet_and_content, len(cb_bullet))
+
+ " trim
+ let cb_bullet = vimwiki#u#trim(cb_bullet)
+ let li_content = vimwiki#u#trim(li_content)
+
+ " nesting symbol
+ if VimwikiGet('syntax') == 'media'
+ if len(cb_bullet) > 0
+ let sym_nest = cb_bullet[0]
+ else
+ let sym_nest = sym
+ endif
+ else
+ let sym_nest = ' '
+ endif
+
+ if g:vimwiki_debug
+ echomsg "PARSE: Sw [".list_sw."]"
+ echomsg s:compose_list_item(n_indent, n_nesting, sym_nest, cb_bullet, li_content, '|')
+ endif
+
+ " change level
+ if cmd == '--'
+ let cb_bullet = s:compose_cb_bullet(cb_bullet, sym)
+ if VimwikiGet('syntax') == 'media'
+ let sym_nest = sym
+ endif
+ elseif cmd == '>>'
+ if cb_bullet == ''
+ let cb_bullet = sym
+ else
+ let n_nesting = n_nesting + list_sw
+ endif
+ elseif cmd == '<<'
+ let n_nesting = n_nesting - list_sw
+ if VimwikiGet('syntax') == 'media'
+ if n_nesting < 0
+ let cb_bullet = ''
+ endif
+ else
+ if n_nesting < list_margin
+ let cb_bullet = ''
+ endif
+ endif
+ endif
+
+ let n_nesting = max([0, n_nesting])
+
+ if g:vimwiki_debug
+ echomsg "SHIFT:"
+ echomsg s:compose_list_item(n_indent, n_nesting, sym_nest, cb_bullet, li_content, '|')
+ endif
+
+ " XXX: this is the code that adds the initial indent
+ let add_nesting = VimwikiGet('syntax') != 'media'
+ if n_indent + n_nesting*(add_nesting) < list_margin
+ let n_indent = list_margin - n_nesting*(add_nesting)
+ endif
+
+ if g:vimwiki_debug
+ echomsg "INDENT:"
+ echomsg s:compose_list_item(n_indent, n_nesting, sym_nest, cb_bullet, li_content, '|')
+ endif
+
+ let line = s:compose_list_item(n_indent, n_nesting, sym_nest, cb_bullet, li_content)
+
+ " replace
+ call setline(lnum, line)
+ call cursor(lnum, match(line, '\S') + 1)
+endfunction "}}}
diff --git a/bash/.vim/autoload/vimwiki/markdown_base.vim b/bash/.vim/autoload/vimwiki/markdown_base.vim
new file mode 100644
index 0000000..7656658
--- /dev/null
+++ b/bash/.vim/autoload/vimwiki/markdown_base.vim
@@ -0,0 +1,302 @@
+" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
+" Vimwiki autoload plugin file
+" Desc: Link functions for markdown syntax
+" Author: Stuart Andrews (.. i.e. don't blame Maxim!)
+" Home: http://code.google.com/p/vimwiki/
+
+
+" MISC helper functions {{{
+
+" vimwiki#markdown_base#reset_mkd_refs
+function! vimwiki#markdown_base#reset_mkd_refs() "{{{
+ call VimwikiClear('markdown_refs')
+endfunction "}}}
+
+" vimwiki#markdown_base#scan_reflinks
+function! vimwiki#markdown_base#scan_reflinks() " {{{
+ let mkd_refs = {}
+ " construct list of references using vimgrep
+ try
+ execute 'vimgrep #'.g:vimwiki_rxMkdRef.'#j %'
+ catch /^Vim\%((\a\+)\)\=:E480/ " No Match
+ "Ignore it, and move on to the next file
+ endtry
+ "
+ for d in getqflist()
+ let matchline = join(getline(d.lnum, min([d.lnum+1, line('$')])), ' ')
+ let descr = matchstr(matchline, g:vimwiki_rxMkdRefMatchDescr)
+ let url = matchstr(matchline, g:vimwiki_rxMkdRefMatchUrl)
+ if descr != '' && url != ''
+ let mkd_refs[descr] = url
+ endif
+ endfor
+ call VimwikiSet('markdown_refs', mkd_refs)
+ return mkd_refs
+endfunction "}}}
+
+
+" vimwiki#markdown_base#get_reflinks
+function! vimwiki#markdown_base#get_reflinks() " {{{
+ let done = 1
+ try
+ let mkd_refs = VimwikiGet('markdown_refs')
+ catch
+ " work-around hack
+ let done = 0
+ " ... the following command does not work inside catch block !?
+ " > let mkd_refs = vimwiki#markdown_base#scan_reflinks()
+ endtry
+ if !done
+ let mkd_refs = vimwiki#markdown_base#scan_reflinks()
+ endif
+ return mkd_refs
+endfunction "}}}
+
+" vimwiki#markdown_base#open_reflink
+" try markdown reference links
+function! vimwiki#markdown_base#open_reflink(link) " {{{
+ " echom "vimwiki#markdown_base#open_reflink"
+ let link = a:link
+ let mkd_refs = vimwiki#markdown_base#get_reflinks()
+ if has_key(mkd_refs, link)
+ let url = mkd_refs[link]
+ call vimwiki#base#system_open_link(url)
+ return 1
+ else
+ return 0
+ endif
+endfunction " }}}
+
+" s:normalize_path
+" s:path_html
+" vimwiki#base#apply_wiki_options
+" vimwiki#base#read_wiki_options
+" vimwiki#base#validate_wiki_options
+" vimwiki#base#setup_buffer_state
+" vimwiki#base#cache_buffer_state
+" vimwiki#base#recall_buffer_state
+" vimwiki#base#print_wiki_state
+" vimwiki#base#mkdir
+" vimwiki#base#file_pattern
+" vimwiki#base#branched_pattern
+" vimwiki#base#subdir
+" vimwiki#base#current_subdir
+" vimwiki#base#invsubdir
+" vimwiki#base#resolve_scheme
+" vimwiki#base#system_open_link
+" vimwiki#base#open_link
+" vimwiki#base#generate_links
+" vimwiki#base#goto
+" vimwiki#base#backlinks
+" vimwiki#base#get_links
+" vimwiki#base#edit_file
+" vimwiki#base#search_word
+" vimwiki#base#matchstr_at_cursor
+" vimwiki#base#replacestr_at_cursor
+" s:print_wiki_list
+" s:update_wiki_link
+" s:update_wiki_links_dir
+" s:tail_name
+" s:update_wiki_links
+" s:get_wiki_buffers
+" s:open_wiki_buffer
+" vimwiki#base#nested_syntax
+" }}}
+
+" WIKI link following functions {{{
+" vimwiki#base#find_next_link
+" vimwiki#base#find_prev_link
+
+" vimwiki#base#follow_link
+function! vimwiki#markdown_base#follow_link(split, ...) "{{{ Parse link at cursor and pass
+ " to VimwikiLinkHandler, or failing that, the default open_link handler
+ " echom "markdown_base#follow_link"
+
+ if 0
+ " Syntax-specific links
+ " XXX: @Stuart: do we still need it?
+ " XXX: @Maxim: most likely! I am still working on a seemless way to
+ " integrate regexp's without complicating syntax/vimwiki.vim
+ else
+ if a:split == "split"
+ let cmd = ":split "
+ elseif a:split == "vsplit"
+ let cmd = ":vsplit "
+ elseif a:split == "tabnew"
+ let cmd = ":tabnew "
+ else
+ let cmd = ":e "
+ endif
+
+ " try WikiLink
+ let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink),
+ \ g:vimwiki_rxWikiLinkMatchUrl)
+ " try WikiIncl
+ if lnk == ""
+ let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl),
+ \ g:vimwiki_rxWikiInclMatchUrl)
+ endif
+ " try Weblink
+ if lnk == ""
+ let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWeblink),
+ \ g:vimwiki_rxWeblinkMatchUrl)
+ endif
+
+ if lnk != ""
+ if !VimwikiLinkHandler(lnk)
+ if !vimwiki#markdown_base#open_reflink(lnk)
+ call vimwiki#base#open_link(cmd, lnk)
+ endif
+ endif
+ return
+ endif
+
+ if a:0 > 0
+ execute "normal! ".a:1
+ else
+ call vimwiki#base#normalize_link(0)
+ endif
+ endif
+
+endfunction " }}}
+
+" vimwiki#base#go_back_link
+" vimwiki#base#goto_index
+" vimwiki#base#delete_link
+" vimwiki#base#rename_link
+" vimwiki#base#ui_select
+
+" TEXT OBJECTS functions {{{
+" vimwiki#base#TO_header
+" vimwiki#base#TO_table_cell
+" vimwiki#base#TO_table_col
+" }}}
+
+" HEADER functions {{{
+" vimwiki#base#AddHeaderLevel
+" vimwiki#base#RemoveHeaderLevel
+"}}}
+
+" LINK functions {{{
+" vimwiki#base#apply_template
+
+" s:clean_url
+" vimwiki#base#normalize_link_helper
+" vimwiki#base#normalize_imagelink_helper
+
+" s:normalize_link_syntax_n
+function! s:normalize_link_syntax_n() " {{{
+ let lnum = line('.')
+
+ " try WikiIncl
+ let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl)
+ if !empty(lnk)
+ " NO-OP !!
+ if g:vimwiki_debug > 1
+ echomsg "WikiIncl: ".lnk." Sub: ".lnk
+ endif
+ return
+ endif
+
+ " try WikiLink0: replace with WikiLink1
+ let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink0)
+ if !empty(lnk)
+ let sub = vimwiki#base#normalize_link_helper(lnk,
+ \ g:vimwiki_rxWikiLinkMatchUrl, g:vimwiki_rxWikiLinkMatchDescr,
+ \ g:vimwiki_WikiLink1Template2)
+ call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWikiLink0, sub)
+ if g:vimwiki_debug > 1
+ echomsg "WikiLink: ".lnk." Sub: ".sub
+ endif
+ return
+ endif
+
+ " try WikiLink1: replace with WikiLink0
+ let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink1)
+ if !empty(lnk)
+ let sub = vimwiki#base#normalize_link_helper(lnk,
+ \ g:vimwiki_rxWikiLinkMatchUrl, g:vimwiki_rxWikiLinkMatchDescr,
+ \ g:vimwiki_WikiLinkTemplate2)
+ call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWikiLink1, sub)
+ if g:vimwiki_debug > 1
+ echomsg "WikiLink: ".lnk." Sub: ".sub
+ endif
+ return
+ endif
+
+ " try Weblink
+ let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWeblink)
+ if !empty(lnk)
+ let sub = vimwiki#base#normalize_link_helper(lnk,
+ \ g:vimwiki_rxWeblinkMatchUrl, g:vimwiki_rxWeblinkMatchDescr,
+ \ g:vimwiki_Weblink1Template)
+ call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWeblink, sub)
+ if g:vimwiki_debug > 1
+ echomsg "WebLink: ".lnk." Sub: ".sub
+ endif
+ return
+ endif
+
+ " try Word (any characters except separators)
+ " rxWord is less permissive than rxWikiLinkUrl which is used in
+ " normalize_link_syntax_v
+ let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWord)
+ if !empty(lnk)
+ let sub = vimwiki#base#normalize_link_helper(lnk,
+ \ g:vimwiki_rxWord, '',
+ \ g:vimwiki_WikiLinkTemplate1)
+ call vimwiki#base#replacestr_at_cursor('\V'.lnk, sub)
+ if g:vimwiki_debug > 1
+ echomsg "Word: ".lnk." Sub: ".sub
+ endif
+ return
+ endif
+
+endfunction " }}}
+
+" s:normalize_link_syntax_v
+function! s:normalize_link_syntax_v() " {{{
+ let lnum = line('.')
+ let sel_save = &selection
+ let &selection = "old"
+ let rv = @"
+ let rt = getregtype('"')
+ let done = 0
+
+ try
+ norm! gvy
+ let visual_selection = @"
+ let visual_selection = substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', '\='."'".visual_selection."'", '')
+
+ call setreg('"', visual_selection, 'v')
+
+ " paste result
+ norm! `>pgvd
+
+ finally
+ call setreg('"', rv, rt)
+ let &selection = sel_save
+ endtry
+
+endfunction " }}}
+
+" vimwiki#base#normalize_link
+function! vimwiki#markdown_base#normalize_link(is_visual_mode) "{{{
+ if 0
+ " Syntax-specific links
+ else
+ if !a:is_visual_mode
+ call s:normalize_link_syntax_n()
+ elseif visualmode() ==# 'v' && line("'<") == line("'>")
+ " action undefined for 'line-wise' or 'multi-line' visual mode selections
+ call s:normalize_link_syntax_v()
+ endif
+ endif
+endfunction "}}}
+
+" }}}
+
+" -------------------------------------------------------------------------
+" Load syntax-specific Wiki functionality
+" -------------------------------------------------------------------------
+
diff --git a/bash/.vim/autoload/vimwiki/style.css b/bash/.vim/autoload/vimwiki/style.css
new file mode 100644
index 0000000..752867b
--- /dev/null
+++ b/bash/.vim/autoload/vimwiki/style.css
@@ -0,0 +1,79 @@
+body {font-family: Tahoma, Geneva, sans-serif; margin: 1em 2em 1em 2em; font-size: 100%; line-height: 130%;}
+h1, h2, h3, h4, h5, h6 {font-family: Trebuchet MS, Helvetica, sans-serif; font-weight: bold; line-height:100%; margin-top: 1.5em; margin-bottom: 0.5em;}
+h1 {font-size: 2.6em; color: #000000;}
+h2 {font-size: 2.2em; color: #404040;}
+h3 {font-size: 1.8em; color: #707070;}
+h4 {font-size: 1.4em; color: #909090;}
+h5 {font-size: 1.3em; color: #989898;}
+h6 {font-size: 1.2em; color: #9c9c9c;}
+p, pre, blockquote, table, ul, ol, dl {margin-top: 1em; margin-bottom: 1em;}
+ul ul, ul ol, ol ol, ol ul {margin-top: 0.5em; margin-bottom: 0.5em;}
+li {margin: 0.3em auto;}
+ul {margin-left: 2em; padding-left: 0.5em;}
+dt {font-weight: bold;}
+img {border: none;}
+pre {border-left: 1px solid #ccc; margin-left: 2em; padding-left: 0.5em;}
+blockquote {padding: 0.4em; background-color: #f6f5eb;}
+th, td {border: 1px solid #ccc; padding: 0.3em;}
+th {background-color: #f0f0f0;}
+hr {border: none; border-top: 1px solid #ccc; width: 100%;}
+del {text-decoration: line-through; color: #777777;}
+.toc li {list-style-type: none;}
+.todo {font-weight: bold; background-color: #f0ece8; color: #a03020;}
+.justleft {text-align: left;}
+.justright {text-align: right;}
+.justcenter {text-align: center;}
+.center {margin-left: auto; margin-right: auto;}
+
+/* classes for items of todo lists */
+.done0 {
+ /* list-style: none; */
+ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAA7SURBVCiR7dMxEgAgCANBI3yVRzF5KxNbW6wsuH7LQ2YKQK1mkswBVERYF5Os3UV3gwd/jF2SkXy66gAZkxS6BniubAAAAABJRU5ErkJggg==);
+ background-repeat: no-repeat;
+ background-position: 0 .2em;
+ margin-left: -2em;
+ padding-left: 1.5em;
+}
+.done1 {
+ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABtSURBVCiR1ZO7DYAwDER9BDmTeZQMFXmUbGYpOjrEryA0wOvO8itOslFrJYAug5BMM4BeSkmjsrv3aVTa8p48Xw1JSkSsWVUFwD05IqS1tmYzk5zzae9jnVVVzGyXb8sALjse+euRkEzu/uirFomVIdDGOLjuAAAAAElFTkSuQmCC);
+ background-repeat: no-repeat;
+ background-position: 0 .15em;
+ margin-left: -2em;
+ padding-left: 1.5em;
+}
+.done2 {
+ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAB1SURBVCiRzdO5DcAgDAVQGxjAYgTvxlDIu1FTIRYAp8qlFISkSH7l5kk+ZIwxKiI2mIyqWoeILYRgZ7GINDOLjnmF3VqklKCUMgTee2DmM661Qs55iI3Zm/1u5h9sm4ig9z4ERHTFzLyd4G4+nFlVrYg8+qoF/c0kdpeMsmcAAAAASUVORK5CYII=);
+ background-repeat: no-repeat;
+ background-position: 0 .15em;
+ margin-left: -2em;
+ padding-left: 1.5em;
+}
+.done3 {
+ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABoSURBVCiR7dOxDcAgDATA/0DtUdiKoZC3YhLkHjkVKF3idJHiztKfvrHZWnOSE8Fx95RJzlprimJVnXktvXeY2S0SEZRSAAAbmxnGGKH2I5T+8VfxPhIReQSuuY3XyYWa3T2p6quvOgGrvSFGlewuUAAAAABJRU5ErkJggg==);
+ background-repeat: no-repeat;
+ background-position: 0 .15em;
+ margin-left: -2em;
+ padding-left: 1.5em;
+}
+.done4 {
+ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAQCAYAAAAbBi9cAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAzgAAAM4BlP6ToAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAIISURBVDiNnZQ9SFtRFMd/773kpTaGJoQk1im4VDpWQcTNODhkFBcVTCNCF0NWyeDiIIiCm82QoIMIUkHUxcFBg1SEQoZszSat6cdTn1qNue92CMbEr9Sey+XC/Z/zu+f8h6ukUil3sVg0+M+4cFxk42/jH2wAqqqKSCSiPQdwcHHAnDHH9s/tN1h8V28ETdP+eU8fT9Nt62ancYdIPvJNtsu87bmjrJlrTDVM4RROJs1JrHPrD4Bar7A6cpc54iKOaTdJXCUI2UMVrQZ0Js7YPN18ECKkYNQcJe/OE/4dZsw7VqNXQMvHy3QZXQypQ6ycrtwDjf8aJ+PNEDSCzLpn7+m2pD8ZKHlKarYhy6XjEoCYGcN95qansQeA3fNdki+SaJZGTMQIOoL3W/Z89rxv+tokubNajlvk/vm+LFpF2XnUKZHI0I+QrI7Dw0OZTqdzUkpsM7mZTyfy5OPGyw1tK7AFSvmB/Ks8w8YwbUYbe6/3QEKv0vugfxWPnMLJun+d/kI/WLdizpNjMbAIKrhMF4OuwadBALqqs+RfInwUvuNi+fBd+wjogfogAFVRmffO02q01mZZ0HHdgXIzdz0QQLPezIQygX6llxNKKgOFARYCC49CqhoHIUTlss/Vx2phlYwjw8j1CAlfAiwQiJpiy7o1VHnsG5FISkoJu7Q/2YmmaV+i0ei7v38L2CBguSi5AAAAAElFTkSuQmCC);
+ background-repeat: no-repeat;
+ background-position: 0 .15em;
+ margin-left: -2em;
+ padding-left: 1.5em;
+}
+
+code {
+ font-family: Monaco,"Courier New","DejaVu Sans Mono","Bitstream Vera Sans Mono",monospace;
+ -webkit-border-radius: 1px;
+ -moz-border-radius: 1px;
+ border-radius: 1px;
+ -moz-background-clip: padding;
+ -webkit-background-clip: padding-box;
+ background-clip: padding-box;
+ padding: 0px 3px;
+ display: inline-block;
+ color: #52595d;
+ border: 1px solid #ccc;
+ background-color: #f9f9f9;
+}
diff --git a/bash/.vim/autoload/vimwiki/tbl.vim b/bash/.vim/autoload/vimwiki/tbl.vim
new file mode 100644
index 0000000..3a8991d
--- /dev/null
+++ b/bash/.vim/autoload/vimwiki/tbl.vim
@@ -0,0 +1,665 @@
+" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
+" Vimwiki autoload plugin file
+" Desc: Tables
+" | Easily | manageable | text | tables | ! |
+" |--------|------------|-------|--------|---------|
+" | Have | fun! | Drink | tea | Period. |
+"
+" Author: Maxim Kim
+" Home: http://code.google.com/p/vimwiki/
+
+" Load only once {{{
+if exists("g:loaded_vimwiki_tbl_auto") || &cp
+ finish
+endif
+let g:loaded_vimwiki_tbl_auto = 1
+"}}}
+
+let s:textwidth = &tw
+
+
+" 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")
+ return strdisplaywidth(a:str)
+ endif
+
+ " get str display width in vim ver < 7.2
+ if !g:vimwiki_CJK_length
+ let ret = strlen(substitute(a:str, '.', 'x', 'g'))
+ else
+ let savemodified = &modified
+ let save_cursor = getpos('.')
+ exe "norm! o\"
+ call setline(line("."), a:str)
+ let ret = virtcol("$") - 1
+ d
+ call setpos('.', save_cursor)
+ let &modified = savemodified
+ endif
+ return ret
+endfunction "}}}
+
+function! s:cell_splitter() "{{{
+ return '\s*'.s:rxSep().'\s*'
+endfunction "}}}
+
+function! s:sep_splitter() "{{{
+ 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*$')
+endfunction "}}}
+
+function! s:is_separator(line) "{{{
+ 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*$'
+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*$'
+
+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())
+endfunction "}}}
+
+function! s:count_separators_up(lnum) "{{{
+ let lnum = a:lnum - 1
+ while lnum > 1
+ if !s:is_separator(getline(lnum))
+ break
+ endif
+ let lnum -= 1
+ endwhile
+
+ return (a:lnum-lnum)
+endfunction "}}}
+
+function! s:count_separators_down(lnum) "{{{
+ let lnum = a:lnum + 1
+ while lnum < line('$')
+ if !s:is_separator(getline(lnum))
+ break
+ endif
+ let lnum += 1
+ endwhile
+
+ return (lnum-a:lnum)
+endfunction "}}}
+
+function! s:create_empty_row(cols) "{{{
+ let row = s:rxSep()
+ let cell = " ".s:rxSep()
+
+ for c in range(a:cols)
+ let row .= cell
+ endfor
+
+ return row
+endfunction "}}}
+
+function! s:create_row_sep(cols) "{{{
+ let row = s:rxSep()
+ let cell = "---".s:rxSep()
+
+ for c in range(a:cols)
+ let row .= cell
+ endfor
+
+ return row
+endfunction "}}}
+
+function! vimwiki#tbl#get_cells(line) "{{{
+ let result = []
+ let cell = ''
+ let quote = ''
+ let state = 'NONE'
+
+ " 'Simple' FSM
+ for idx in range(strlen(a:line))
+ " The only way I know Vim can do Unicode...
+ let ch = a:line[idx]
+ if state == 'NONE'
+ if ch == '|'
+ let state = 'CELL'
+ endif
+ elseif state == 'CELL'
+ if ch == '[' || ch == '{'
+ let state = 'BEFORE_QUOTE_START'
+ let quote = ch
+ elseif ch == '|'
+ call add(result, vimwiki#u#trim(cell))
+ let cell = ""
+ else
+ let cell .= ch
+ endif
+ elseif state == 'BEFORE_QUOTE_START'
+ if ch == '[' || ch == '{'
+ let state = 'QUOTE'
+ let quote .= ch
+ else
+ let state = 'CELL'
+ let cell .= quote.ch
+ let quote = ''
+ endif
+ elseif state == 'QUOTE'
+ if ch == ']' || ch == '}'
+ let state = 'BEFORE_QUOTE_END'
+ endif
+ let quote .= ch
+ elseif state == 'BEFORE_QUOTE_END'
+ if ch == ']' || ch == '}'
+ let state = 'CELL'
+ endif
+ let cell .= quote.ch
+ let quote = ''
+ endif
+ endfor
+
+ if cell.quote != ''
+ call add(result, vimwiki#u#trim(cell.quote, '|'))
+ endif
+ return result
+endfunction "}}}
+
+function! s:col_count(lnum) "{{{
+ return len(vimwiki#tbl#get_cells(getline(a:lnum)))
+endfunction "}}}
+
+function! s:get_indent(lnum) "{{{
+ if !s:is_table(getline(a:lnum))
+ return
+ endif
+
+ let indent = 0
+
+ let lnum = a:lnum - 1
+ while lnum > 1
+ let line = getline(lnum)
+ if !s:is_table(line)
+ let indent = indent(lnum+1)
+ break
+ endif
+ let lnum -= 1
+ endwhile
+
+ return indent
+endfunction " }}}
+
+function! s:get_rows(lnum) "{{{
+ if !s:is_table(getline(a:lnum))
+ return
+ endif
+
+ let upper_rows = []
+ let lower_rows = []
+
+ let lnum = a:lnum - 1
+ while lnum >= 1
+ let line = getline(lnum)
+ if s:is_table(line)
+ call add(upper_rows, [lnum, line])
+ else
+ break
+ endif
+ let lnum -= 1
+ endwhile
+ call reverse(upper_rows)
+
+ let lnum = a:lnum
+ while lnum <= line('$')
+ let line = getline(lnum)
+ if s:is_table(line)
+ call add(lower_rows, [lnum, line])
+ else
+ break
+ endif
+ let lnum += 1
+ endwhile
+
+ return upper_rows + lower_rows
+endfunction "}}}
+
+function! s:get_cell_max_lens(lnum) "{{{
+ let max_lens = {}
+ for [lnum, row] in s:get_rows(a:lnum)
+ if s:is_separator(row)
+ continue
+ endif
+ let cells = vimwiki#tbl#get_cells(row)
+ for idx in range(len(cells))
+ let value = cells[idx]
+ if has_key(max_lens, idx)
+ let max_lens[idx] = max([s:wide_len(value), max_lens[idx]])
+ else
+ let max_lens[idx] = s:wide_len(value)
+ endif
+ endfor
+ endfor
+ return max_lens
+endfunction "}}}
+
+function! s:get_aligned_rows(lnum, col1, col2) "{{{
+ let max_lens = s:get_cell_max_lens(a:lnum)
+ let rows = []
+ for [lnum, row] in s:get_rows(a:lnum)
+ if s:is_separator(row)
+ let new_row = s:fmt_sep(max_lens, a:col1, a:col2)
+ else
+ let new_row = s:fmt_row(row, max_lens, a:col1, a:col2)
+ endif
+ call add(rows, [lnum, new_row])
+ endfor
+ return rows
+endfunction "}}}
+
+" Number of the current column. Starts from 0.
+function! s:cur_column() "{{{
+ let line = getline('.')
+ if !s:is_table(line)
+ return -1
+ endif
+ " TODO: do we need conditional: if s:is_separator(line)
+
+ let curs_pos = col('.')
+ let mpos = match(line, s:rxSep(), 0)
+ let col = -1
+ while mpos < curs_pos && mpos != -1
+ let mpos = match(line, s:rxSep(), mpos+1)
+ if mpos != -1
+ let col += 1
+ endif
+ endwhile
+ return col
+endfunction "}}}
+
+" }}}
+
+" Format functions {{{
+function! s:fmt_cell(cell, max_len) "{{{
+ let cell = ' '.a:cell.' '
+
+ let diff = a:max_len - s:wide_len(a:cell)
+ if diff == 0 && empty(a:cell)
+ let diff = 1
+ endif
+
+ let cell .= repeat(' ', diff)
+ return cell
+endfunction "}}}
+
+function! s:fmt_row(line, max_lens, col1, col2) "{{{
+ let new_line = s:rxSep()
+ let cells = vimwiki#tbl#get_cells(a:line)
+ for idx in range(len(cells))
+ if idx == a:col1
+ let idx = a:col2
+ elseif idx == a:col2
+ let idx = a:col1
+ endif
+ let value = cells[idx]
+ 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 idx += 1
+ endwhile
+ return new_line
+endfunction "}}}
+
+function! s:fmt_cell_sep(max_len) "{{{
+ if a:max_len == 0
+ return repeat('-', 3)
+ else
+ return repeat('-', a:max_len+2)
+ endif
+endfunction "}}}
+
+function! s:fmt_sep(max_lens, col1, col2) "{{{
+ 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()
+ endfor
+ return new_line
+endfunction "}}}
+"}}}
+
+" Keyboard functions "{{{
+function! s:kbd_create_new_row(cols, goto_first) "{{{
+ let cmd = "\o".s:create_empty_row(a:cols)
+ let cmd .= "\:call vimwiki#tbl#format(line('.'))\"
+ let cmd .= "\0"
+ if a:goto_first
+ let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'c', line('.'))\"
+ else
+ let cmd .= (col('.')-1)."l"
+ let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\"
+ endif
+ let cmd .= "a"
+
+ return cmd
+endfunction "}}}
+
+function! s:kbd_goto_next_row() "{{{
+ let cmd = "\j"
+ let cmd .= ":call search('.\\(".s:rxSep()."\\)', 'c', line('.'))\"
+ let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\"
+ let cmd .= "a"
+ return cmd
+endfunction "}}}
+
+function! s:kbd_goto_prev_row() "{{{
+ let cmd = "\k"
+ let cmd .= ":call search('.\\(".s:rxSep()."\\)', 'c', line('.'))\"
+ let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\"
+ let cmd .= "a"
+ return cmd
+endfunction "}}}
+
+" Used in s:kbd_goto_next_col
+function! vimwiki#tbl#goto_next_col() "{{{
+ let curcol = virtcol('.')
+ let lnum = line('.')
+ let newcol = s:get_indent(lnum)
+ let max_lens = s:get_cell_max_lens(lnum)
+ for cell_len in values(max_lens)
+ if newcol >= curcol-1
+ break
+ endif
+ let newcol += cell_len + 3 " +3 == 2 spaces + 1 separator |...
+ endfor
+ let newcol += 2 " +2 == 1 separator + 1 space |...
+ if newcol + delta > curcol-1
+ let newcol -= (prev_cell_len + 3) " +3 == 2 spaces + 1 separator |...
+ break
+ elseif newcol + delta == curcol-1
+ break
+ endif
+ let prev_cell_len = cell_len
+ let newcol += delta
+ endfor
+ let newcol += 2 " +2 == 1 separator + 1 space |"
+ " let cmd .= "a"
+ "echomsg "DEBUG kbd_goto_prev_col> ".cmd
+ return cmd
+endfunction "}}}
+
+"}}}
+
+" Global functions {{{
+function! vimwiki#tbl#kbd_cr() "{{{
+ let lnum = line('.')
+ if !s:is_table(getline(lnum))
+ return "\"
+ endif
+
+ if s:is_separator(getline(lnum+1)) || !s:is_table(getline(lnum+1))
+ let cols = len(vimwiki#tbl#get_cells(getline(lnum)))
+ return s:kbd_create_new_row(cols, 0)
+ else
+ return s:kbd_goto_next_row()
+ endif
+endfunction "}}}
+
+function! vimwiki#tbl#kbd_tab() "{{{
+ let lnum = line('.')
+ if !s:is_table(getline(lnum))
+ return "\"
+ endif
+
+ let last = s:is_last_column(lnum, col('.'))
+ let is_sep = s:is_separator_tail(getline(lnum))
+ "echomsg "DEBUG kbd_tab> last=".last.", is_sep=".is_sep
+ if (is_sep || last) && !s:is_table(getline(lnum+1))
+ let cols = len(vimwiki#tbl#get_cells(getline(lnum)))
+ return s:kbd_create_new_row(cols, 1)
+ endif
+ return s:kbd_goto_next_col(is_sep || last)
+endfunction "}}}
+
+function! vimwiki#tbl#kbd_shift_tab() "{{{
+ let lnum = line('.')
+ if !s:is_table(getline(lnum))
+ return "\"
+ endif
+
+ let first = s:is_first_column(lnum, col('.'))
+ let is_sep = s:is_separator_tail(getline(lnum))
+ "echomsg "DEBUG kbd_tab> ".first
+ if (is_sep || first) && !s:is_table(getline(lnum-1))
+ return ""
+ endif
+ return s:kbd_goto_prev_col(is_sep || first)
+endfunction "}}}
+
+function! vimwiki#tbl#format(lnum, ...) "{{{
+ if !(&filetype == 'vimwiki')
+ return
+ endif
+ let line = getline(a:lnum)
+ if !s:is_table(line)
+ return
+ endif
+
+ if a:0 == 2
+ let col1 = a:1
+ let col2 = a:2
+ else
+ let col1 = 0
+ let col2 = 0
+ endif
+
+ let indent = s:get_indent(a:lnum)
+
+ for [lnum, row] in s:get_aligned_rows(a:lnum, col1, col2)
+ let row = repeat(' ', indent).row
+ call setline(lnum, row)
+ endfor
+
+ let &tw = s:textwidth
+endfunction "}}}
+
+function! vimwiki#tbl#create(...) "{{{
+ if a:0 > 1
+ let cols = a:1
+ let rows = a:2
+ elseif a:0 == 1
+ let cols = a:1
+ let rows = 2
+ elseif a:0 == 0
+ let cols = 5
+ let rows = 2
+ endif
+
+ if cols < 1
+ let cols = 5
+ endif
+
+ if rows < 1
+ let rows = 2
+ endif
+
+ let lines = []
+ let row = s:create_empty_row(cols)
+
+ call add(lines, row)
+ if rows > 1
+ call add(lines, s:create_row_sep(cols))
+ endif
+
+ for r in range(rows - 1)
+ call add(lines, row)
+ endfor
+
+ call append(line('.'), lines)
+endfunction "}}}
+
+function! vimwiki#tbl#align_or_cmd(cmd) "{{{
+ if s:is_table(getline('.'))
+ call vimwiki#tbl#format(line('.'))
+ else
+ exe 'normal! '.a:cmd
+ endif
+endfunction "}}}
+
+function! vimwiki#tbl#reset_tw(lnum) "{{{
+ if !(&filetype == 'vimwiki')
+ return
+ endif
+ let line = getline(a:lnum)
+ if !s:is_table(line)
+ return
+ endif
+
+ let s:textwidth = &tw
+ let &tw = 0
+endfunction "}}}
+
+" TODO: move_column_left and move_column_right are good candidates to be
+" refactored.
+function! vimwiki#tbl#move_column_left() "{{{
+
+ "echomsg "DEBUG move_column_left: "
+
+ let line = getline('.')
+
+ if !s:is_table(line)
+ return
+ endif
+
+ let cur_col = s:cur_column()
+ if cur_col == -1
+ return
+ endif
+
+ if cur_col > 0
+ call vimwiki#tbl#format(line('.'), cur_col-1, cur_col)
+ call cursor(line('.'), 1)
+
+ let sep = '\('.s:rxSep().'\).\zs'
+ let mpos = -1
+ let col = -1
+ while col < cur_col-1
+ let mpos = match(line, sep, mpos+1)
+ if mpos != -1
+ let col += 1
+ else
+ break
+ endif
+ endwhile
+
+ endif
+
+endfunction "}}}
+
+function! vimwiki#tbl#move_column_right() "{{{
+
+ let line = getline('.')
+
+ if !s:is_table(line)
+ return
+ endif
+
+ let cur_col = s:cur_column()
+ if cur_col == -1
+ return
+ endif
+
+ if cur_col < s:col_count(line('.'))-1
+ call vimwiki#tbl#format(line('.'), cur_col, cur_col+1)
+ call cursor(line('.'), 1)
+
+ let sep = '\('.s:rxSep().'\).\zs'
+ let mpos = -1
+ let col = -1
+ while col < cur_col+1
+ let mpos = match(line, sep, mpos+1)
+ if mpos != -1
+ let col += 1
+ else
+ break
+ endif
+ endwhile
+
+ endif
+
+endfunction "}}}
+
+function! vimwiki#tbl#get_rows(lnum) "{{{
+ return s:get_rows(a:lnum)
+endfunction "}}}
+
+function! vimwiki#tbl#is_table(line) "{{{
+ return s:is_table(a:line)
+endfunction "}}}
+
+function! vimwiki#tbl#is_separator(line) "{{{
+ return s:is_separator(a:line)
+endfunction "}}}
+
+function! vimwiki#tbl#cell_splitter() "{{{
+ return s:cell_splitter()
+endfunction "}}}
+
+function! vimwiki#tbl#sep_splitter() "{{{
+ return s:sep_splitter()
+endfunction "}}}
+
+"}}}
diff --git a/bash/.vim/autoload/vimwiki/u.vim b/bash/.vim/autoload/vimwiki/u.vim
new file mode 100644
index 0000000..9680a27
--- /dev/null
+++ b/bash/.vim/autoload/vimwiki/u.vim
@@ -0,0 +1,77 @@
+" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
+" Vimwiki autoload plugin file
+" Utility functions
+" Author: Maxim Kim
+" Home: http://code.google.com/p/vimwiki/
+
+function! vimwiki#u#trim(string, ...) "{{{
+ let chars = ''
+ if a:0 > 0
+ let chars = a:1
+ endif
+ let res = substitute(a:string, '^[[:space:]'.chars.']\+', '', '')
+ let res = substitute(res, '[[:space:]'.chars.']\+$', '', '')
+ return res
+endfunction "}}}
+
+
+" Builtin cursor doesn't work right with unicode characters.
+function! vimwiki#u#cursor(lnum, cnum) "{{{
+ exe a:lnum
+ exe 'normal! 0'.a:cnum.'|'
+endfunction "}}}
+
+function! vimwiki#u#is_windows() "{{{
+ return has("win32") || has("win64") || has("win95") || has("win16")
+endfunction "}}}
+
+function! vimwiki#u#chomp_slash(str) "{{{
+ return substitute(a:str, '[/\\]\+$', '', '')
+endfunction "}}}
+
+function! vimwiki#u#time(starttime) "{{{
+ " measure the elapsed time and cut away miliseconds and smaller
+ return matchstr(reltimestr(reltime(a:starttime)),'\d\+\(\.\d\d\)\=')
+endfunction "}}}
+
+function! vimwiki#u#path_norm(path) "{{{
+ " /-slashes
+ let path = substitute(a:path, '\', '/', 'g')
+ " treat multiple consecutive slashes as one path separator
+ let path = substitute(path, '/\+', '/', 'g')
+ " ensure that we are not fooled by a symbolic link
+ return resolve(path)
+endfunction "}}}
+
+function! vimwiki#u#is_link_to_dir(link) "{{{
+ " Check if link is to a directory.
+ " It should be ended with \ or /.
+ if a:link =~ '.\+[/\\]$'
+ return 1
+ endif
+ return 0
+endfunction " }}}
+
+function! vimwiki#u#count_first_sym(line) "{{{
+ let first_sym = matchstr(a:line, '\S')
+ return len(matchstr(a:line, first_sym.'\+'))
+endfunction "}}}
+
+" return longest common path prefix of 2 given paths.
+" '~/home/usrname/wiki', '~/home/usrname/wiki/shmiki' => '~/home/usrname/wiki'
+function! vimwiki#u#path_common_pfx(path1, path2) "{{{
+ let p1 = split(a:path1, '[/\\]', 1)
+ let p2 = split(a:path2, '[/\\]', 1)
+
+ let idx = 0
+ let minlen = min([len(p1), len(p2)])
+ while (idx < minlen) && (p1[idx] ==? p2[idx])
+ let idx = idx + 1
+ endwhile
+ if idx == 0
+ return ''
+ else
+ return join(p1[: idx-1], '/')
+ endif
+endfunction "}}}
+
diff --git a/bash/.vim/doc/vimwiki.txt b/bash/.vim/doc/vimwiki.txt
new file mode 100644
index 0000000..4ae55d9
--- /dev/null
+++ b/bash/.vim/doc/vimwiki.txt
@@ -0,0 +1,2372 @@
+*vimwiki.txt* A Personal Wiki for Vim
+
+ __ __ ___ __ __ _ _ ___ ___ _ ___ ~
+ | | | || | | |_| || | _ | || | | | | || | ~
+ | |_| || | | || || || || | | |_| || | ~
+ | || | | || || | | _|| | ~
+ | || | | || || | | |_ | | ~
+ | | | | | ||_|| || _ || | | _ || | ~
+ |___| |___| |_| |_||__| |__||___| |___| |_||___| ~
+
+
+ Version: 2.1
+
+==============================================================================
+CONTENTS *vimwiki-contents*
+
+ 1. Intro |vimwiki|
+ 2. Prerequisites |vimwiki-prerequisites|
+ 3. Mappings |vimwiki-mappings|
+ 3.1. Global mappings |vimwiki-global-mappings|
+ 3.2. Local mappings |vimwiki-local-mappings|
+ 3.3. Text objects |vimwiki-text-objects|
+ 4. Commands |vimwiki-commands|
+ 4.1. Global commands |vimwiki-global-commands|
+ 4.2. Local commands |vimwiki-local-commands|
+ 5. Wiki syntax |vimwiki-syntax|
+ 5.1. Typefaces |vimwiki-syntax-typefaces|
+ 5.2. Links |vimwiki-syntax-links|
+ 5.3. Headers |vimwiki-syntax-headers|
+ 5.4. Paragraphs |vimwiki-syntax-paragraphs|
+ 5.5. Lists |vimwiki-syntax-lists|
+ 5.6. Tables |vimwiki-syntax-tables|
+ 5.7. Preformatted text |vimwiki-syntax-preformatted|
+ 5.8. Mathematical formulae |vimwiki-syntax-math|
+ 5.9. Blockquotes |vimwiki-syntax-blockquotes|
+ 5.10. Comments |vimwiki-syntax-comments|
+ 5.11. Horizontal line |vimwiki-syntax-hr|
+ 5.12. Schemes |vimwiki-syntax-schemes|
+ 5.13. Transclusions |vimwiki-syntax-transclude|
+ 5.14. Thumbnails |vimwiki-syntax-thumbnails|
+ 6. Folding/Outline |vimwiki-folding|
+ 7. Placeholders |vimwiki-placeholders|
+ 8. Todo lists |vimwiki-todo-lists|
+ 9. Tables |vimwiki-tables|
+ 10. Diary |vimwiki-diary|
+ 11. Options |vimwiki-options|
+ 11.1. Registered Wiki |vimwiki-register-wiki|
+ 11.2. Temporary Wiki |vimwiki-temporary-wiki|
+ 11.3. Per-Wiki Options |vimwiki-local-options|
+ 11.4. Global Options |viwmiki-global-options|
+ 12. Help |vimwiki-help|
+ 13. Developers |vimwiki-developers|
+ 14. Changelog |vimwiki-changelog|
+ 15. License |vimwiki-license|
+
+
+==============================================================================
+1. Intro *vimwiki*
+
+Vimwiki is a personal wiki for Vim -- a number of linked text files that have
+their own syntax highlighting.
+
+With vimwiki you can:
+ - organize notes and ideas;
+ - manage todo-lists;
+ - write documentation.
+
+To do a quick start press ww (this is usually \ww) to go to your index
+wiki file. By default it is located in: >
+ ~/vimwiki/index.wiki
+
+Feed it with the following example:
+
+= My knowledge base =
+ * Tasks -- things to be done _yesterday_!!!
+ * Project Gutenberg -- good books are power.
+ * Scratchpad -- various temporary stuff.
+
+Place your cursor on 'Tasks' and press Enter to create a link. Once pressed,
+'Tasks' will become '[[Tasks]]' -- a vimwiki link. Press Enter again to
+open it. Edit the file, save it, and then press Backspace to jump back to your
+index.
+
+A vimwiki link can be constructed from more than one word. Just visually
+select the words to be linked and press Enter. Try it with 'Project
+Gutenberg'. The result should look something like:
+
+= My knowledge base =
+ * [[Tasks]] -- things to be done _yesterday_!!!
+ * [[Project Gutenberg]] -- good books are power.
+ * Scratchpad -- various temporary stuff.
+
+==============================================================================
+2. Prerequisites *vimwiki-prerequisites*
+
+Make sure you have these settings in your vimrc file: >
+ set nocompatible
+ filetype plugin on
+ syntax on
+
+Without them Vimwiki will not work properly.
+
+
+==============================================================================
+3. Mappings *vimwiki-mappings*
+
+There are global and local mappings in vimwiki.
+
+------------------------------------------------------------------------------
+3.1. Global mappings *vimwiki-global-mappings*
+
+[count]ww or VimwikiIndex
+ Open index file of the [count]'s wiki.
+
+ ww opens the first wiki from |g:vimwiki_list|.
+ 1ww as above, opens the first wiki from |g:vimwiki_list|.
+ 2ww opens the second wiki from |g:vimwiki_list|.
+ 3ww opens the third wiki from |g:vimwiki_list|.
+ etc.
+ To remap: >
+ :nmap w VimwikiIndex
+<
+See also |:VimwikiIndex|
+
+
+[count]wt or VimwikiTabIndex
+ Open index file of the [count]'s wiki in a new tab.
+
+ wt tabopens the first wiki from |g:vimwiki_list|.
+ 1wt as above tabopens the first wiki from |g:vimwiki_list|.
+ 2wt tabopens the second wiki from |g:vimwiki_list|.
+ 3wt tabopens the third wiki from |g:vimwiki_list|.
+ etc.
+ To remap: >
+ :nmap t VimwikiTabIndex
+<
+See also |:VimwikiTabIndex|
+
+
+ws or VimwikiUISelect
+ List and select available wikies.
+ To remap: >
+ :nmap wq VimwikiUISelect
+<
+See also |:VimwikiUISelect|
+
+
+[count]wi or VimwikiDiaryIndex
+ Open diary index file of the [count]'s wiki.
+
+ wi opens diary index file of the first wiki from
+ |g:vimwiki_list|.
+ 1wi the same as above.
+ 2wi opens diary index file of the second wiki from
+ |g:vimwiki_list|.
+ etc.
+ To remap: >
+ :nmap i VimwikiDiaryIndex
+
+See also |:VimwikiDiaryIndex|
+
+
+[count]ww or VimwikiMakeDiaryNote
+ Open diary wiki-file for today of the [count]'s wiki.
+
+ ww opens diary wiki-file for today in the first wiki
+ from |g:vimwiki_list|.
+ 1ww as above opens diary wiki-file for today in the
+ first wiki from |g:vimwiki_list|.
+ 2ww opens diary wiki-file for today in the second wiki
+ from |g:vimwiki_list|.
+ 3ww opens diary wiki-file for today in the third wiki
+ from |g:vimwiki_list|.
+ etc.
+ To remap: >
+ :nmap d VimwikiMakeDiaryNote
+<
+See also |:VimwikiMakeDiaryNote|
+
+
+[count]wt or VimwikiTabMakeDiaryNote
+ Open diary wiki-file for today of the [count]'s wiki in a new tab.
+
+ wt tabopens diary wiki-file for today in the first
+ wiki from |g:vimwiki_list|.
+ 1wt as above tabopens diary wiki-file for today in the
+ first wiki from |g:vimwiki_list|.
+ 2wt tabopens diary wiki-file for today in the second
+ wiki from |g:vimwiki_list|.
+ 3wt tabopens diary wiki-file for today in the third
+ wiki from |g:vimwiki_list|.
+ etc.
+ To remap: >
+ :nmap dt VimwikiTabMakeDiaryNote
+<
+See also |:VimwikiTabMakeDiaryNote|
+
+
+------------------------------------------------------------------------------
+3.2. Local mappings
+
+NORMAL MODE *vimwiki-local-mappings*
+ *vimwiki_wh*
+wh Convert current wiki page to HTML.
+ Maps to |:Vimwiki2HTML|
+ To remap: >
+ :nmap wc Vimwiki2HTML
+<
+ *vimwiki_whh*
+whh Convert current wiki page to HTML and open it in
+ webbrowser.
+ Maps to |:Vimwiki2HTML|
+ To remap: >
+ :nmap wcc Vimwiki2HTMLBrowse
+<
+ *vimwiki_wi*
+wi Update diary section (delete old, insert new)
+ Only works from the diary index.
+ Maps to |:VimwikiDiaryGenerateLinks|
+ To remap: >
+ :nmap wcr VimwikiDiaryGenerateLinks
+<
+ *vimwiki_*
+ Follow/create wiki link (create target wiki page if
+ needed).
+ Maps to |:VimwikiFollowLink|.
+ To remap: >
+ :nmap wf VimwikiFollowLink
+<
+ *vimwiki_*
+ Split and follow (create target wiki page if needed).
+ May not work in some terminals. Remapping could help.
+ Maps to |:VimwikiSplitLink|.
+ To remap: >
+ :nmap we VimwikiSplitLink
+<
+ *vimwiki_*
+ Vertical split and follow (create target wiki page if
+ needed).
+ May not work in some terminals. Remapping could help.
+ Maps to |:VimwikiVSplitLink|.
+ To remap: >
+ :nmap wq VimwikiVSplitLink
+<
+ *vimwiki_* *vimwiki_*
+, Follow wiki link (create target wiki page if needed),
+ opening in a new tab.
+ May not work in some terminals. Remapping could help.
+ Maps to |:VimwikiTabnewLink|.
+ To remap: >
+ :nmap wt VimwikiTabnewLink
+<
+ *vimwiki_*
+ Go back to previous wiki page.
+ Maps to |:VimwikiGoBackLink|.
+ To remap: >
+ :nmap wb VimwikiGoBackLink
+<
+ *vimwiki_*
+ Find next link on the current page.
+ Maps to |:VimwikiNextLink|.
+ To remap: >
+ :nmap wn VimwikiNextLink
+<
+ *vimwiki_*
+ Find previous link on the current page.
+ Maps to |:VimwikiPrevLink|.
+ To remap: >
+ :nmap wp VimwikiPrevLink
+<
+ *vimwiki_wd*
+wd Delete wiki page you are in.
+ Maps to |:VimwikiDeleteLink|.
+ To remap: >
+ :nmap dd VimwikiDeleteLink
+<
+ *vimwiki_wr*
+wr Rename wiki page you are in.
+ Maps to |:VimwikiRenameLink|.
+ To remap: >
+ :nmap rr VimwikiRenameLink
+<
+ *vimwiki_*
+ Toggle list item on/off (checked/unchecked)
+ Maps to |:VimwikiToggleListItem|.
+ To remap: >
+ :nmap tt VimwikiToggleListItem
+< See |vimwiki-todo-lists|.
+
+ *vimwiki_=*
+= Add header level. Create if needed.
+ There is nothing to indent with '==' command in
+ vimwiki, so it should be ok to use '=' here.
+ To remap: >
+ :nmap == VimwikiAddHeaderLevel
+<
+ *vimwiki_-*
+- Remove header level.
+ To remap: >
+ :nmap -- VimwikiRemoveHeaderLevel
+<
+ *vimwiki_+*
++ Create and/or decorate links. Depending on the
+ context, this command will: convert words into
+ Wikilinks; convert raw URLs into Wikilinks; and add
+ placeholder text to Wiki- or Weblinks that are missing
+ descriptions. Can be activated in normal mode with
+ the cursor over a word or link, or in visual mode with
+ the selected text .
+
+ *vimwiki_glm*
+glm Increase the indent of a single-line list item.
+
+ *vimwiki_gll*
+gll Decrease the indent of a single-line list item.
+
+ *vimwiki_glstar* *vimwiki_gl8*
+gl* or gl8 Switch or insert a "*" symbol. Only available in
+ supported syntaxes.
+
+ *vimwiki_gl#* *vimwiki_gl3*
+gl# or gl3 Switch or insert a "#" symbol. Only available in
+ supported syntaxes.
+
+ *vimwiki_gl-*
+gl- Switch or insert a "-" symbol. Only available in
+ supported syntaxes.
+
+ *vimwiki_gl1*
+gl1 Switch or insert a "1." symbol. Only available in
+ supported syntaxes.
+
+ *vimwiki_gqq* *vimwiki_gww*
+gqq Format table. If you made some changes to a table
+ or without swapping insert/normal modes this command
+gww will reformat it.
+
+ *vimwiki_*
+ Move current table column to the left.
+ See |:VimwikiTableMoveColumnLeft|
+ To remap: >
+ :nmap wtl VimwikiTableMoveColumnLeft
+<
+ *vimwiki_*
+ Move current table column to the right.
+ See |:VimwikiTableMoveColumnRight|
+ To remap: >
+ :nmap wtr VimwikiTableMoveColumnRight
+<
+ *vimwiki_*
+ Open the previous day's diary link if available.
+ See |:VimwikiDiaryPrevDay|
+
+ *vimwiki_*
+ Open the next day's diary link if available.
+ See |:VimwikiDiaryNextDay|
+
+
+Works only if |g:vimwiki_use_mouse| is set to 1.
+<2-LeftMouse> Follow wiki link (create target wiki page if needed).
+
+ Split and follow wiki link (create target wiki page if
+ needed).
+
+ Vertical split and follow wiki link (create target
+ wiki page if needed).
+
+ Go back to previous wiki page.
+
+Note: <2-LeftMouse> is just left double click.
+
+
+
+INSERT MODE *vimwiki-table-mappings*
+ *vimwiki_i_*
+ Go to the table cell beneath the current one, create
+ a new row if on the last one.
+
+ *vimwiki_i_*
+ Go to the next table cell, create a new row if on the
+ last cell.
+See |g:vimwiki_table_mappings| to turn them off.
+
+
+------------------------------------------------------------------------------
+3.3. Text objects *vimwiki-text-objects*
+
+ah A section segment (the area between two consecutive
+ headings) including trailing empty lines.
+ih A section segment without trailing empty lines.
+
+You can 'vah' to select a section segment with its contents or 'dah' to delete
+it or 'yah' to yank it or 'cah' to change it.
+
+a\ A cell in a table.
+i\ An inner cell in a table.
+ac A column in a table.
+ic An inner column in a table.
+
+
+==============================================================================
+4. Commands *vimwiki-commands*
+
+------------------------------------------------------------------------------
+4.1. Global Commands *vimwiki-global-commands*
+
+*:VimwikiIndex*
+ Open index file of the current wiki.
+
+*:VimwikiTabIndex*
+ Open index file of the current wiki in a new tab.
+
+*:VimwikiUISelect*
+ Open index file of the selected wiki.
+
+*:VimwikiDiaryIndex*
+ Open diary index file of the current wiki.
+
+*:VimwikiMakeDiaryNote*
+ Open diary wiki-file for today of the current wiki.
+
+*:VimwikiTabMakeDiaryNote*
+ Open diary wiki-file for today of the current wiki in a new tab.
+
+
+------------------------------------------------------------------------------
+4.2. Local commands *vimwiki-local-commands*
+
+*:VimwikiFollowLink*
+ Follow wiki link (create target wiki page if needed).
+
+*:VimwikiGoBackLink*
+ Go back to the wiki page you came from.
+
+*:VimwikiSplitLink*
+ Split and follow wiki link (create target wiki page if needed).
+
+*:VimwikiVSplitLink*
+ Vertical split and follow wiki link (create target wiki page if needed).
+
+*:VimwikiTabnewLink*
+ Follow wiki link in a new tab (create target wiki page if needed).
+
+*:VimwikiNextLink*
+ Find next link on the current page.
+
+*:VimwikiPrevLink*
+ Find previous link on the current page.
+
+*:VimwikiGoto*
+ Goto link provided by an argument. For example: >
+ :VimwikiGoto HelloWorld
+< opens opens/creates HelloWorld wiki page.
+
+*:VimwikiDeleteLink*
+ Delete the wiki page that you are in.
+
+*:VimwikiRenameLink*
+ Rename the wiki page that you are in.
+
+*:Vimwiki2HTML*
+ Convert current wiki page to HTML using vimwiki's own converter or a
+ user-supplied script (see |vimwiki-option-custom_wiki2html|).
+
+*:Vimwiki2HTMLBrowse*
+ Convert current wiki page to HTML and open it in webbrowser.
+
+*:VimwikiAll2HTML*
+ Convert all wiki pages to HTML.
+ Default css file (style.css) is created if there is no one.
+
+*:VimwikiToggleListItem*
+ Toggle list item on/off (checked/unchecked)
+ See |vimwiki-todo-lists|.
+
+*:VimwikiListChangeLevel* CMD
+ Change the nesting level, or symbol, for a single-line list item.
+ CMD may be ">>" or "<<" to change the indentation of the item, or
+ one of the syntax-specific bullets: "*", "#", "1.", "-".
+ See |vimwiki-todo-lists|.
+
+*:VimwikiSearch* /pattern/
+*:VWS* /pattern/
+ Search for /pattern/ in all files of current wiki.
+ To display all matches use |:lopen| command.
+ To display next match use |:lnext| command.
+ To display previous match use |:lprevious| command.
+
+*:VimwikiBacklinks*
+*:VWB*
+ Search for wikilinks to the [[current wiki page]]
+ in all files of current wiki.
+ To display all matches use |:lopen| command.
+ To display next match use |:lnext| command.
+ To display previous match use |:lprevious| command.
+
+
+*:VimwikiTable*
+ Create a table with 5 cols and 2 rows.
+
+ :VimwikiTable cols rows
+ Create a table with the given cols and rows
+
+ :VimwikiTable cols
+ Create a table with the given cols and 2 rows
+
+
+*:VimwikiTableMoveColumnLeft* , *:VimwikiTableMoveColumnRight*
+ Move current column to the left or to the right:
+ Example: >
+
+ | head1 | head2 | head3 | head4 | head5 |
+ |--------|--------|--------|--------|--------|
+ | value1 | value2 | value3 | value4 | value5 |
+
+
+ Cursor is on 'head1'.
+ :VimwikiTableMoveColumnRight
+
+ | head2 | head1 | head3 | head4 | head5 |
+ |--------|--------|--------|--------|--------|
+ | value2 | value1 | value3 | value4 | value5 |
+
+ Cursor is on 'head3'.
+ :VimwikiTableMoveColumnLeft
+
+ | head2 | head3 | head1 | head4 | head5 |
+ |--------|--------|--------|--------|--------|
+ | value2 | value3 | value1 | value4 | value5 |
+<
+
+ Commands are mapped to and respectively.
+
+
+*:VimwikiGenerateLinks*
+ Insert all available links into current buffer.
+
+*:VimwikiDiaryGenerateLinks*
+ Delete old, insert new diary section into diary index file.
+
+*:VimwikiDiaryNextDay*
+ Open next day diary link if available.
+ Mapped to .
+
+*:VimwikiDiaryPrevDay*
+ Open previous day diary link if available.
+ Mapped to .
+
+
+==============================================================================
+5. Wiki syntax *vimwiki-syntax*
+
+
+There are a lot of different wikies out there. Most of them have their own
+syntax and vimwiki's default syntax is not an exception here.
+
+Vimwiki has evolved its own syntax that closely resembles google's wiki
+markup. This syntax is described in detail below.
+
+Vimwiki also supports alternative syntaxes, like Markdown and MediaWiki, to
+varying degrees; see |vimwiki-option-syntax|. Static elements like headers,
+quotations, and lists are customized in syntax/vimwiki_xxx.vim, where xxx
+stands for the chosen syntax.
+
+Interactive elements such as links and vimwiki commands are supported by
+definitions and routines in syntax/vimwiki_xxx_custom.vim and
+autoload/vimwiki/xxx_base.vim. Currently, only Markdown includes this level
+of support.
+
+Vimwiki2HTML is currently functional only for the default syntax.
+
+------------------------------------------------------------------------------
+5.1. Typefaces *vimwiki-syntax-typefaces*
+
+There are a few typefaces that gives you a bit of control over how your
+text should be decorated: >
+ *bold text*
+ _italic text_
+ ~~strikeout text~~
+ `code (no syntax) text`
+ super^script^
+ sub,,script,,
+
+
+------------------------------------------------------------------------------
+5.2. Links *vimwiki-syntax-links*
+
+Wikilinks~
+
+Link with spaces in it: >
+ [[This is a link]]
+or: >
+ [[This is a link source|Description of the link]]
+
+Links to directories (ending with a "/") are also supported: >
+ [[/home/somebody/|Home Directory]]
+
+Use |g:vimwiki_dir_link| to control the behaviour when opening directories.
+
+Raw URLs~
+
+Raw URLs are also supported: >
+ http://code.google.com/p/vimwiki
+ mailto:habamax@gmail.com
+ ftp://vim.org
+
+
+Markdown Links~
+
+These links are only available for Markdown syntax. See
+http://daringfireball.net/projects/markdown/syntax#link.
+
+Inline link: >
+ [Looks like this](URL)
+
+Image link: >
+ ![Looks like this](URL)
+
+The URL can be anything recognized by vimwiki as a raw URL.
+
+
+Reference-style links: >
+ a) [Link Name][Id]
+ b) [Id][], using the "implicit link name" shortcut
+
+Reference style links must always include *two* consecutive pairs of
+[-brackets, and field entries can not use "[" or "]".
+
+
+NOTE: (in Vimwiki's current implementation) Reference-style links are a hybrid
+of Vimwiki's default "Wikilink" and the tradition reference-style link.
+
+If the Id is defined elsewhere in the source, as per the Markdown standard: >
+ [Id]: URL
+
+then the URL is opened with the system default handler. Otherwise, Vimwiki
+treats the reference-style link as a Wikilink, interpreting the Id field as a
+wiki page name.
+
+Highlighting of existing links when |vimwiki-option-maxhi| is activated
+identifies links whose Id field is not defined, either as a reference-link or
+as a wiki page.
+
+To scan the page for new or changed definitions for reference-links, simply
+re-open the page ":e".
+
+
+------------------------------------------------------------------------------
+5.3. Headers *vimwiki-syntax-headers*
+
+= Header level 1 =~
+By default all headers are highlighted using |hl-Title| highlight group.
+
+== Header level 2 ==~
+You can set up different colors for each header level: >
+ :hi VimwikiHeader1 guifg=#FF0000
+ :hi VimwikiHeader2 guifg=#00FF00
+ :hi VimwikiHeader3 guifg=#0000FF
+ :hi VimwikiHeader4 guifg=#FF00FF
+ :hi VimwikiHeader5 guifg=#00FFFF
+ :hi VimwikiHeader6 guifg=#FFFF00
+Set up colors for all 6 header levels or none at all.
+
+=== Header level 3 ===~
+==== Header level 4 ====~
+===== Header level 5 =====~
+====== Header level 6 ======~
+
+
+You can center your headers in HTML by placing spaces before the first '=':
+ = Centered Header L1 =~
+
+
+------------------------------------------------------------------------------
+5.4. Paragraphs *vimwiki-syntax-paragraphs*
+
+A paragraph is a group of lines starting in column 1 (no indentation).
+Paragraphs are separated by a blank line:
+
+This is first paragraph
+with two lines.
+
+This is a second paragraph with
+two lines.
+
+
+------------------------------------------------------------------------------
+5.5. Lists *vimwiki-syntax-lists*
+
+Unordered lists: >
+ * Bulleted list item 1
+ * Bulleted list item 2
+ * Bulleted list sub item 1
+ * Bulleted list sub item 2
+ * more ...
+ * and more ...
+ * ...
+ * Bulleted list sub item 3
+ * etc.
+or: >
+ - Bulleted list item 1
+ - Bulleted list item 2
+ - Bulleted list sub item 1
+ - Bulleted list sub item 2
+ - more ...
+ - and more ...
+ - ...
+ - Bulleted list sub item 3
+ - etc.
+
+or mix: >
+ - Bulleted list item 1
+ - Bulleted list item 2
+ * Bulleted list sub item 1
+ * Bulleted list sub item 2
+ * more ...
+ - and more ...
+ - ...
+ * Bulleted list sub item 3
+ * etc.
+
+Ordered lists: >
+ # Numbered list item 1
+ # Numbered list item 2
+ # Numbered list sub item 1
+ # Numbered list sub item 2
+ # more ...
+ # and more ...
+ # ...
+ # Numbered list sub item 3
+ # etc.
+
+It is possible to mix bulleted and numbered lists: >
+ * Bulleted list item 1
+ * Bulleted list item 2
+ # Numbered list sub item 1
+ # Numbered list sub item 2
+
+Note that a space after *, - or # is essential.
+
+Multiline list items: >
+ * Bulleted list item 1
+ List item 1 continued line.
+ List item 1 next continued line.
+ * Bulleted list item 2
+ * Bulleted list sub item 1
+ List sub item 1 continued line.
+ List sub item 1 next continued line.
+ * Bulleted list sub item 2
+ * etc.
+
+Definition lists: >
+Term 1:: Definition 1
+Term 2::
+:: Definition 2
+:: Definition 3
+
+
+------------------------------------------------------------------------------
+5.6. Tables *vimwiki-syntax-tables*
+
+Tables are created by entering the content of each cell separated by |
+delimiters. You can insert other inline wiki syntax in table cells, including
+typeface formatting and links.
+For example: >
+
+ | Year | Temperature (low) | Temperature (high) |
+ |------|-------------------|--------------------|
+ | 1900 | -10 | 25 |
+ | 1910 | -15 | 30 |
+ | 1920 | -10 | 32 |
+ | 1930 | _N/A_ | _N/A_ |
+ | 1940 | -2 | 40 |
+>
+
+In HTML the following part >
+ | Year | Temperature (low) | Temperature (high) |
+ |------|-------------------|--------------------|
+>
+is higlighted as a table header.
+
+If you indent a table then it will be centered in HTML.
+
+If you set > in a cell, the cell spans the left column.
+If you set \/ in a cell, the cell spans the above row.
+For example: >
+
+ | a | b | c | d |
+ | \/ | e | > | f |
+ | \/ | \/ | > | g |
+ | h | > | > | > |
+>
+
+See |vimwiki-tables| for more details on how to manage tables.
+
+
+------------------------------------------------------------------------------
+5.7. Preformatted text *vimwiki-syntax-preformatted*
+
+Use {{{ and }}} to define a block of preformatted text:
+{{{ >
+ Tyger! Tyger! burning bright
+ In the forests of the night,
+ What immortal hand or eye
+ Could frame thy fearful symmetry?
+ In what distant deeps or skies
+ Burnt the fire of thine eyes?
+ On what wings dare he aspire?
+ What the hand dare sieze the fire?
+}}}
+
+
+You can add optional information to {{{ tag: >
+{{{class="brush: python" >
+ def hello(world):
+ for x in range(10):
+ print("Hello {0} number {1}".format(world, x))
+}}}
+
+Result of HTML export: >
+
+ def hello(world):
+ for x in range(10):
+ print("Hello {0} number {1}".format(world, x))
+
+
+This might be useful for coloring program code with external js tools
+such as google's syntax highlighter.
+
+You can setup vimwiki to highlight code snippets in preformatted text.
+See |vimwiki-option-nested_syntaxes|
+
+
+------------------------------------------------------------------------------
+5.8. Mathematical formulae *vimwiki-syntax-math*
+
+Mathematical formulae are highlighted, and can be rendered in HTML using the
+powerful open source display engine MathJax (http://www.mathjax.org/).
+
+There are three supported syntaxes, which are inline, block display and
+block environment.
+
+Inline math is for short formulae within text. It is enclosed by single
+dollar signs, e.g.:
+ $ \sum_i a_i^2 = 1 $
+
+Block display creates a centered formula with some spacing before and after
+it. It must start with a line including only {{$, then an arbitrary number
+of mathematical text are allowed, and it must end with a line including only
+}}$.
+E.g.:
+ {{$
+ \sum_i a_i^2
+ =
+ 1
+ }}$
+
+Note: no matter how many lines are used in the text file, the HTML will
+compress it to *one* line only.
+
+Block environment is similar to block display, but is able to use specific
+LaTeX environments, such as 'align'. The syntax is the same as for block
+display, except for the first line which is {{$%environment%.
+E.g.:
+ {{$%align%
+ \sum_i a_i^2 &= 1 + 1 \\
+ &= 2.
+ }}$
+
+Similar compression rules for the HTML page hold (as MathJax interprets the
+LaTeX code).
+
+Note: the highlighting in VIM is automatic. For the rendering in HTML, you
+have two *alternative* options:
+
+1. using the MathJax server for rendering (needs an internet connection).
+Add to your HTML template the following line:
+
+
+
+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:
+
+
+
+where is the folder on your HD, as a relative path to the
+template folder. For instance, a sensible folder structure could be:
+
+- wiki
+ - text
+ - html
+ - templates
+ - mathjax
+
+In this case, would be "../mathjax" (without quotes).
+
+
+------------------------------------------------------------------------------
+5.9. Blockquotes *vimwiki-syntax-blockquotes*
+
+Text started with 4 or more spaces is a blockquote.
+
+ This would be a blockquote in vimwiki. It is not highlighted in vim but
+ could be styled by CSS in HTML. Blockquotes are usually used to quote a
+ long piece of text from another source.
+
+
+------------------------------------------------------------------------------
+5.10. Comments *vimwiki-syntax-comments*
+
+Text line started with %% is a comment.
+E.g.: >
+ %% this text would not be in HTML
+<
+
+
+------------------------------------------------------------------------------
+5.11. Horizontal line *vimwiki-syntax-hr*
+
+4 or more dashes at the start of the line is a 'horizontal line' (): >
+ ----
+<
+
+------------------------------------------------------------------------------
+5.12. Schemes *vimwiki-syntax-schemes*
+
+In addition to standard web schemes (e.g. `http:`, `https:`, `ftp:`, etc.) a
+number of special schemes are supported: "wiki#:", "local:", "diary:",
+"file:", and schemeless.
+
+While "wiki:#", "diary" and schemeless links are automatically opened in Vi,
+all other links are opened with the system command. To customize this
+behavior, see |VimwikiLinkHandler|.
+
+Interwiki:~
+
+If you maintain more than one wiki, you can create interwiki links between them
+by adding a numbered prefix "wiki#:" in front of a link: >
+ [[wiki#:This is a link]]
+or: >
+ [[wiki#:This is a link source|Description of the link]]
+
+The number "#", in the range 0..N-1, identifies the destination wiki in
+|g:vimwiki_list|.
+
+Diary:~
+
+The diary scheme is used to concisely link to diary entries: >
+ [[diary:2012-03-05]]
+
+This scheme precludes explicit inclusion of |vimwiki-option-diary_rel_path|,
+and is most useful on subwiki pages to avoid links such as: >
+ [[../../diary/2012-03-05]]
+
+Local:~
+
+A local resource that is not a wiki page may be specified with a path relative
+to the current page: >
+ [[local:../assets/data.csv|data (CSV)]]
+
+When followed or converted to HTML, extensions of local-scheme links are not
+modified.
+
+File:~
+
+The file scheme allows you to directly link to arbitray resources using
+absolute paths and extensions: >
+ [[file:///home/somebody/a/b/c/music.mp3]]
+
+Schemeless:~
+
+Schemeless URLs, which are the default, are treated internally as "wiki#:"
+URLs in all respects except when converted to Html.
+
+Schemeless links convert to plain relative path URLs, nearly verbatim: >
+ relpath/wikipage.html
+
+The "wiki#:", "local:", and "diary:" schemes use absolute paths as URLs: >
+ file:///abs_path_to_html#/relpath/wikipage.html
+
+When |vimwiki-option-maxhi| equals 1, a distinct highlighting style is used to
+identify schemeless links whose targets are not found. All other links appear
+as regular links even if the files to which they refer do not exist.
+
+
+------------------------------------------------------------------------------
+5.13. Transclusions *vimwiki-syntax-transclude*
+
+Transclusion (Wiki-Include) Links~
+
+Links that use "{{" and "}}" delimiters signify content that is to be
+included into the Html output, rather than referenced via hyperlink.
+
+Wiki-include URLs may use any of the supported schemes, may be absolute or
+relative, and need not end with an extension.
+
+The primary purpose for wiki-include links is to include images.
+
+Transclude from a local URL: >
+ {{local:../../images/vimwiki_logo.png}}
+or from a universal URL: >
+ {{http://vimwiki.googlecode.com/hg/images/vimwiki_logo.png}}
+
+Transclude image with alternate text: >
+ {{http://vimwiki.googlecode.com/hg/images/vimwiki_logo.png|Vimwiki}}
+in HTML: >
+
+
+Transclude image with alternate text and some style: >
+ {{http://.../vimwiki_logo.png|cool stuff|style="width:150px; height: 120px;"}}
+in HTML: >
+
+
+Transclude image _without_ alternate text and with css class: >
+ {{http://.../vimwiki_logo.png||class="center flow blabla"}}
+in HTML: >
+
+
+A trial feature allows you to supply your own handler for wiki-include links.
+See |VimwikiWikiIncludeHandler|.
+
+
+------------------------------------------------------------------------------
+5.14. Thumbnails *vimwiki-syntax-thumbnails*
+
+Thumbnail links~
+>
+Thumbnail links are constructed like this: >
+ [[http://someaddr.com/bigpicture.jpg|{{http://someaddr.com/thumbnail.jpg}}]]
+
+in HTML: >
+
+
+ %title%
+
+
+
+