From 12b72de8527218594dbc82e8e274d6763b98b1cf Mon Sep 17 00:00:00 2001 From: David Baynard Date: Thu, 28 Mar 2019 14:11:07 +0000 Subject: [PATCH 1/2] Fold html comments in an identical manner to code blocks --- after/ftplugin/markdown/folding.vim | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/after/ftplugin/markdown/folding.vim b/after/ftplugin/markdown/folding.vim index 9198ed1..f048a63 100644 --- a/after/ftplugin/markdown/folding.vim +++ b/after/ftplugin/markdown/folding.vim @@ -8,7 +8,13 @@ function! StackedMarkdownFolds() elseif thisline =~ '^```$' && nextline =~ '^\s*$' " end of a fenced block return "<2" endif - + + if thisline =~ '^$' && nextline =~ '^\s*$' " end of an HTML commented block + return "<2" + endif + if HeadingDepth(v:lnum) > 0 return ">1" else @@ -26,6 +32,12 @@ function! NestedMarkdownFolds() return "s1" endif + if thisline =~ '^$' && nextline =~ '^\s*$' " end of an HTML commented block + return "s1" + endif + let depth = HeadingDepth(v:lnum) if depth > 0 return ">".depth From 3af939a95c9836ff075e38d15efcc203735a44c3 Mon Sep 17 00:00:00 2001 From: David Baynard Date: Thu, 28 Mar 2019 14:14:01 +0000 Subject: [PATCH 2/2] Integrate html comment regex with code blocks --- after/ftplugin/markdown/folding.vim | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/after/ftplugin/markdown/folding.vim b/after/ftplugin/markdown/folding.vim index f048a63..c07f3e7 100644 --- a/after/ftplugin/markdown/folding.vim +++ b/after/ftplugin/markdown/folding.vim @@ -3,15 +3,9 @@ function! StackedMarkdownFolds() let thisline = getline(v:lnum) let prevline = getline(v:lnum - 1) let nextline = getline(v:lnum + 1) - if thisline =~ '^```.*$' && prevline =~ '^\s*$' " start of a fenced block + if thisline =~ '^\%(```\|$' && nextline =~ '^\s*$' " end of an HTML commented block + elseif thisline =~ '^\%(```\|-->\)$' && nextline =~ '^\s*$' " end of a fenced block or HTML commented block return "<2" endif @@ -26,15 +20,9 @@ function! NestedMarkdownFolds() let thisline = getline(v:lnum) let prevline = getline(v:lnum - 1) let nextline = getline(v:lnum + 1) - if thisline =~ '^```.*$' && prevline =~ '^\s*$' " start of a fenced block - return "a1" - elseif thisline =~ '^```$' && nextline =~ '^\s*$' " end of a fenced block - return "s1" - endif - - if thisline =~ '^$' && nextline =~ '^\s*$' " end of an HTML commented block + elseif thisline =~ '^\%(```\|-->\)$' && nextline =~ '^\s*$' " end of a fenced block or HTML commented block return "s1" endif