Respect Blank Lines in Preview Mode

When I’m in editor mode I can leave multiple blank lines between text. I find this useful for separating content and making my work more readable. However, when I switch to preview mode the blank lines are stripped and my work is horribly condensed again.

Any chance you would stop preview mode from stripping whitespace, or at least give the option to have preview mode respect blank lines?

Thank you!

20 Likes

I think it would be nice too. If you didn’t know, you can add a <br /> to get what you want.

1 Like

+1

is viable but not so graceful. :slight_smile:

1 Like
.markdown-preview-view div p {

margin-bottom: 1.5rem;

}

this css snippet works for a visual line break in preview @bagameow

Thank you for the CSS snippet, @hieu, but I think the request is not about generally increasing the spacing after every paragraph, as your snippet does; instead, it’s about (sometimes) using multiple empty lines to visually separate some parts/paragraphs from each other. This works well in edit mode (and most other note apps), but in preview mode, all this additional visual structure is lost.

1 Like

:sob: nods, makes prose so ugly, hurts my heart

1 Like

I took this answer from Stackoverflow:

this is a line with two hardbreaks below:\
\
\

…and it worked great for me. Cheers!

1 Like

For macOS, pressing OPT SPACE on a new line produces a blank line in preview mode.

Angel

1 Like

You can also do:

(empty line)
\
(tab)
(tab)

Each empty line with a tab will create an empty line in preview. the \ symbol won‘t be shown in preview.

Extra bonus: If you want to avoid the empty lines getting “swallowed” by folding an above header, do this:

# .
\
(tab)
(tab)

The amount of hashtags should be equal to the above header. Instead of a . you can also use another symbol, but I found the dot to be least obtrusive.

2 Likes

I appreciate people coming up with all kinds of creative workarounds, but they all require you to remember to do something special and potentially even uglify your notes significantly when viewed in edit mode. Plus, most users will simply be annoyed by the existing behavior and not come to the forums to search for some hacky workaround.

I’m cautiously optimistic, though, that this issue will get solved by the planned WYSIWYG editor mode, which is in the short-term section of the Obsidian roadmap.

3 Likes

Just in case someone in the future is looking for this: I found a workaround using an ‘invisible space character’ which creates identical line breaks in live preview as in reading mode:

1 Like

Thanks for the direction. I’d like to add that you can also get the Invisible character with the Obsidian console: copy(String.fromCodePoint(0x200e)).

With the Templater Plugin you can assign hotkey for the following template file: <% String.fromCodePoint(0x200e) + '\n' %>

The <br> is a visible mess. At the moment I can add invisible mess with Invisible Character, but that’s not a good thing. And I’m still looking for a solution, but the blank line doesn’t turn into anything and I can’t style it.


There are invisible characters here

The Live/Preview Source mode handles line breaks just fine.

The main problem of most new users who are biased with rich text editors is,
they don’t realize what it means when Obsidian uses markdown to display notes.This is the only problem.

If you want double or multiple line breaks, feel free to try out the community theme Dune. More info here. It won’t transform Obsidian in a WYSIWYG (What You See Is What You Get)- editor but adds a convenient way to add breaks.

One can argue if there should be multiple blank lines in rendered markdown or not - however, there is obvious demand for it. People use stuff in different ways and as long as there is a way to implement something without breaking something else - why not?

That being said I think there is a way to implement this feature without breaking something else, event though I might be wrong, because my markdown knowledge is limited:
If there are multiple blank lines inserted in editor mode, add a   OR
to the source.
Thats basically an extension of the editor, the souce and the Preview are still markdown compliant.

That being said I would prefer this change in combination with something else: Remove the toggle “Strict linebreaks” (as it is not Markdown standard) and instead add the toggle “Always use hard line breaks” (Basically what this plugin does - and you can read the argument for it there: GitHub - bkis/obsidian-hard-breaks: A plugin for Obsidian that adds functionality to force hard line breaks

Both in combination would mean that line breaks in editor mode, in preview mode and when viewing the saved markdown file in a different viewer always look the same. That would make writing stuff for people who come from WYSIWYG-Editors (like mee) just that little easier.

Could you please elaborate what you mean with that?