From 966a94bd477f3b10ae7b66693508274c9aaf1288 Mon Sep 17 00:00:00 2001 From: Nick Borden Date: Mon, 28 May 2018 12:24:29 -0700 Subject: [PATCH] Diary links should use markdown syntax when appropriate (#500) When markdown syntax is enabled, generated links should use markdown link syntax. Fix #499 --- autoload/vimwiki/diary.vim | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/autoload/vimwiki/diary.vim b/autoload/vimwiki/diary.vim index 1ceeb2e..164211d 100644 --- a/autoload/vimwiki/diary.vim +++ b/autoload/vimwiki/diary.vim @@ -150,17 +150,21 @@ function! s:format_diary() \ '__Header__', s:get_month_name(month), '')) for [fl, cap] in s:sort(items(g_files[year][month])) - if empty(cap) - let entry = substitute(vimwiki#vars#get_global('WikiLinkTemplate1'), - \ '__LinkUrl__', fl, '') - let entry = substitute(entry, '__LinkDescription__', cap, '') - call add(result, repeat(' ', vimwiki#lst#get_list_margin()).'* '.entry) - else - let entry = substitute(vimwiki#vars#get_global('WikiLinkTemplate2'), - \ '__LinkUrl__', fl, '') - let entry = substitute(entry, '__LinkDescription__', cap, '') - call add(result, repeat(' ', vimwiki#lst#get_list_margin()).'* '.entry) + let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate2') + + if vimwiki#vars#get_wikilocal('syntax') == 'markdown' + let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink1Template') + + if empty(cap) " When using markdown syntax, we should ensure we always have a link description. + let cap = fl + endif + elseif empty(cap) + let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate1') endif + + let entry = substitute(link_tpl, '__LinkUrl__', fl, '') + let entry = substitute(entry, '__LinkDescription__', cap, '') + call add(result, repeat(' ', vimwiki#lst#get_list_margin()).'* '.entry) endfor endfor