Add a title with “# Title A” then a subtitle with “## Subtitle” and then again any title with “# Title B”
Add some content below of each of the titles
Fold the subtitle
You will then see, that subtitle and the next title will have no gap between them, which makes reading a bit difficult.
If you add a newline before “# Title B” you now have a fitting gap.
So far so good.
But now expand and fold the subtitle again!
You will see that the subtitle “ate” the new empty line!
Will leads in the subtitle growing over time with more and more empty lines and you never will have the distance between the titles.
Proposed Solution
For folding, only fold up to the last line with content, but NOT empty lines!
Trailing empty times should never be folded - they don’t belong to the folded section but to the containing file itself.
Friends and fellow folders — I bring magic from CSS wizard @sailKite in the form of a snippet they have graciously provided at my humble request!
/* Put some vertical space under folded headings for better readbility.
Courtesy of @sailkite https://discord.com/channels/686053708261228577/702656734631821413/1136455149691347045
Re: feature request https://forum.obsidian.md/t/when-folding-dont-include-trailing-empty-lines/43973
"and of course you can do it a different way where instead you modify the top padding on things that come after
"which may have relevance in some cases but i'm struggling to think of any off the top of my head... maybe in embeds or something"
For a rough version of this different way see https://forum.obsidian.md/t/when-folding-dont-include-trailing-empty-lines/43973/10
*/
.is-collapsed > :is(h1, h2, h3, h4, h5, h6),
.HyperMD-header:has(> .cm-fold-indicator.is-collapsed, > .cm-foldPlaceholder) {
padding-bottom: 24px;
}
It doesn’t preserve your literal blank lines but it adds some padding under folded headings for much the same effect.