" Return the filename of the note with id `noteId`. If the file is note found, " then v:false is returned. function denote#meta#fileFromNoteId(noteId) " According to the file-naming scheme, the note id is prefixed with '@@'. If " the note id appears at the beginning of the filename, then this prefix is " optional. There may exist another field (such as the signature, title, or " keywords field) after the note id. These are prefixed with '==', '--', or " '__'. If the note id is the last field, then the id is followed by the file " extension, e.g., '.md'. " (A) First, we get all files that contain the note id as substring. " (B) Then we ensure that the note id is followed by another field or by the " file extension. let files = glob("*" .. a:noteId .. "*", 0, v:true) \ ->filter('v:val =~ "' .. a:noteId .. '\\(==\\|--\\|__\\|\\.\\)"') \ ->filter('v:val =~ "^' .. a:noteId .. '\\|@@' .. a:noteId .. '"') return empty(files) ? v:false : files[0] endfunction " Return the note id from the filename. On failure, v:false is returned. function denote#meta#noteIdFromFile(filename) return a:filename->matchstr("@@\\zs.\\{-\\}\\ze\\(==\\|--\\|__\\|\\..\\)") \ ?? a:filename->matchstr("^.\\{-\\}\\ze\\(==\\|--\\|__\\|\\..\\)") \ ?? v:false endfunction " Return the note title from the filename. On failure, v:false is returned. function denote#meta#noteTitleFromFile(filename) return a:filename->matchstr("--\\zs.\\{-\\}\\ze\\(==\\|@@\\|__\\|\\..\\)")->substitute("-", " ", "g") \ ?? v:false endfunction " Return the note tags from the filename as a list. function denote#meta#noteTagsFromFile(filename) return a:filename->matchstr("__\\zs.\\{-\\}\\ze\\(==\\|@@\\|--\\|\\..\\)")->split("_") endfunction " Identifier creation function denote#meta#identifier_generate() if g:denote_identifier_fun return execute "call " .. g:denote_identifier_fun .. "()" endif return exists("*strftime") \ ? strftime("%Y%m%dT%H%M%S") \ : rand() endfunction