Formatting like bold/italics/etc across multiple paragraphs

Use case or problem

If you select multiple paragraphs and hit a keyboard shortcut to Bold, Italicise, Strikethrough, etc, Obsidian will just insert ** or ~~ or the like at the start of the first paragraph and end of the last one.

This does not result in the expected formatting.

Instead, Obsidian could insert the the ** or ~~ markers at the start and end of each paragraph in the selection.

This would match expected behaviour. E.g., this is what happens in Dynalist. You select multiple list items, hit Bold, and markers are inserted inside each item.

Will this be a surprising change?

The user has a clear, unambiguous intent. They selected multiple paragraphs. They want to bold them. Right now, it doesn’t. The current behaviour with multiple paragraphs doesn’t accomplish much, so changing the current behaviour shouldn’t be a problem.

Proposed solution

Change logic for applying inline styles like bold, italics, highlights, and strikethrough so that:
if multiple paragraphs are selected, then markers are inserted for each paragraph.

If the first or last paragraph are only partially selected (not the entirety), then that case is handled appropriate to only bold that part of the paragraph.

Paragraphs are defined as being separated by blank lines, where by blank lines I mean a line consisting only of spaces. This logic matches the behaviour of the inline style. E.g.

across newlines
like this**

works but

**Bold across
newlines when there’s a
a blank line with or without spaces
doesn’t work**

Current workaround

The current behaviour of trying to apply an inline style across paragraph does nothing! Instead, just have to insert the markers manually for each paragraph.

Having the feature to easily apply styles to multiple paragraphs would be a great help.

1 Like

+1, I agree this is a bug.

It’s not obvious that it’s a bug, so I spent some time researching this to understand what the correct behavior should be for markdown.

It’s not clearly specified in the specification whether wrapping multiple paragraphs in one set of emphasis characters (*/_ or **/__) should work or not.

Daring Fireball: Markdown Syntax Documentation just says “Text wrapped with one * or _ will be wrapped with an HTML <em> tag; double * ’s or _ ’s will be wrapped with an HTML <strong> tag.”

Basic Syntax | Markdown Guide says “You can add emphasis by making text bold or italic. To bold text, add two asterisks or underscores before and after a word or phrase.”

I can’t find any authorative source describing whether or not multiple lines wrapped in emphasis is valid markdown or not, but most tools seem to treat it as invalid.

If that’s the case, I agree that obsidian should default to producing valid sensible markdown for the use case, and I agree that the most sensible way to handle it is to wrap each line of text in emphasis.

I agree that formatting shortcuts should be applied per paragraph if multiple paragraph are selected. I’ll add this FR to the valuable list.

afaics It doesn’t work in Obsidian either! LP or legacy.
Select two lines. Bold them. Add empty line between existing lines thereby turning them into paragraphs. Bolding will disappear from second paragraph.

Bold two paragraphs and only the first bolds.

This function works perfectly well in Marktext and Typora, and my more traditional markdown editor, WriteMonkey; they all add the ** to start and end of each line. I think it is a bug.

1 Like