mirror of
https://github.com/tpope/vim-markdown.git
synced 2025-11-18 14:53:40 -05:00
better and more correct handling of front matter
This commit is contained in:
@@ -22,11 +22,6 @@ endif
|
|||||||
function! MarkdownFold()
|
function! MarkdownFold()
|
||||||
let line = getline(v:lnum)
|
let line = getline(v:lnum)
|
||||||
|
|
||||||
" Front matter
|
|
||||||
if v:lnum == 1 && line == '---'
|
|
||||||
return ">20"
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Regular headers
|
" Regular headers
|
||||||
let depth = match(line, '\(^#\+\)\@<=\( .*$\)\@=')
|
let depth = match(line, '\(^#\+\)\@<=\( .*$\)\@=')
|
||||||
if depth > 0
|
if depth > 0
|
||||||
@@ -43,10 +38,16 @@ function! MarkdownFold()
|
|||||||
return ">2"
|
return ">2"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Front matter
|
||||||
|
if v:lnum == 1 && line == '---'
|
||||||
|
let b:markdown_frontmatter = 1
|
||||||
|
return ">1"
|
||||||
|
endif
|
||||||
|
|
||||||
" End of front matter
|
" End of front matter
|
||||||
let prevline = getline(v:lnum - 1)
|
if (line == '...') && b:markdown_frontmatter
|
||||||
if (prevline == '...') && (foldlevel(v:lnum-1) == 20)
|
unlet b:markdown_frontmatter
|
||||||
return '>0'
|
return '<1'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return "="
|
return "="
|
||||||
|
|||||||
Reference in New Issue
Block a user