From 788a961052b843eeaa198dee0168fdf492f373c8 Mon Sep 17 00:00:00 2001 From: Tinmarino Date: Thu, 7 Jan 2021 22:06:55 -0300 Subject: [PATCH] Test: Add option to configure date string format #1073 --- autoload/vimwiki/html.vim | 16 ++++++++---- autoload/vimwiki/vars.vim | 3 +-- doc/design_notes.md | 3 ++- test/html_convert_default.vader | 26 +++++++++++++++++++ .../testwiki/templates/template_1073.tpl | 7 +++++ test/vimrc | 4 +-- 6 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 test/resources/testwiki/templates/template_1073.tpl diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim index 1d001ee..b36b032 100644 --- 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 index 7d8259e..7091f75 100644 --- 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 [space] value + " :param: (1) 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 index 3dbcf92..d628a0a 100644 --- 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 index 8a09fd3..90166a5 100644 --- a/test/html_convert_default.vader +++ b/test/html_convert_default.vader @@ -280,7 +280,33 @@ Expect (Plain Html): + 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'\ +# Convert + :call ConvertWiki2Html()\ +# Erase oth and date + :%s/[0-9]\+/Z/g\ + :%s/[A-Z][a-z][a-z]/Z/g\ +# Restore peace + :let g:vimwiki_wikilocal_vars[0]['template_date_format'] = ''\ + +Expect (Date proper format): + + +
+

Zt updated on Z Z, Z

+
+ + + # 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 new file mode 100644 index 0000000..e6de386 --- /dev/null +++ b/test/resources/testwiki/templates/template_1073.tpl @@ -0,0 +1,7 @@ + + +
+

Last updated on %date%

+
+ + diff --git a/test/vimrc b/test/vimrc index a81b3af..18791a6 100644 --- 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'