Inline Code Spans Should Not Collapse Consecutive Whitespace

Steps to reproduce

  1. Open new document
  2. Write a sentence and include an inline code span with consecutive interior spaces:
# Test document

**Inline Code**: `foo  bar` (baz)

Expected result

Consecutive spaces are not collapsed, in either Editor or Reader mode.

Test Document

Inline Code: foo··bar (baz)

Actual result

Consecutive spaces are collapsed, in both Editor and Reader mode.

Test Document

Inline Code: foo·bar (baz)


Additional information

According to CommonMark Spec, and conventional Markdown experience, interior consecutive spaces are not supposed to be collapsed:

Interior spaces are not collapsed:

Example 337


Note that browsers will typically collapse consecutive spaces when rendering <code> elements, so it is recommended that the following CSS be used:

code{white-space: pre-wrap;}

On mobile I don’t see the behavior in editing view (but I do in reading view).

In original Markdown inline code spans in Markdown aren’t intended to be marked as pre-formatted. Block is marked with <pre> and <code>: Daring Fireball: Markdown Syntax Documentation, inline is marked with only <code>: Daring Fireball: Markdown Syntax Documentation. The CommonMark spec, which Obsidian largely follows, uses that same markup but says whitespace should not be collapsed and recommends the CSS suggested by OP. CommonMark Spec

1 Like

I don’t see this in the editor. Happens in reading mode

Oops! You’re right, this can only be reproduced in Reading mode.

EDIT: Doesn’t look like I can edit the post anymore :sweat_smile:

Expected result should be the same, but “Actual result” should be: