Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 71edcf6802 | |||
| be45bd65f5 | |||
| 11350f572b |
@@ -449,7 +449,7 @@ function! vimwiki#base#generate_links(create, ...) abort
|
||||
let use_caption = vimwiki#vars#get_wikilocal('generated_links_caption', wiki_nr)
|
||||
for link in links
|
||||
let link_infos = vimwiki#base#resolve_link(link)
|
||||
if !vimwiki#base#is_diary_file(link_infos.filename, copy(l:diary_file_paths))
|
||||
if !vimwiki#base#is_among_diary_files(link_infos.filename, copy(l:diary_file_paths))
|
||||
let link_tpl = vimwiki#vars#get_syntaxlocal('Link1')
|
||||
|
||||
let link_caption = vimwiki#base#read_caption(link_infos.filename)
|
||||
@@ -2639,13 +2639,10 @@ function! s:clean_url(url) abort
|
||||
endfunction
|
||||
|
||||
|
||||
function! vimwiki#base#is_diary_file(filename, ...) abort
|
||||
" Check if 1.filename is a diary file
|
||||
" An optional second argument allows you to pass in a list of diary files rather
|
||||
" than generating a list on each call to the function.
|
||||
let l:diary_file_paths = a:0 > 0 ? a:1 : vimwiki#diary#get_diary_files()
|
||||
function! vimwiki#base#is_among_diary_files(filename, diary_file_paths) abort
|
||||
" Check if filename is in a list of diary files
|
||||
let l:normalised_file_paths =
|
||||
\ map(l:diary_file_paths, 'vimwiki#path#normalize(v:val)')
|
||||
\ map(a:diary_file_paths, 'vimwiki#path#normalize(v:val)')
|
||||
" Escape single quote (Issue #886)
|
||||
let filename = substitute(a:filename, "'", "''", 'g')
|
||||
let l:matching_files =
|
||||
@@ -2654,6 +2651,32 @@ function! vimwiki#base#is_diary_file(filename, ...) abort
|
||||
endfunction
|
||||
|
||||
|
||||
function! vimwiki#base#is_diary_file(filename, ...) abort
|
||||
" Check if filename is a diary file.
|
||||
"
|
||||
" For our purposes, a diary file is any readable file with the current wiki
|
||||
" extension in diary_rel_path.
|
||||
"
|
||||
" An optional second argument allows you to pass in a list of diary files
|
||||
" rather than generating a list on each call to the function. This is
|
||||
" handled by passing off to is_among_diary_files(). This behavior is
|
||||
" retained just in case anyone has scripted against is_diary_file(), but
|
||||
" shouldn't be used internally by VimWiki code. Call is_among_diary_files()
|
||||
" directly instead.
|
||||
|
||||
" Handle the case with diary file paths passed in:
|
||||
if a:0 > 0
|
||||
return vimwiki#base#is_among_diary_files(a:filename, a:1)
|
||||
endif
|
||||
|
||||
let l:readable = filereadable(a:filename)
|
||||
let l:diary_path = vimwiki#vars#get_wikilocal('path') .
|
||||
\ vimwiki#vars#get_wikilocal('diary_rel_path')
|
||||
let l:in_diary_path = (0 == stridx(a:filename, l:diary_path))
|
||||
return l:readable && l:in_diary_path
|
||||
endfunction
|
||||
|
||||
|
||||
function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template) abort
|
||||
" Treat link string towards normalization
|
||||
" [__LinkDescription__](__LinkUrl__.__FileExtension__)
|
||||
|
||||
@@ -4019,6 +4019,8 @@ master is retained as a legacy mirror of the dev branch.
|
||||
|
||||
This is somewhat experimental, and will probably be refined over time.
|
||||
|
||||
2023.04.04~
|
||||
|
||||
New:~
|
||||
* Issue #1261: Feature: Support for <mark> in Markdown
|
||||
highlighting with yellow background and back foreground
|
||||
@@ -4027,6 +4029,8 @@ New:~
|
||||
Also add the |blockquote_markers| variable
|
||||
|
||||
Fixed:~
|
||||
* Issue #1267: Improve performance on link creation by speeding up
|
||||
is_diary_file()
|
||||
* Issue #1229: Bug: VimwikiGoto without argument creates empty page
|
||||
* Issue #1316: Permit tags in heading
|
||||
and improve |VimwikiSearchTags| and |VimwikiRebuildTags|
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ endif
|
||||
let g:loaded_vimwiki = 1
|
||||
|
||||
" Set to version number for release:
|
||||
let g:vimwiki_version = '2022.12.02'
|
||||
let g:vimwiki_version = '2023.04.04'
|
||||
|
||||
" Get the directory the script is installed in
|
||||
let s:plugin_dir = expand('<sfile>:p:h:h')
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# Test vimwiki#base#is_diary_file() for various inputs.
|
||||
|
||||
Execute (Check known good diary file):
|
||||
VimwikiIndex 1
|
||||
let link_infos = vimwiki#base#resolve_link('diary:2020-07-22')
|
||||
Assert vimwiki#base#is_diary_file(link_infos.filename)
|
||||
|
||||
Execute (Check known good diary file using is_diary_file, with list of all diary files - legacy interface):
|
||||
VimwikiIndex 1
|
||||
let link_infos = vimwiki#base#resolve_link('diary:2020-07-22')
|
||||
let diary_file_paths = vimwiki#diary#get_diary_files()
|
||||
Assert vimwiki#base#is_diary_file(link_infos.filename, diary_file_paths)
|
||||
|
||||
Execute (Check known good diary file use is_among_diary_files, with list of all diary files):
|
||||
VimwikiIndex 1
|
||||
let link_infos = vimwiki#base#resolve_link('diary:2020-07-22')
|
||||
let diary_file_paths = vimwiki#diary#get_diary_files()
|
||||
Assert vimwiki#base#is_among_diary_files(link_infos.filename, diary_file_paths)
|
||||
|
||||
Execute (Check for nonexistent diary file):
|
||||
VimwikiIndex 1
|
||||
Assert !vimwiki#base#is_diary_file('not-a-diary-file')
|
||||
|
||||
Execute (Clean):
|
||||
call ReloadVimwiki()
|
||||
+1
-1
@@ -257,7 +257,7 @@ Expect (Correctly formatted tags file):
|
||||
!_TAG_PROGRAM_AUTHOR Vimwiki
|
||||
!_TAG_PROGRAM_NAME Vimwiki Tags
|
||||
!_TAG_PROGRAM_URL https://github.com/vimwiki/vimwiki
|
||||
!_TAG_PROGRAM_VERSION 2022.12.02
|
||||
!_TAG_PROGRAM_VERSION 2023.04.04
|
||||
second-tag Test-Tag.md 13;" vimwiki:Test-Tag\tTest-Tag#second-tag\tTest-Tag#second-tag
|
||||
test-tag Test-Tag.md 5;" vimwiki:Test-Tag\tTest-Tag#a-header\tA header
|
||||
top-tag Test-Tag.md 1;" vimwiki:Test-Tag\tTest-Tag\tTest-Tag
|
||||
|
||||
Reference in New Issue
Block a user