Skip to content

Commit a83a87d

Browse files
committed
avoid hardcoding markdown syntax
1 parent cb8d854 commit a83a87d

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

autoload/vimwiki_tasks.vim

+14-7
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ function! vimwiki_tasks#open_tasknotes()
547547
call vimwiki_tasks#insert_task_details(l:uuid)
548548
" Insert the notes header
549549
" call append(line('$'), '')
550-
call append(line('$') - 1, '## Notes')
550+
call append(line('$') - 1, <SID>CreateHeader('Notes'))
551551
" put the cursor on the last line
552552
normal G
553553
endif
@@ -559,17 +559,18 @@ endfunction
559559
function! vimwiki_tasks#insert_task_details(uuid)
560560
let l:details = vimwiki_tasks#load_full_task(a:uuid)
561561
call append(0, '%% TaskUUID: '.a:uuid)
562-
" TODO: don't hardcode markdown syntax
563562
call append(1, '')
564-
call append(2, '# '.<SID>Strip(l:details.description))
565-
call append(3, '## Task details')
563+
call append(2, <SID>Strip(l:details.description))
564+
normal 3gg
565+
call vimwiki#base#AddHeaderLevel()
566+
call append(3, <SID>CreateHeader('Task details'))
566567
let l:i = 4
567568
for l:detail in l:details.details
568569
call append(l:i, l:detail)
569570
let l:i += 1
570571
endfor
571572
call append(0 + l:i, '')
572-
call append(1 + l:i, '## Annotations')
573+
call append(1 + l:i, <SID>CreateHeader('Annotations'))
573574
let l:i += 2
574575
for l:annotation in l:details.annotations
575576
call append(l:i, l:annotation)
@@ -597,8 +598,7 @@ function! vimwiki_tasks#update_tasknote()
597598
let l:last_modified_line = l:line
598599
endif
599600
" check if we already match the Annotations header
600-
" TODO: don't hardcode markdown syntax
601-
if match(l:line, '\v^## Annotations') != -1
601+
if match(l:line, '\v^'.<SID>CreateHeader('Annotations')) != -1
602602
let l:last_header_match = 1
603603
endif
604604
" check if we are past the last header, then the first empty line
@@ -623,5 +623,12 @@ function! vimwiki_tasks#update_tasknote()
623623
let &mod = 1
624624
echo "Updated the task details"
625625
endif
626+
endfunction
626627

628+
function! s:CreateHeader(header)
629+
let hdr = g:vimwiki_rxH.g:vimwiki_rxH.' '.a:header
630+
if g:vimwiki_symH
631+
let hdr .= ' '.g:vimwiki_rxH.g:vimwiki_rxH
632+
endif
633+
return hdr
627634
endfunction

0 commit comments

Comments
 (0)