CSS Snippet Indent not working

So I wanted to add a custom css snippet; it is not working and I don’t know why.

Snippet:

/* TEXT INDENT */

/* regular indent */
.indent .cm-content .cm-line {
    text-indent: 1.5rem;
}

/* no indent for header */
.indent .cm-content .HyperMD-header {
    text-indent: 0;
}

.indent .cm-content .HyperMD-header+.cm-line,
.indent .cm-content .HyperMD-quote+.cm-line {
    text-indent: 0;
}

.indent .cm-content .HyperMD-header+.cm-line+.cm-line,
.indent .cm-content .HyperMD-quote+.cm-line+.cm-line {
    text-indent: 0;
}

In my document’s properties I added the css-class indent

And nothing happened.

Can someone help me out?

Maybe I should explain what my desired result is:

  1. No indent for quotes and the first paragraph under a new header
  2. Ident for every following paragraph

It seems mostly working on this end. The only part that isn’t doing anything or necessary is:

.indent .cm-content .HyperMD-quote+.cm-line { text-indent: 0; }

because you need an blank/empty line after a block quote anyway.

Source mode:

Live Preview:


Keep in mind that the CSS as is won’t do anything in Reading view or rendered contexts, i.e., it’s only targeting the editor.

1 Like

I had the setting “save as .rtf” enabled instead of a plain text, so the .css file was faulty. Didn’t know you have to change it on MacOS.
Now it works. Thanks for checking, so I knew the problem was in my end.
And good point on the redundant part of the snippet. I will leave it out.

Yeah, that will do it.

I recommend using a proper code editor if you’re going to be doing a lot of this.

TextMate, Sublime Text, and VSCode are great options on macOS, but there are many.

Ah thanks. Normally I never code, just trying some stuff out to customise my Obsidian experience.
I found the snippet somewhere else. Sadly, I don’t remember the author. I link him if I find the post again.

Thanks for the recommendations, though. I will definitely get one of the programmes just to have a proper one on hand.

Got it.

I’d grab TextMate then. Free, lightweight, and won’t make any funky .rtf files.

Yup, did just that after seeing the prize tag on Sublime Text.

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