vimwiki

Personal wiki for vim
git clone https://github.com/vimwiki/vimwiki.git
Log | Files | Refs | README | LICENSE

commit 28177c33e33ba26a69035b1593e843c3769f3abc
parent 8cdc1c15388cc7f4edb827ff15dbc31d592a79af
Author: Yuchen Pei <ycpei@users.noreply.github.com>
Date:   Sat,  8 Jul 2017 15:04:54 -0400

Added date placeholder. (#360)

* added date placeholder.

* made today the default.

Diffstat:
Mautoload/vimwiki/html.vim | 24++++++++++++++++++++++++
Msyntax/vimwiki.vim | 1+
2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim @@ -209,6 +209,19 @@ function! s:save_vimwiki_buffer() "{{{ endif endfunction "}}} +" get date. +function! s:process_date(placeholders, default_date) "{{{ + if !empty(a:placeholders) + for [placeholder, row, idx] in a:placeholders + let [type, param] = placeholder + if type ==# 'date' && !empty(param) + return param + endif + endfor + endif + return a:default_date +endfunction "}}} + " get title. function! s:process_title(placeholders, default_title) "{{{ if !empty(a:placeholders) @@ -1205,6 +1218,15 @@ function! s:parse_line(line, state) " {{{ endif endif + " date -- placeholder + if !processed + if line =~# '^\s*%date' + let processed = 1 + let param = matchstr(line, '^\s*%date\s\zs.*') + let state.placeholder = ['date', param] + endif + endif + " html template -- placeholder "{{{ if !processed if line =~# '^\s*%template' @@ -1483,11 +1505,13 @@ function! s:convert_file(path_html, wikifile) "{{{ call extend(ldest, lines) let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r")) + let date = s:process_date(placeholders, strftime('%Y-%m-%d')) let html_lines = s:get_html_template(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, "%date%", "'. date .'", "g")') call map(html_lines, 'substitute(v:val, "%root_path%", "'. \ s:root_path(VimwikiGet('subdir')) .'", "g")') diff --git a/syntax/vimwiki.vim b/syntax/vimwiki.vim @@ -460,6 +460,7 @@ execute 'syntax region VimwikiMath start=/'.g:vimwiki_rxMathStart. " placeholders syntax match VimwikiPlaceholder /^\s*%nohtml\s*$/ syntax match VimwikiPlaceholder /^\s*%title\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam +syntax match VimwikiPlaceholder /^\s*%date\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam syntax match VimwikiPlaceholder /^\s*%template\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam syntax match VimwikiPlaceholderParam /\s.*/ contained