vimwiki

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

commit 788a961052b843eeaa198dee0168fdf492f373c8
parent 5996fdf26aafd9a515724a31e4b4632e5b617c26
Author: Tinmarino <tinmarino@gmail.com>
Date:   Thu,  7 Jan 2021 22:06:55 -0300

Test: Add option to configure date string format #1073

Diffstat:
Mautoload/vimwiki/html.vim | 16+++++++++++-----
Mautoload/vimwiki/vars.vim | 3+--
Mdoc/design_notes.md | 3++-
Mtest/html_convert_default.vader | 26++++++++++++++++++++++++++
Atest/resources/testwiki/templates/template_1073.tpl | 7+++++++
Mtest/vimrc | 4++--
6 files changed, 49 insertions(+), 10 deletions(-)

diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim @@ -118,14 +118,20 @@ endfunction function! s:template_full_name(name) abort - if a:name ==? '' + let name = a:name + if name ==? '' let name = vimwiki#vars#get_wikilocal('template_default') - else - let name = a:name endif - let fname = expand(vimwiki#vars#get_wikilocal('template_path'). - \ name . vimwiki#vars#get_wikilocal('template_ext')) + " Suffix Path by a / is not + let path = vimwiki#vars#get_wikilocal('template_path') + if strridx(path, '/') +1 != len(path) + let path .= '/' + endif + + let ext = vimwiki#vars#get_wikilocal('template_ext') + + let fname = expand(path . name . ext) if filereadable(fname) return fname diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim @@ -1286,7 +1286,6 @@ endfunction " 4. Command (exported) {{{1 " ---------------------------------------------------------- - function! s:get_anywhere(key, ...) abort " Get variable anywhere " Returns: [value, location] where loc=global|wikilocal|syntaxlocal|bufferlocal|none @@ -1390,7 +1389,7 @@ endfunction function! vimwiki#vars#cmd(arg) abort " Set or Get a vimwiki variable - " :param: (1) key <string> [space] value <string> + " :param: (1) <string> command parameter: key [space] value " -- name of the variable [space] value to evaluate and set the variable " Called: VimwikiVar " Get key and value diff --git a/doc/design_notes.md b/doc/design_notes.md @@ -240,8 +240,9 @@ reasons for such a complex system is: * [Vimwiki syntax specification](./specification.wiki) * [Syntax region](../syntax/vimwiki.vim) +* [Nesting manager]( ../autoload/vimwiki/u.vim): vimwiki#u#hi_typeface(dic) -TODO currently the typeface delmiters are customized that way: +TODO currently the typeface delimiters are customized that way: ```vim " Typeface: -> u.vim diff --git a/test/html_convert_default.vader b/test/html_convert_default.vader @@ -280,7 +280,33 @@ Expect (Plain Html): </body> + Execute (Delete): call DeleteFile('$HOME/testwiki/TestHtml.wiki') + +Given vimwiki (PR: Add option to configure date string format 1073) {{{1): + %template template_1073 + content + +Do (template_date_format): +# Set conf + :let g:vimwiki_wikilocal_vars[0]['template_date_format'] = '%b %d, %Y'\<Cr> +# Convert + :call ConvertWiki2Html()\<Cr> +# Erase oth and date + :%s/[0-9]\+/Z/g\<Cr> + :%s/[A-Z][a-z][a-z]/Z/g\<Cr> +# Restore peace + :let g:vimwiki_wikilocal_vars[0]['template_date_format'] = ''\<Cr> + +Expect (Date proper format): + <html> + <body> + <div class="content"> + <p><small>Zt updated on Z Z, Z</small></p> + </div> + </body> + </html> + # vim: sw=2 foldmethod=marker foldlevel=30 diff --git a/test/resources/testwiki/templates/template_1073.tpl b/test/resources/testwiki/templates/template_1073.tpl @@ -0,0 +1,7 @@ +<html> +<body> + <div class="content"> + <p><small>Last updated on %date%</small></p> + </div> +</body> +</html> diff --git a/test/vimrc b/test/vimrc @@ -1,8 +1,7 @@ " TODO treat if local (see $HOME in all tests) -" TODO mutualise call CopyResources() " TODO mutualise (to prettify output) mode(1) to check if in -Es or not " TODO test tabnext in at least one travis job (without -Es) -" TODO (idea) fasten travis difefrent job with the same vimwiki git (-8s) +" IDEA fasten travis difefrent job with the same vimwiki git (-8s) " Declare tipical Vim preambule " vint: -ProhibitSetNoCompatible @@ -29,6 +28,7 @@ let vimwiki_default = {} let vimwiki_default.path = $HOME . '/testwiki' let vimwiki_default.path_html = $HOME . '/html/default' + let vimwiki_default.template_path = $HOME . '/testwiki/templates/' let vimwiki_default.syntax = 'default' let vimwiki_default.ext = '.wiki' let vimwiki_default.name = 'DefaultSyntax'