handle variable-length front matter
This commit is contained in:
@@ -155,7 +155,7 @@ endfunction
|
||||
" @argument a:md_type string: Any of 'yaml' (default) or 'toml', for
|
||||
" markdown front matter
|
||||
" @return: List of strings with a line-per item that describes the front matter
|
||||
function libdenote#fm_gen(ext, id, title, tags=[], md_type='yaml')
|
||||
function libdenote#fm_gen(ext, id, title, tags, md_type='yaml')
|
||||
return a:ext == 'org' ? s:org_new(a:id, a:title, a:tags)
|
||||
\ : a:ext == 'txt' ? s:plain_new(a:id, a:title, a:tags)
|
||||
\ : a:md_type == 'toml' ? s:md_new_toml(a:id, a:title, a:tags)
|
||||
@@ -180,7 +180,8 @@ function libdenote#fm_alter(fm, mod)
|
||||
let l:repl = libdenote#fm_gen(l:ext,
|
||||
\ has_key(a:mod, 'id') ? a:mod.id : '',
|
||||
\ has_key(a:mod, 'title') ? a:mod.title : '',
|
||||
\ has_key(a:mod, 'tags') ? a:mod.tags : [])
|
||||
\ has_key(a:mod, 'tags') ? a:mod.tags : [],
|
||||
\ g:denote_fm_md_type)
|
||||
if has_key(a:mod, 'date')
|
||||
let l:ididx = indexof(l:repl, 'v:val =~ "^\\(#+\\)\\?date"')
|
||||
call map(l:new, {_, v -> v =~ "^\\(#+\\)\\?date" ? l:repl[l:ididx] : v})
|
||||
@@ -199,11 +200,3 @@ function libdenote#fm_alter(fm, mod)
|
||||
endif
|
||||
return l:new
|
||||
endfunction
|
||||
|
||||
" Returns the length of a front matter (number of lines)
|
||||
" @argument a:ext string: File extension
|
||||
function libdenote#fm_len(ext)
|
||||
return a:ext == 'org' ? 4
|
||||
\ : a:ext == 'txt' ? 5
|
||||
\ : 6
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user