Spaces behind frontmatter "---" break the formatting of the note in Edit mode

Create a new note and type:

---
---<Space>

# Heading1

Expected result

Heading1 is formatted as a heading.

Actual result

Heading1 is not formatted as a heading

Environment

  • Operating system:
    I could verify this on Windows and Android.

  • Debug info:
    SYSTEM INFO:
    Obsidian version: v1.1.16
    Installer version: v1.1.9
    Operating system: Windows 10 Home 10.0.19045
    Login status: not logged in
    Insider build toggle: off
    Live preview: on
    Legacy editor: off
    Base theme: dark
    Community theme: none
    Snippets enabled: 0
    Restricted mode: on

RECOMMENDATIONS:
none


Additional information

If the official answer to this bahaviour is “Works as expected”, I recommend changing this expectation because this behaviour creates problems for users.

Thanks for Obsidian and for looking into this!

image

1 Like
---
---<Space>

# Heading1

The above doesn’t close the YAML header.

Because ---<Space> reads as YAML, the # Heading1 displays as a YAML comment, as expected.

2 Likes

Trailing white-space relevant for syntax is asking for trouble.

“The principle of least astonishment (POLA ), aka principle of least surprise (alternatively a law or rule ),[1][2] applies to user interface and software design.[3] It proposes that a component of a system should behave in a way that most users will expect it to behave, and therefore not astonish or surprise users.” Principle of least astonishment - Wikipedia

Yes, if you know about this you won’t be astonished, but most users will first not know about this.

3 Likes

Trailing white spaces are also used in Markdown with meaning:

When you do want to insert a <br /> break tag using Markdown, you end a line with two or more spaces, then type return.

Daring Fireball: Markdown Syntax Documentation

And ---<space> is used in YAML for directive indicators, such as between log items.

In both cases they seem to pass POLA (for users who are used to the specs). Both are outside of Obsidian’s control, I think, but perhaps could be raised with the people responsible for YAML and Markdown specs.

As such I think that invisible trailing white space is not a great idea in any interface. Hope that Obsidian will one day add a core option to display white spaces and non-printing artefacts in edit mode.

EDIT: At least users can see by the onscreen formatting in edit mode that the text is being rendered as YAML (guess that might depend on the theme used) and so know that something needs changing, and when viewing in read mode Obsidian will give an ‘invalid YAML’ warning. Safety nets, of sorts? Writing aids?

2 Likes

Thanks for the info! In the YAML spec it says:

YAML uses three dashes (“--- ”) to separate directives from document content.

It doesn’t say that the line must end after the three dashes or that whitespace after the three dashes should make any difference.

I cannot find --- with trailing whitespace anywhere in the YAML spec. ---<space> is always followed by non-whitespace there.

But I don’t know much about YAML and thus I am happy to learn if I am wrong.

1 Like

thanks. I have seen users confused about this.

1 Like

will be fixed 1.3.2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.